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 from the web developer's side (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.

Status in Chromium

Blink>CSS


Enabled by default in:

  • Chrome for desktop release 88
  • Chrome for Android release 88
  • Android WebView release 88

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

  • No signal
  • No signal
  • No signal
  • Positive

Owner

Last updated on 2021-01-20