Skip to content

Constructable Stylesheets & adoptedStyleSheets #204

@Westbrook

Description

@Westbrook

Description

Constructable Stylesheets and adoptedStyleSheets enable adding styles directly to DOM trees, e.g. document and shadow roots, without creating new DOM elements. Because a single stylesheet object can be adopted by multiple scopes, it also allows sharing of styles that can be centrally modified.

General consensus; shipped in both Chrome and Firefox, not available in Safari

Rationale

  • There is no effective way to share styles across components while allowing them to be centrally modified.
  • Creating <style> elements for each style used in each shadow root has a measurable performance overhead.
  • CSS Module Scripts, another critical feature, depends on constructible stylesheets.

Specification

https://w3c.github.io/csswg-drafts/cssom-1/

Tests

Those including "constructable" in https://github.com/web-platform-tests/wpt/tree/master/css/cssom

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions