Skip to content

Make DOMPurify work in Node.js #29

@fhemberger

Description

@fhemberger

Regarding issue #26 and #27, I originally held back Common JS style exports and publishing on npm on purpose, as DOMPurify doesn't run on a pure Node.js environment (it does client side with Browserify).

I'm still looking for a way to get it to work on Node.js as well. jsdom lacks DOM Level 2 Traversal methods like createNodeIterator at the moment, which DOMPurify uses internally.

What's currently missing:

  • document.implementation.createHTMLDocument
    (polyfilled with return jsdom('<html><body></body></html>');)
  • `window.NodeFilter (extracted the properties needed for DOMPurify from the spec)
  • document.createNodeIterator(root, whatToShow, filter, entityReferenceExpansion)
  • NodeIterator.nextNode() implementation
  • Setter method for document.body.outerHTML

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions