JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q33434F
  • License ISC

Visitor DOM crawler, executing given function recursively beginning with the provided node.

Package Exports

  • dom-visitor

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dom-visitor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dom-visitor

Visitor designed for DOM crawling and node modification.

If you'd like a sensible way of collecting information about nodes, then I'd recommend using the dom-reducer:

DOMVisitor takes 2 arguments:

  • startingNode ex.: document.body,

  • fn, a function called on every node, ex.: node => node => (node["onclick"] ? delete node["onclick"] : void 0)

DOMVisitor supports Browser, Node.js & AMD.

USAGE

Refer to index.spec.js for Node.js fakeDOM example

In browser: inject DOMVisitor code unto a website through devtools or script tag, then:

const removeAttribute = (attr, node) =>
  DOMVisitor(node, node => (node[attr] ? delete node[attr] : void 0));

removeAttribute("onclick", document.body);

Happy DOM crawling!