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

Add style attribute and importance to cascade sort #1550

Merged
merged 14 commits into from
Jan 16, 2024
Merged

Conversation

Jym77
Copy link
Contributor

@Jym77 Jym77 commented Jan 15, 2024

Resolves #1532

With CSS cascade level 5 (compared to level 4):

  • Importance reverse sorting not just for origin, but also for encapsulation context. Origin was OK to ignore since we have very few important user agent rules and they are unlikely to be temptatively overridden by author rules (and even less relying on the fact that it doesn't work). Encapsulation context, however, is required to solve Handle Shadow DOM related pseudo-classes and -elements #1533.
  • Style attribute now has its own step in the cascade sorting, making it more natural to handle it there.

With this PR, both importance and style attribute are now part of the Cascade. This streamline Style building since all declarations are provided, and in decreasing cascade order. So, only parsing of the value is really required. Cascade becomes a bit more complex and, notably, elements with style attribute creates new branches in the rules tree, thus decreasing the possibility of sharing. Given that style attribute declarations have higher precedence than style sheet declarations, they should be close to the leaves and this shouldn't be a big issue.

Style.from() still handles the style attribute for elements that are not part of a Document (hence have no access to style sheet and no associated cascade). This should be mostly a use case for our own tests.

@Jym77 Jym77 self-assigned this Jan 15, 2024
@Jym77 Jym77 added the major Backwards-incompatible change that touches public API label Jan 15, 2024
@Jym77
Copy link
Contributor Author

Jym77 commented Jan 15, 2024

!pr extract

@Jym77 Jym77 marked this pull request as ready for review January 15, 2024 11:00
@Jym77 Jym77 requested a review from a team as a code owner January 15, 2024 11:00
@Jym77 Jym77 added minor Backwards-compatible change that touches public API and removed major Backwards-incompatible change that touches public API labels Jan 15, 2024
@Jym77 Jym77 added this pull request to the merge queue Jan 16, 2024
Merged via the queue into main with commit f361ec1 Jan 16, 2024
6 checks passed
@Jym77 Jym77 deleted the shadow-selectors branch January 16, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Backwards-compatible change that touches public API
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

!important User-Agent rules should not be overwritten by !important author rules.
2 participants