A parse5-compatible TreeAdapter for the DOM
Clone or download
Pull request Compare This branch is 2 commits behind nrkn:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
test
.gitattributes
.gitignore
.jshintrc
index.js
package-lock.json
package.json
readme.md

readme.md

dom-treeadapter

A parse5-compatible TreeAdapter for the DOM

See TreeAdapter at parse5 documentation

Install

npm install dom-treeadapter

Usage

Browser:

const parse5 = require( 'parse5' )
const Adapter = require( 'dom-treeadapter' )

const adapter = Adapter( window.document )

const domNodes = parse5.parseFragment( '<div></div>', { treeAdapter: adapter } )

jsdom:

const parse5 = require( 'parse5' )
const Adapter = require( 'dom-treeadapter' )
const jsdom = require( 'jsdom' )

const { JSDOM } = jsdom
const dom = new JSDOM( '<!doctype html>' )
const { document } = dom.window

const adapter = Adapter( document )

const domNodes = parse5.parseFragment( '<div></div>', { treeAdapter: adapter } )