Skip to content

Quirks render mode in HTML Modules #797

@travisleithead

Description

@travisleithead

(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() 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 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, probably for similar reasons. See the parser spec here 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions