Don't panic when matching pseudo-element selectors against unstyled elements - #652
Open
nicoburns wants to merge 1 commit into
Open
Don't panic when matching pseudo-element selectors against unstyled elements#652nicoburns wants to merge 1 commit into
nicoburns wants to merge 1 commit into
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes CRASHes in
css/css-nesting/nesting-basic.htmlandcss/css-nesting/contextually-invalid-selectors-003.html(2 → 0 crashes; both now PASS).Nested rules under a pseudo-element rule (e.g.
.test::before { & { ... } }) cause stylo to match a::beforeselector component against regular elements during the initial style traversal. Blitz'sTElement::match_pseudo_elementcalledel.styles.primary()(whichunwrap()s) on the candidate element, but during initial traversal an element'sElementDataexists before its primary style has been computed, so this panicked withcalled Option::unwrap() on a None valueat stylodata.rs:187.Fix in
match_pseudo_element:Treating "no primary style yet" as "no pseudo-element identity" is correct: only Blitz's synthesized pseudo-element/anonymous-box nodes carry a pseudo, and those always have styles by the time they are matched (the
AnonymousBlockfallback is unaffected).Not a stylo bug: the
unwrapis in stylo convenience API; the root cause was Blitz assuming primary styles always exist during selector matching.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/a8bd4846bf354f33a6037fffaca1f583
Requested by: @nicoburns
WPT results
2 newly passing, 0 newly failing (net +2).
Full diff (2 changed tests)
Generated by the WPT workflow.