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

Scripting flag and behaviour for noscript #7

Open
ArkadiuszMichalski opened this issue May 8, 2016 · 1 comment
Open

Scripting flag and behaviour for noscript #7

ArkadiuszMichalski opened this issue May 8, 2016 · 1 comment

Comments

@ArkadiuszMichalski
Copy link

ArkadiuszMichalski commented May 8, 2016

This flag determinate behaviour for noscript. Default scripting flag depends on scripting was enabled/disabled 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 only check scripting flag state (doesn't change it).
And now in P&S I see:

  • all commands that use fragment parsing algorithm (Element.innerHTML, Element.outerHTML, Element.insertAdjacentHTML, Range.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:
<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 div2 = document.createElement("div");
    div2.insertAdjacentHTML("afterbegin", "<noscript><p>test1<p>test2</noscript>");
    console.log(div2.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>
@domenic
Copy link
Collaborator

domenic commented Jan 5, 2020

whatwg/html#5190 takes care of your second point by removing the note about the scripting flag and instead noting that there's no browsing context so scripting is disabled. I will also add tests to web-platform-tests/wpt#21041 if they don't exist already, for DOMParser.

The other part of the issue will wait until we move those APIs into HTML, but it's possible that could be soon.

domenic added a commit to web-platform-tests/wpt that referenced this issue Jan 5, 2020
domenic added a commit to web-platform-tests/wpt that referenced this issue Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants