Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAXParser: an HTML content inside <noscript> tag is not parsed correctly #105

Closed
eGavr opened this issue Feb 13, 2016 · 4 comments
Closed
Labels

Comments

@eGavr
Copy link

eGavr commented Feb 13, 2016

Hi, here is the minimal test case:

var parse5 = require('parse5');

var parser = new parse5.SAXParser();

parser.on('startTag', function(tagName) {
    console.log(tagName); // logs only 'noscript'
});

parser.write('<noscript><div></div></noscript>')

The parser supposes that the content of <nonscript> is a simple text, but it is an HTML, isn't it?

@inikulin
Copy link
Owner

parse5 always behaves as an interactive user agent, so it parses noscript as a text, like browsers with enabled javascript do. If you wish to contribute, we can introduce option to switch parse5 to non-interactive user agent mode. Searching Tree Construction section of the HTML spec for "interactive user agent" is a good starting point.

@eGavr
Copy link
Author

eGavr commented Feb 13, 2016

As I remember browsers with enabled javascript just skip the content of tag nonscript, but not consider it as text.

Why do not parse a content as HTML in case of HTML by default? :)
I mean, that the parser could detect whether a content is HTML or not and parse it in the first case, and do not parse in the second one.

@inikulin
Copy link
Owner

Because it's per spec.

@inikulin
Copy link
Owner

As I remember browsers with enabled javascript just skip the content of tag nonscript, but not consider it as text.

It's considered as a text. It's just not rendered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants