taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

parser fails to keep script element child nodes #55

Closed niole closed 4 years ago

niole commented 4 years ago

failing repro:

const page = "<!DOCTYPE html><html lang="en"><head></head><body><script id="storeFinder" type="application/json">{"key":true}</script></body></html>"
const root = parse(page);
const storeFinder = document.querySelector("#storeFinder");
console.log("store finder exists", storeFinder !== null);
console.log("no child nodes are kept", storeFinder.childNodes.length === 0);

Expectation: the parser keeps the child nodes of script tags as text nodes, like how the parser keeps text nodes of divs

peterlerche commented 4 years ago

I have the same issue. Any idea how to work around it ?

peterlerche commented 4 years ago

Have just discovered that it is not just affect Githubissues.

  • Githubissues is a development platform for aggregating issues.