Skip to content

Conversation

asamuzaK
Copy link
Contributor

@asamuzaK asamuzaK commented Sep 8, 2025

Fixes #242
Rebased #243

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 8, 2025 14:04
@asamuzaK asamuzaK force-pushed the style2 branch 3 times, most recently from 26a9f20 to 3ae525e Compare September 9, 2025 21:10
@asamuzaK asamuzaK force-pushed the style2 branch 2 times, most recently from 67f75a4 to ba2962e Compare September 11, 2025 22:36
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
2 participants