Choose contentDOM wrapper more carefully and add display: contents #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two related issues solved by this change:
Firstly, it's possible to produce invalid (and broken) HTML with the current approach of duplicating the contentDOM. For example, if the contentDOM is a
ul
tag, we will currently produce<ul><ul><!-- content --></ul></ul>
, which is almost certainly not desired. This PR fixes this by always choosing adiv
or aspan
(both non-semantic), and choosing which to use based on whether the contentDOM is phrasing content (meaning that it's meant to be inside of a paragraph/textblock, like aspan
or other inline elements).Secondly, since this contentDOM wrapper is totally inaccessible to consumers (they can't add styles or event handlers or what-have-you to it), we make it
display: contents
. This allows consumers to essentially ignore it for the purposes of styling, which is great, because they don't necessarily know it exists!