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

[css-scoping] [selectors] :scope and DocumentFragment / ShadowRoot #7261

Closed
emilio opened this issue May 8, 2022 · 19 comments
Closed

[css-scoping] [selectors] :scope and DocumentFragment / ShadowRoot #7261

emilio opened this issue May 8, 2022 · 19 comments
Labels
css-scoping-1 Current Work selectors-4 Current Work

Comments

@emilio
Copy link
Collaborator

emilio commented May 8, 2022

Relevant spec sections are:

If I read the specs correctly:

  1. Element.querySelectorAll(":scope > *") returns all the direct descendants of the given element. This is interoperable behavior and not ambiguous.
  2. Document.querySelectorAll(":scope > *") ought to work and return only the root element (the scoping root would be the Document node, and it has only one child, which is the document element). Browsers are interoperable here but not following this reasoning. Instead, :scope is the root element (so such a query returns the <head> and <body> elements, usually).
  3. DocumentFragment.querySelectorAll(":scope > *") ought to work and return the children of the fragment, because the scoping root is the fragment, and is a virtual scoping root. This works in Blink, but not in Gecko and WebKit (:scope is undefined, so it falls back to the root element of the document, so it never matches anything).
  4. In style sheets, :scope is always the root element of the document, because there's no defined scoping node, and that's the fallback. That's Gecko and WebKit's behavior. Blink in shadow trees considers the shadow root a :scope (https://crbug.com/1272434), but :scope doesn't match the shadow host directly like :host does.

This is all very unfortunate and inconsistent. It's clear that the spec is wrong for the Document.querySelector case, IMO (though the spec doesn't define Document as a potential "virtual" scoping root, it follows that if such should work for DocumentFragment it ought to work for Document as well?).

We should probably agree on the non-interoperable cases. If we wanted to make :scope behave consistently for Document and DocumentFragment, we ought to probably either:

  • Make all direct children of the fragment match :scope (rather than what the spec currently says / what Blink does), or.
  • Leave the scope node undefined (which is what WebKit / Gecko does), so it always matches the root element as a fallback.

For the stylesheets case, I think WebKit and Gecko follow the spec and the spec is somewhat reasonable. We have :host for shadow trees, and even tho defining :scope is possible, it might be a bit tricky, depending on how we define the above.

Thoughts?

cc @tabatkins @lilles @anttijk

@emilio emilio added selectors-4 Current Work css-scoping-1 Current Work Agenda+ labels May 8, 2022
@lifaon74
Copy link

lifaon74 commented May 9, 2022

In my opinion, the :scope should match the node itself, even if it is virtual. So calling :scope > * on a DocumentFragment should returns its direct children, just as it would have happen on a HTMLElement. It solves the problem: I have a container, I want to select some of its direct children, how can I do it ? ex :scope > scope[name="abc"].

Usually, the :scope usage is coupled with custom elements.

@emilio
Copy link
Collaborator Author

emilio commented May 9, 2022

In my opinion, the :scope should match the node itself, even if it is virtual. So calling :scope > * on a DocumentFragment should returns its direct children, just as it would have happen on a HTMLElement.

Then doing so in Document should select the root element for the same reasoning right? That's not how browsers behave right now.

Usually, the :scope usage is coupled with custom elements.

:host works like you want for custom elements across all browsers afaict.

@lilles
Copy link
Member

lilles commented May 9, 2022

Reading the Selectors4 spec, it looks to me that :scope always matches a true element, even if the scoping root can be a Document or a DocumentFragment/ShadowRoot? Am I reading it correctly?

https://drafts.csswg.org/selectors-4/#the-scope-pseudo says afaict that :scope must match an element?

If so, point 2. Document.querySelectorAll(":scope > *") should return body/head because the scoping root is not an Element, hence falling back to the document root element?

@emilio
Copy link
Collaborator Author

emilio commented May 9, 2022

Hmm, I guess you're right. In which case Gecko and WebKit are just right?

@lilles
Copy link
Member

lilles commented May 9, 2022

Hmm, I guess you're right. In which case Gecko and WebKit are just right?

That's what it looks like to me.

@astearns
Copy link
Member

astearns commented May 9, 2022

@emilio can you give an update on what we should resolve on for this?

@emilio emilio removed the Agenda+ label May 10, 2022
@emilio
Copy link
Collaborator Author

emilio commented May 10, 2022

It seems we all agree on the spec meaning, so I guess what's left here is landing some tests.

@lilles
Copy link
Member

lilles commented May 10, 2022

@emilio
Copy link
Collaborator Author

emilio commented May 10, 2022

Those come from web-platform-tests/wpt#12252. @lilles I saw some movement in the Chromium bug, are you fixing these or do you want me to send a PR?

