Shadow DOM for Replaced Elements
This page explains Shadow DOM for Replaced Elements.
Background
Per HTML specification, some HTML elements are designed to either not render their contents or have special requirements in regard to contents rendering. According to the spec http://www.w3.org/TR/shadow-dom/, all the HTML elements are considered having an equivalent of a shadow DOM subtree that is created and populated at the time of element instantiation.
Implementation
To implement Shadow DOM for these elements, we use either of these options.
- Some HTML elements have a UserAgentShadowRoot at the time of element instantiation
- Other HTML elements does not have a UserAgentShadowRoot at the time of element instantiation, but just before we add AuthorShadowDOM to these elements, we instantiate UserAgentShadowDOM for these elements. (Lazily instantiated UserAgentShadowDOM)
The lazily instantiated UserAgentShadowDOM basically has an inner element, which is almost the same to the host. It will create the same renderer as the host's. The host's renderer will become just a RenderBlock or RenderInlineBlock or something defined in CSS.
Styling
To style the inner element of UserAgentShadowDOM for replaced elements, pseudo id is used. These are the implemented pseudo ids. This will grow as we implement Shadow DOM for other replaced elements.
element name | pseudo id |
img | -webkit-image-inner-element |