Skip to content

Conversation

asamuzaK
Copy link
Contributor

@asamuzaK asamuzaK commented Sep 7, 2025

Built on top of #239
Fixes #242

Spec: https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface

  • Breaking change: the functionality provided by CSSStyleDeclaration is now provided by CSSStyleProperties, i.e. use new CSSStyleProperties() to create an instance.
  • Breaking change: the arguments to new CSSStyleProperties() are different from the arguments to new CSSStyleDeclaration().
    • The first argument can be Window, Element or CSSStyleRule.
    • The second argument is an options object.
      • The on change callback previously received as the first argument should be included in the options object using onChange key.
        Callback is applied only when the context is Element.
        const node = document.createElement("div");
        const callback = cssText => {
          console.log(cssText);
        };
        const style = new CSSStyleProperties(node, {
          onChange: callback
        });
      • If the context is Window, element node should be included in the options object using element key.
        const node = document.createElement("div");
        const style = new CSSStyleProperties(window, {
          element: node
        });
  • Switched main entry point from ./lib/CSSStyleDeclaration.js to ./lib/index.js.
  • Updated dependencies and devDependencies.

@asamuzaK asamuzaK marked this pull request as draft September 7, 2025 00:03
@asamuzaK asamuzaK force-pushed the style branch 10 times, most recently from dad72d8 to 6a86bd4 Compare September 7, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prepare and export CSSStyleProperties
1 participant