@lilles
Copy link
Member

lilles commented May 10, 2022

I have not changed them yet, so feel free to send a PR.

@lilles
Copy link
Member

lilles commented May 10, 2022

I won't have time to change them today, at least.

emilio added a commit to emilio/web-platform-tests that referenced this issue May 11, 2022
@emilio
Copy link
Collaborator Author

emilio commented May 11, 2022

emilio added a commit to web-platform-tests/wpt that referenced this issue May 12, 2022
@emilio emilio closed this as completed May 12, 2022
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 18, 2022
Automatic update from web-platform-tests
Clean-up and fix :scope test.

As per discussion in w3c/csswg-drafts#7261

--

wpt-commits: 3bd0214afc4f254b13c65117074806bfeee0189f
wpt-pr: 34032
jamienicol pushed a commit to jamienicol/gecko that referenced this issue May 25, 2022
Automatic update from web-platform-tests
Clean-up and fix :scope test.

As per discussion in w3c/csswg-drafts#7261

--

wpt-commits: 3bd0214afc4f254b13c65117074806bfeee0189f
wpt-pr: 34032
@andruud
Copy link
Member

andruud commented Feb 16, 2023

@tabatkins seemingly made a ninja edit of the spec which is in conflict with the conclusion here. Reopening since, we probably need to change the spec or implementations.

@andruud andruud reopened this Feb 16, 2023
@tabatkins
Copy link
Member

Not a ninja edit! I was applying the resolutions from #6399, as the commit message says!

Further, I don't think my edits had any impact on this thread. Can you elaborate on what you think I changed that's relevant here?

@tabatkins
Copy link
Member

tabatkins commented Feb 16, 2023

Rune's reading:

Reading the Selectors4 spec, it looks to me that :scope always matches a true element, even if the scoping root can be a Document or a DocumentFragment/ShadowRoot? Am I reading it correctly?

Was just wrong. :scope can match a virtual scoping root, like a DocumentFragment; my #6399 edits reworded the relevant text but maintained this fact. A virtual scoping root can't be the subject of a selector, but that just means that docfrag.querySelector(":scope") won't return anything; it can still match the non-element DocumentFragment node so long as it then moves the subject to an actual element (or pseudo-element).

The relevant question for Document.querySelector() and DocumentFragment.querySelector() is just whether they pass a "scoping root" to the "match a selector" algorithm. Per DOM, it appears they do in both cases (since Document, DocumentFragment, and Element all share the same algorithm via the ParentNode mixin).

So following the specs as they are written today, document.querySelector(":scope > *") should return the html element, just as myshadowroot.querySelector(":scope > *") returns all the root nodes in the shadow tree.

(If we wanted document.querySelector(":scope") to return the html element instead, so it matched how the selector would work in a stylesheet, I think that would be fine, maybe even preferable. It just requires a small fix to DOM, not to Selectors, to selectively not pass a scoping root when called on a Document.)

@andruud
Copy link
Member

andruud commented Feb 16, 2023

OK, I may have been too quick to declare a ninja edit. [But hey, I got your attention :-)]. I did see the #6399 reference, but I couldn't immediately understand why some fix related to :has() would also (seemingly) change whether or not :scope in general could match non-elements (subject or not).

Rune's reading [...] was just wrong.

OK, but to be fair, Emilio and me (I remember looking at the spec at the time as well) also read the old spec as ":scope matches ELEMENTS ONLY". But whatever, let's move on:

So following the specs as they are written today, document.querySelector(":scope > *") should return the html element, just as myshadowroot.querySelector(":scope > *") returns all the root nodes in the shadow tree.

Yeah, that behavior makes sense. It's not what browsers implement though.

But this is good, it resolves another question I had about @scope {} (without a prelude) from a constructed stylesheet in a shadow tree. If :scope could only match real elements, then @scope { :scope > div {} } could never match anything, but with the "virtual scoping root" it could be allowed to match the shadow root.

Closing the issue again, hopefully we can change implementations rather than changing the spec.

@andruud andruud closed this as completed Feb 16, 2023
@tabatkins
Copy link
Member

Closing the issue again, hopefully we can change implementations rather than changing the spec.

I wrote it in an edit, but note that I think the current browser behavior (where :scope returns the html element, :scope > * returns body and head) is reasonable for document. I'd honestly prefer to fix the DOM spec there; it's a trivial edit.

But for document fragments (like shadow roots) :scope does indeed need to match the docfrag itself.

@lifaon74
Copy link

