Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

## Fix rewriteStyleSheets to Ensure Global Constructable Stylesheets Are Processed #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rjlg
Copy link

@rjlg rjlg commented Jan 29, 2025

Fix rewriteStyleSheets to Ensure Global Constructable Stylesheets Are Processed

Issue:

  • document.adoptedStyleSheets was not being checked when shadowRoot was undefined, leading to missing pseudo-state rewrites for global (non-Shadow DOM) styles.
  • This likely caused Constructable Stylesheets in document.adoptedStyleSheets to be ignored, preventing pseudo-state transformations from applying correctly.

Fixes & Enhancements:

  • Ensures document.adoptedStyleSheets is always included when processing styles globally.
  • Consolidates styles from both shadowRoot and document to guarantee all stylesheets are rewritten.
  • Uses a Set to remove duplicates, preventing redundant stylesheet processing.

Key Changes:

  • Now explicitly includes document.adoptedStyleSheets when shadowRoot is undefined.
  • Constructs a unified set of stylesheets from:
    • shadowRoot.styleSheets (if available)
    • shadowRoot.adoptedStyleSheets (if available)
    • document.styleSheets
    • document.adoptedStyleSheets
  • Uses Set([...styles]) to remove duplicates before iterating over stylesheets.

Impact:

  • Fixes missing pseudo-state transformations for global Constructable Stylesheets.
  • Ensures parity between Shadow DOM and global styles in pseudo-state rewriting.
  • Prevents redundant processing of duplicate stylesheets, improving efficiency.

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.

1 participant