Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

replying to myself like a pro: after reading the spec https://www.w3.org/TR/html5/scripting-1.html#the-noscript-el..., the <noscript> element is even trickier, it has at least 4 parsing modes:

in the head with scripting disabled (no text, only link, style, meta)

in the head, with scripting enabled (can include text (like whitespaces) but parsed elements must result in link,style,meta DOM only)

in the body with scripting disabled (text, but no other noscript)

in the body with scripting enabled (text, but no other noscript and script tags)

so basically

  <html><noscript><link href="e.css"></noscript><title>hi</title><h1>ho</h1>
would be find, as the <head> would close just before the <h1> (in scripting enabled and disabled case)

but:

  <html><noscript> <link href="e.css"></noscript><title>hi</title><h1>ho</h1>
would close the <head> in a scripting disabled case just before the <noscript>-tag

and closes the <head> just before the <h1> in a scripting enabled case.

this would explain the DOMParser.parseFromString() behaviour, as it's a scripting disabled case....



http://software.hixie.ch/utilities/js/live-dom-viewer/saved/...

In Chrome Canary 55.0.2866.0 the noscript element contains a text node and a link element. This matches the spec as far as I can tell; whitespace is allowed in noscript in head.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: