-
Notifications
You must be signed in to change notification settings - Fork 673
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][css-cascade] :scope in shadowy prelude-less @scope matches nothing #9178
Comments
Looking a bit closer at the specs, the most consistent thing might be to scope to the shadow host instead, though still match in the context of the shadow tree. So the scoping root is:
EDIT: And we'd need to pair that with #9025, otherwise |
Yes, this solution makes sense to me. I would expect this scope to be the shadow host. |
Yes, this seems pretty clearly to just be an oversight; if the stylesheet is a root element of the shadow tree, it should scope to the shadow host. (And
Hm, yeah, that might predate some of the featureless text, or maybe it's just being too general, and meant like "you can't do |
@astearns Proposed async resolution: |
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653}
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653}
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653}
I don't think this would necessarily make it no-op, since Then again, the host is likely the default scope-root for un-scoped styles in shadow dom? So maybe that is still no-op? |
Yeah, scoping-wise it's a no-op, but you'd get proximity applied between the subject and the host. |
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653}
The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment. Proposed Resolution: |
RESOLVED: |
…s no owner-parent element, a=testonly Automatic update from web-platform-tests [@scope] Scope to host element if there's no owner-parent element Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653} -- wpt-commits: 21cc51826719698a688a92e7a48c8775a5329c20 wpt-pr: 41440
…s no owner-parent element, a=testonly Automatic update from web-platform-tests [@scope] Scope to host element if there's no owner-parent element Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653} -- wpt-commits: 21cc51826719698a688a92e7a48c8775a5329c20 wpt-pr: 41440
Would this mean that you can author a stylesheet with |
Implicit scopes, i.e. scopes without a <scope-start> selector, should scope to the parent element of the owner element: <div id=foo> <style> @scope { ... } /* Scoped to #foo */ </style> </div> However, there are two ShadowDOM-related cases where we don't have an owner-parent element: 1. When the <style> element appears directly below a shadow root. 2. When the stylesheet is constructed/adopted. In this case we don't even have an owner element. Currently, we handle this by never activating the scope. This CL fixes this issue by instead scoping implicit @scope rules to the shadow *host* instead of the *root*. This requires a spec change [1], therefore the tests are marked as tentative. Fixed: 1379844 [1] w3c/csswg-drafts#9178 Change-Id: I9146ffb3c6cb5e2f5697dc3d3e62cda9396709b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4778499 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184653}
@jacobrask I don't think this change would have any impact on how If no |
The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808}
The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808}
The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808}
…entative, a=testonly Automatic update from web-platform-tests [@scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194
…entative, a=testonly Automatic update from web-platform-tests [@scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194
…ntative, a=testonly Automatic update from web-platform-tests [scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futharkchromium.org> Auto-Submit: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194 UltraBlame original commit: ff3fb02123f7b931cc3be074606869975947f573
…ntative, a=testonly Automatic update from web-platform-tests [scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futharkchromium.org> Auto-Submit: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194 UltraBlame original commit: ff3fb02123f7b931cc3be074606869975947f573
…ntative, a=testonly Automatic update from web-platform-tests [scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futharkchromium.org> Auto-Submit: Anders Hartvoll Ruud <andruudchromium.org> Commit-Queue: Rune Lillesveen <futharkchromium.org> Cr-Commit-Position: refs/heads/main{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194 UltraBlame original commit: ff3fb02123f7b931cc3be074606869975947f573
…entative, a=testonly Automatic update from web-platform-tests [@scope] Mark scope-shadow.html as non-tentative The relevant issue has been resolved, and the spec has been edited. w3c/csswg-drafts#9178 Change-Id: I218d98496e31d24e07a6a4e40bf0be4e6940c731 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5864290 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Auto-Submit: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1355808} -- wpt-commits: 08f0c2e7e7b808bd8227a2985a11271b905ab5f9 wpt-pr: 48194
A prelude-less
@scope
rule, e.g.@scope { ... }
scopes the styles to the root of the containing tree if the owner element has no parent element. Example:However, the shadow root can't be matched by
:scope
, because it's replaced by the shadow host for selector purposes. CSS Scoping 1:This makes prelude-less
@scope
rules that exist directly beneath a shadow root mostly non-usable, since the inner selectors either have:scope
in them somewhere, or get an implicit:scope
prepended if not.Not sure what the best fix is here ...
@tabatkins
I noticed that https://drafts.csswg.org/css-scoping-1/#shadow-gloss contradicts the other part of the spec:
But since this doesn't match browser implementations, I assume it's a remnant of a previous spec version.
EDIT: Related: #7261 (comment)
The text was updated successfully, but these errors were encountered: