Skip to content

Commit f227cfc

Browse files
ccjmnedummdidumm
andauthored
fix: Allow global-like pseudo-selectors refinement (#15313)
For instance, specifying a tree-structural pseudo-class to `::view-transition-new` should still constitute a valid global-like selector. Fixes #15312 --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
1 parent e74fbcb commit f227cfc

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

.changeset/gold-hairs-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow global-like pseudo-selectors refinement

packages/svelte/src/compiler/phases/2-analyze/css/css-analyze.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ const css_visitors = {
133133

134134
node.metadata.is_global = node.selectors.length >= 1 && is_global(node);
135135

136-
if (node.selectors.length === 1) {
136+
if (
137+
node.selectors.length >= 1 &&
138+
node.selectors.every(
139+
(selector) =>
140+
selector.type === 'PseudoClassSelector' || selector.type === 'PseudoElementSelector'
141+
)
142+
) {
137143
const first = node.selectors[0];
138144
node.metadata.is_global_like ||=
139145
(first.type === 'PseudoClassSelector' && first.name === 'host') ||

packages/svelte/tests/css/samples/view-transition/expected.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
::view-transition-old {
99
animation-duration: 0.5s;
1010
}
11+
::view-transition-old:only-child {
12+
animation-duration: 0.5s;
13+
}
1114
::view-transition-new {
1215
animation-duration: 0.5s;
1316
}
17+
::view-transition-new:only-child {
18+
animation-duration: 0.5s;
19+
}
1420
::view-transition-image-pair {
1521
animation-duration: 0.5s;
1622
}

packages/svelte/tests/css/samples/view-transition/input.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
::view-transition-old {
99
animation-duration: 0.5s;
1010
}
11+
::view-transition-old:only-child {
12+
animation-duration: 0.5s;
13+
}
1114
::view-transition-new {
1215
animation-duration: 0.5s;
1316
}
17+
::view-transition-new:only-child {
18+
animation-duration: 0.5s;
19+
}
1420
::view-transition-image-pair {
1521
animation-duration: 0.5s;
1622
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy