[w3c/webcomponents] Quirks render mode in HTML Modules (#797)

(Copied from legacy repo)
OP by @dandclark 

The question was raised as to whether HTML modules should require `<!doctype html>` to keep the HTML Module document out of quirks mode. Quirks mode can have effects outside of CSS, e.g. it determines whether [getElementsByClassName()](https://dom.spec.whatwg.org/#concept-getelementsbyclassname) is case-sensitive. So, the render mode can have an impact for HTML Modules even though the HTML Module document itself isn't displayed.

If we were to follow the language of the [parser spec](https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode) today, an HTML Module’s document would be placed in quirks mode if it had no doctype. I don’t think this is ideal though, because one way we expect the feature to be used is for smaller HTML snippets – e.g. a single `<template>` element – and we don’t want to require that people specify `<!doctype>`s for these or else end up in quirks mode.

So it seems there are two possible ways to go:

* A. As part of the HTML Module spec changes, specify that an HTML Module’s document inherits its quirks mode status from the top-level importing document.
* B. Enforce that all HTML Module documents are standards-mode regardless of `<!doctype>`.  A similar thing was done with [iframe srcdoc documents](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#an-iframe-srcdoc-document), probably for similar reasons.  See the parser spec [here](https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode) where these are specifically eliminated from quirks mode considerations.  We could follow this pattern.

I like option (B) because I see no reason why code written in HTML Modules (which will presumably be all or mostly new) should ever need quirks mode; because of the prior art with iframe srcdoc; and because it’s similar to JS module scripts automatically enforcing `"use strict"`.

Any objections to this?

-- 
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/webcomponents/issues/797

Received on Wednesday, 27 February 2019 03:58:15 UTC