[w3c/DOM-Parsing] Scripting flag and behaviour for noscript (#7)

This flag determinate behaviour for noscript. Default [scripting flag](https://html.spec.whatwg.org/multipage/syntax.html#scripting-flag) depends on [scripting was enabled/disabled](https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-script) which depends if node's node document has a browsing context and scripting is enabled in that browsing context.
If needed then scripting flag can be force so we can have scripting flag set to "enabled" where scripting was disabled. Comment from HTML spec: "The scripting flag can be enabled even when the parser was originally created for the HTML fragment parsing algorithm, even though script elements don't execute in that case."
[HTML fragment parsing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#html-fragment-parsing-algorithm) only check scripting flag state (doesn't change it).
And now in P&S I see:
- all commands that use fragment parsing algorithm (`nnerHTML`, `outerHTML`, `createContextualFragment`) don't set explicity a scripting flag. They operate on intermediate document without browsing context so this flag has default state "disabled" so noscript element should be parsed. But browsers don't do this so probably somewhere this flag should be set to "enabled" in P&S spec.
- for DOMParser.parseFromString() and "text/html" you wrote "The scripting flag must be set to "disabled" but it's obvious because returned document doesn't have browsing context and second green box inform about parsing noscript element. 
Some test:
```js
<script type = "text/javascript">
 var div = document.createElement("div");
 div.innerHTML = "<noscript><p>test1<p>test2</noscript></noscript>";
 console.log(div.firstChild.childNodes.length, div.firstChild.firstChild); // 1 text

 var frag = document.createRange().createContextualFragment("<noscript><p>test1<p>test2</noscript>");
 console.log(frag.firstChild.childNodes.length, frag.firstChild.firstChild); // 1 text

 var doc = new DOMParser().parseFromString("<body><noscript><p>test1<p>test2</noscript>", "text/html");
 console.log(doc.body.firstChild.childNodes.length, doc.body.firstChild.firstChild, doc.body.firstChild.lastChild); // 2 p p 
 console.log(doc.defaultView); // null - this new document is without browsing context
</script>
```

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/DOM-Parsing/issues/7

Received on Sunday, 8 May 2016 17:04:21 UTC