Intent to Prototype and Ship: Don't clear adoptedStyleSheets on adoption to/from <template>

192 views
Skip to first unread message

Rakina Zata Amni

unread,
Oct 18, 2020, 11:35:45 PM10/18/20
to blink-dev

Contact emails

rak...@chromium.org


Explainer

https://github.com/WICG/construct-stylesheets/issues/133 - no explainer as this is a small improvement, and spec change is pending due to the dependency on moving to the DOM & CSSOM specs (but should be simple).


Summary

When adopting a shadow root into a <template> document from a document that the <template> is in (or vice versa), we will no longer clear its adoptedStyleSheets.


Motivation

Currently we always clear adoptedStyleSheets when the shadow root containing it is adopted into a different document. The main reason for this is to ensure constructed stylesheets are not used across <iframe>s, but this also covers adopting into/from <template>s, causing some confusion to web developers (see https://crbug.com/1111864)


We recently assessed that there should be no problem with keeping adoptedStyleSheets on adoption for the <template> case, as the lifetime of a <template> is bounded by the lifetime of the document containing it. For more details, see https://github.com/WICG/construct-stylesheets/issues/133.


Risks

Interoperability and Compatibility

The risk for this change should be low as the behavior change is small (and more intuitive) and Chrome is the only browser that has shipped adoptedStyleSheets (Firefox implementation is pending).


Edge: No signals

Firefox: No signals

Safari: No signals

Web / Framework developers: Positive (see bug)



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes 


Is this feature fully tested by web-platform-tests?

Yes (tests added in https://chromium-review.googlesource.com/c/chromium/src/+/2464519


Link to entry on the feature dashboard

https://chromestatus.com/features/5980793119703040 


Requesting approval to ship?

Yes

Alex Russell

unread,
Oct 22, 2020, 3:20:04 PM10/22/20
to blink-dev, Rakina Zata Amni
Hey Rakina!

It's great to see sharp edges being rounded off for constructable stylesheets. The current usage looks very high, however:


Do we have a way to know if we'll cause breakage with this? Do we know if cross-document template cloning is rare?

Regards

Rakina Zata Amni

unread,
Oct 22, 2020, 8:28:59 PM10/22/20
to Alex Russell, blink-dev, mason...@chromium.org, Kevin Schaaf, Gray Norton
Thanks Alex,
I don't think we have data on cross-document template cloning + adoptedStyleSheets is used, we can try to gather some data if we need to. However, I think that the current behavior (clearing on adoption) is very much a footgun and is unexpected to web developers though (see comment), and I doubt many developers depend on the current behavior (and if they do, they can have a quick fix for this by clearing manually). Additionally, nothing other than adoptedStyleSheets is currently cleared on adoption (see adopt, adopting steps, adoptedStyleSheets adopting steps).

Chris Harrelson

unread,
Oct 28, 2020, 1:57:17 PM10/28/20
to Rakina Zata Amni, Alex Russell, blink-dev, Mason Freed, Kevin Schaaf, Gray Norton
LGTM1

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACPC1r6bgbBHpXNseRmTqSzOEPf0A_ZZW%2BHwS2sXqzbK28A0ng%40mail.gmail.com.

TAMURA, Kent

unread,
Oct 28, 2020, 10:26:30 PM10/28/20
to Rakina Zata Amni, blink-dev, Mason Freed, Kevin Schaaf, Gray Norton
LGTM2




--
TAMURA Kent
Software Engineer, Google


Yoav Weiss

unread,
Oct 29, 2020, 3:58:57 AM10/29/20
to TAMURA, Kent, Rakina Zata Amni, blink-dev, Mason Freed, Kevin Schaaf, Gray Norton
Reply all
Reply to author
Forward
0 new messages