You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should <template for> patch when shadowrootmode doesn't attach a shadow root? #13075
The template start tag steps in "in head" give a valid shadowrootmode precedence over for, even when no shadow root gets attached:
If template's shadowrootmode attribute is not in the None state:
If any of the following are true:
the parser's allow declarative shadow roots is false;
hostIsRoot is true; or
the parser's insertion target redirection map[declarativeShadowHostElement] exists,
then insert an element at the adjusted insertion location with template, insertionLocation, and true, and return.
...
Otherwise, if template has a for attribute: ...
Attaching the shadow root can also fail, in which case the steps likewise insert template and return. So per spec, for is ignored whenever shadowrootmode is valid.
Chrome Canary 157 patches instead whenever no shadow root is attached:
The same happens with a top-level template in setHTMLUnsafe(), and with Document.parseHTMLUnsafe() when the host already has a shadow root. Chrome only skips patching when the shadow root is attached. Gecko's in-progress implementation (bug 2053472) does the same as Chrome. template-for-superseded-by-shadowrootmode.html only covers the case where the shadow root is attached.
Maybe the spec should match: fall through to the for steps when no shadow root is attached, instead of returning.
Aligning with the implementations seem OK here. Though this is kind of a judgment call since a combination of for and shadowrootmode is an error condition in any case.
Activity
noamr commentedon Oct 14, 2026
Aligning with the implementations seem OK here. Though this is kind of a judgment call since a combination of
forandshadowrootmodeis an error condition in any case.noamr commentedon Oct 14, 2026
WPT added as part of web-platform-tests/wpt#63320