In my opinion, document.querySelector(":scope > *") should return the document.html element and document.querySelector(":scope") the document itself.
And docFrag.querySelector(":scope > *") its child elements and docFrag.querySelector(":scope") the document fragment. This would allow a better consistency and natural interpretation. However, it could be a little confuse if we expect only Element or null as a return. In this case, we may consider querySelector(":scope") always returning null if the parent is not an Element.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 21, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 21, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 22, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 22, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
aarongable pushed a commit to chromium/chromium that referenced this issue Feb 22, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 22, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 22, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Mar 7, 2023
Automatic update from web-platform-tests
[@scope] Support @scope (:host)

In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}

--

wpt-commits: 37ffe7edc5b6400a16ba6511ba2fd392ab8be318
wpt-pr: 38610
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Mar 28, 2023
In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}
aosmond pushed a commit to aosmond/gecko that referenced this issue May 18, 2023
Automatic update from web-platform-tests
[@scope] Support @scope (:host)

In CalculateActivations, we'd previously just call
Element.parentElement up the ancestor chain, therefore never
reach the host. Additionally, we did not propagate the original
SelectorCheckerContext.scope which is needed for :host to match.

This CL uses ParentOrShadowHostElement, and adds the concept of
"activation ceiling" to deal with the fact that we need to look at
one element *above* the current activation root when that root is a
ShadowRoot.

Note that :scope is supposed to be able to match "virtual" roots [1]
(like a ShadowRoot), but Blink does not support this in general.
This CL does not address this issue.

[1] w3c/csswg-drafts#7261

Bug: 1280240
Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1108363}

--

wpt-commits: 37ffe7edc5b6400a16ba6511ba2fd392ab8be318
wpt-pr: 38610
@andruud
Copy link
Member

andruud commented Aug 14, 2023

So following the specs as they are written today, document.querySelector(":scope > *") should return the html element, just as myshadowroot.querySelector(":scope > *") returns all the root nodes in the shadow tree.

Yeah, that behavior makes sense. It's not what browsers implement though.

Actually, no, that does not make sense for shadow roots, because the shadow root itself does not exist for the purposes of selector matching (when matching in the context of that shadow tree):

Scoping:

When a selector is matched against a shadow tree, the selector match list is initially the shadow host, followed by all children of the shadow tree’s shadow root and their descendants, ordered by a pre-order traversal.

Also, to reinforce that:

For the purpose of Selectors, a shadow host also appears in its shadow tree, with the contents of the shadow tree treated as its children. (In other words, the shadow host is treated as replacing the shadow root node.)

This is aligned with the current behavior of all browsers as well. To visualize:

If this matches:

:host > div { ... }

then this can't also match:

:scope > div { ... }

At least not as long as :scope points to the shadow root.

dgp1130 added a commit to dgp1130/HydroActive that referenced this issue Aug 10, 2024
`el.shadowRoot.querySelector` uses a `ShadowRoot` as the root of the query, not an `Element` so we should support that. The behavior of `:scope` seems to be a little weird, but Chrome also returns `null` when used in a shadow root. This [csswg issue](w3c/csswg-drafts#7261) has some ambiguity, but it seems that because browsers don't see shadow roots as elements, `querySelector` can't return the `ShadowRoot`. I think the best behavior we can do is just type `null`.
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
aarongable pushed a commit to chromium/chromium that referenced this issue Nov 13, 2024
This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Nov 13, 2024
This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 16, 2024
…atchForRelation, a=testonly

Automatic update from web-platform-tests
Remove special :scope matching code in MatchForRelation

This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}

--

wpt-commits: 7b7e2451a431d0cc68e4e5a96d19a71675dd782d
wpt-pr: 49150
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 18, 2024
…atchForRelation, a=testonly

Automatic update from web-platform-tests
Remove special :scope matching code in MatchForRelation

This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}

--

wpt-commits: 7b7e2451a431d0cc68e4e5a96d19a71675dd782d
wpt-pr: 49150
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Nov 20, 2024
…atchForRelation, a=testonly

Automatic update from web-platform-tests
Remove special :scope matching code in MatchForRelation

This special path causes :scope selectors to incorrectly match
':scope *' selectors in shadow roots, when it actually should
match nothing [1].

The provided test scope-pseudo-in-shadow.html is passing in Firefox
and Safari. The existing WPT scope-selector.html (all browsers currently
passing) cover querySelector[All] cases well for shadow roots, document,
and other DocumentFragments. There should be no behavior change there.

Fixed: 378698644

[1] w3c/csswg-drafts#11188
[2] w3c/csswg-drafts#7261

Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382339}

--

wpt-commits: 7b7e2451a431d0cc68e4e5a96d19a71675dd782d
wpt-pr: 49150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-scoping-1 Current Work selectors-4 Current Work
Projects
None yet
Development

No branches or pull requests

6 participants