rehype-dom-parse
Advanced tools
Comparing version
@@ -31,2 +31,4 @@ /** | ||
const DOCUMENT_FRAGMENT_NODE = 11 | ||
/** | ||
@@ -37,13 +39,12 @@ * @param {string} htmlString | ||
function createFragment(htmlString) { | ||
const fragment = document.createDocumentFragment() | ||
const temporary = document.createElement('body') | ||
temporary.innerHTML = htmlString | ||
let child = temporary.firstChild | ||
const doc = createDocument('<!doctype html><body>' + htmlString) | ||
while (child) { | ||
fragment.append(child) | ||
child = temporary.firstChild | ||
} | ||
return fragment | ||
/** | ||
* Pretend as a DocumentFragment node, | ||
* @see https://github.com/rehypejs/rehype-dom/pull/19 for more details | ||
*/ | ||
return /** @type {DocumentFragment} */ ({ | ||
nodeType: DOCUMENT_FRAGMENT_NODE, | ||
childNodes: doc.body.childNodes | ||
}) | ||
} | ||
@@ -50,0 +51,0 @@ |
{ | ||
"name": "rehype-dom-parse", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "rehype plugin to use browser APIs to parse HTML", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
7790
1%71
1.43%