document-policy
document-policy copied to clipboard
Feature Request: policy for well formed DOM
Currently DOM permits a lot of trees that couldn't be represented in HTML or are semantically invalid.
For example this tree couldn't be represented in HTML but can be constructed in DOM anyway:
p
"Some text"
p "Another paragraph nested inside"
"More text"
Another example is this tree that can be represented in HTML but could break accessibility:
p "Some text"
li "An out of place list item"
p "Some more text"
I propose a feature policy well-formed-dom that fails to construct DOM if it would break the content model specified by HTML.
FWIW, while I appreciate the sentiment, I don't think this is doable. This would add massive complexity and doesn't really buy us much. It would mostly lead to slower code.