Wait—why does Safari use a `shadowrootmode` attribute when all the other docs on Declarative Shadow DOM use `shadowroot`?
https://webkit.org/blog/13851/declarative-shadow-dom/
(I remember retweeting something about this but I’m having trouble finding it)
8 replies
@zachleat the shadowroot attribute got deprecated in favor of shadowrootmode.
"Summary
The standards-track `shadowrootmode` attribute, which enables declarative Shadow DOM, was shipped in Chrome 111. The older, non-standard `shadowroot` attribute is now deprecated. During the deprecation period, both attributes are functional, however the `shadowroot` attribute does not enable the new streaming behavior, whereas `shadowrootmode` allows streaming of content. There is a straightforward migration path: replace `shadowroot` with `shadowrootmode`."@jerryD a ha, thank you!
@zachleat they changed the behavior to attach the shadow root after the opening tag so that streaming would work. Part of that change also changed the attribute name.
Here’s the context from @jerryD (thank you!)
@zachleat I was equally baffled by this a few days ago and I ended up finding the exact GitHub issue thread where this was discussed: https://github.com/whatwg/html/pull/5465#discussion_r1004046952
I think one of the core issues was that `HTMLTemplateElement.shadowRoot` + the `shadowroot` attribute conflicted with the existence of `Element.shadowRoot`. On template elements it would have been a `string` but everywhere else it could have been a reference to an actual shadow root, which is pretty confusing!