-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: correctly visit elements that may match :has() during pruning #15207
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b41004a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@@ -234,7 +236,7 @@ function apply_combinator(relative_selector, parent_selectors, rule, node) { | |||
|
|||
case '+': | |||
case '~': { | |||
const siblings = get_possible_element_siblings(node, name === '+'); | |||
const siblings = get_possible_element_preceding_siblings(node, name === '+'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to clarify that it retreats previous siblings.
|
||
walk_children(element.fragment, { is_child: true }); | ||
sibling_elements ??= get_following_sibling_elements(element, include_self); | ||
if (selectors.some((s) => s.combinator?.name === ' ' || s.combinator?.name === '>')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't cover s.combinator === null
case - I suppose only the first selector can have no combinator.
So, now |
Fixes #14072
:has()
was matching only against descendants or siblings, but not sibling's descendants.Also, in a case like
:has(> .foo > .bar)
it was matching against children instead of descendants, so I had to drop the>
optimization. But, to ensure that in case like:has(> .foo)
it matches only the direct children, the inner selector is prepended with a selector of new type that matches only certain element.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint