Files
blockly/packages
Matt Hillsdon 6a6871ea54 fix: CSS back to <style> for Safari/cascade reasons (#9908)
Reverts the storage mechanism introduced in #9611 (constructable
stylesheets via `adoptedStyleSheets`) while keeping the per-root
injection-site tracking that #9611 added for shadow-DOM support.

Motivations:

- Safari 15.4 compatibility. `new CSSStyleSheet()` and
  `adoptedStyleSheets` require Safari 16.4+
- Cascade order. `adoptedStyleSheets` apply after `<style>`/`<link>`
  elements in the document, so Blockly's defaults silently overrode
  host stylesheets. Prepending a `<style>` to the head (or to the
  shadow root) restores the pre-#9611 behavior where any author
  stylesheet declared later wins on specificity ties.

Trade-offs:

- Per-shadow-root CSS text is duplicated rather than shared via a
  single adopted sheet object. Negligible for typical use.
- `Css.register()` calls made after the first `inject()` no longer
  reach already-injected roots (same as #9611's behavior); subsequent
  `inject()` calls into other roots still pick them up. Web-component
  consumers can legitimately register late, so this is preferred to
  reinstating the pre-#9611 throw.

Fixes #9876
2026-05-20 14:54:09 -04:00
..
2026-05-18 13:18:12 -07:00