TreeWalker augmentations for DOM Nodes

Usage no npm install needed!

<script type="module">
  import actualwaveWalkerBrowserdomAugmentations from 'https://cdn.skypack.dev/@actualwave/walker-browserdom-augmentations';


TreeWalker Browser DOM Augmentations

TreeWalker augmentations for DOM Nodes. It's used in DOMWalker library to add to TreeWalker HTML Element-specific funcitons, like adding event listeners or getting attributes.


  • name():String -- retrieve Node.nodeName

  • text():String -- retrieve Node.innerText

  • attributes():NamedNodeMap -- retrieve Element.attributes

  • attribute(name:String, value:?any):any -- get attribute by name, if second arguemtn passed, will set it as attribute value, if second arguemtn is undefined, will remove attribute.

  • parent():Node -- returns parent node

  • root():Node -- return root node of DOM tree

  • query(selector:String):Node -- equivalent to Element.querySelector()

  • queryAll(selector:String):NodeList -- equivalent to Element.querySelector()

  • on(eventType:String, listener:Function):Function -- add event lsitener, returns callback that will remove event listner once called.

  • off(eventType:String, listener:Function) -- remove event listener.

  • emmit(event:Event|String) -- dispatch Event, if string passed, will create Event of this type.