@actualwave/walker-browserdom-augmentations

0.0.3 • Public • Published

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.

API

  • 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.

DEMO

Package Sidebar

Install

npm i @actualwave/walker-browserdom-augmentations

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

16.3 kB

Total Files

7

Last publish

Collaborators

  • actualwave