Skip to content

Commit 3d961f5

Browse files
committed
fix some stuff
1 parent bef6c15 commit 3d961f5

File tree

7 files changed

+38
-40
lines changed

7 files changed

+38
-40
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,14 @@ function get_possible_element_siblings(node, adjacent_only) {
898898

899899
if (!current) break;
900900

901+
if (
902+
current.type === 'Component' ||
903+
current.type === 'SvelteComponent' ||
904+
current.type === 'SvelteSelf'
905+
) {
906+
continue;
907+
}
908+
901909
if (current.type === 'SnippetBlock') {
902910
for (const site of current.metadata.sites) {
903911
const siblings = get_possible_element_siblings(site, adjacent_only);

packages/svelte/tests/css/samples/general-siblings-combinator-slot/_config.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import { test } from '../../test';
22

33
export default test({
44
warnings: [
5-
{
6-
code: 'css_unused_selector',
7-
message: 'Unused CSS selector ".a ~ .b"',
8-
start: { character: 110, column: 1, line: 10 },
9-
end: { character: 117, column: 8, line: 10 }
10-
},
115
{
126
code: 'css_unused_selector',
137
message: 'Unused CSS selector ".b ~ .c"',
@@ -17,26 +11,26 @@ export default test({
1711
{
1812
code: 'css_unused_selector',
1913
message: 'Unused CSS selector ".c ~ .f"',
20-
start: { character: 164, column: 1, line: 12 },
21-
end: { character: 171, column: 8, line: 12 }
14+
start: { character: 162, column: 1, line: 12 },
15+
end: { character: 169, column: 8, line: 12 }
2216
},
2317
{
2418
code: 'css_unused_selector',
2519
message: 'Unused CSS selector ".f ~ .g"',
26-
start: { character: 191, column: 1, line: 13 },
27-
end: { character: 198, column: 8, line: 13 }
20+
start: { character: 187, column: 1, line: 13 },
21+
end: { character: 194, column: 8, line: 13 }
2822
},
2923
{
3024
code: 'css_unused_selector',
3125
message: 'Unused CSS selector ".b ~ .f"',
32-
start: { character: 218, column: 1, line: 14 },
33-
end: { character: 225, column: 8, line: 14 }
26+
start: { character: 212, column: 1, line: 14 },
27+
end: { character: 219, column: 8, line: 14 }
3428
},
3529
{
3630
code: 'css_unused_selector',
3731
message: 'Unused CSS selector ".b ~ .g"',
38-
start: { character: 245, column: 1, line: 15 },
39-
end: { character: 252, column: 8, line: 15 }
32+
start: { character: 237, column: 1, line: 15 },
33+
end: { character: 244, column: 8, line: 15 }
4034
}
4135
]
4236
});
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
12
.d.svelte-xyz ~ .e:where(.svelte-xyz) { color: green; }
23
.a.svelte-xyz ~ .g:where(.svelte-xyz) { color: green; }
4+
.a.svelte-xyz ~ .b:where(.svelte-xyz) { color: green; }
35

46
/* no match */
5-
/* (unused) .a ~ .b { color: green; }*/
6-
/* (unused) .b ~ .c { color: green; }*/
7-
/* (unused) .c ~ .f { color: green; }*/
8-
/* (unused) .f ~ .g { color: green; }*/
9-
/* (unused) .b ~ .f { color: green; }*/
10-
/* (unused) .b ~ .g { color: green; }*/
7+
/* (unused) .b ~ .c { color: red; }*/
8+
/* (unused) .c ~ .f { color: red; }*/
9+
/* (unused) .f ~ .g { color: red; }*/
10+
/* (unused) .b ~ .f { color: red; }*/
11+
/* (unused) .b ~ .g { color: red; }*/

packages/svelte/tests/css/samples/general-siblings-combinator-slot/input.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<style>
66
.d ~ .e { color: green; }
77
.a ~ .g { color: green; }
8+
.a ~ .b { color: green; }
89
910
/* no match */
10-
.a ~ .b { color: green; }
11-
.b ~ .c { color: green; }
12-
.c ~ .f { color: green; }
13-
.f ~ .g { color: green; }
14-
.b ~ .f { color: green; }
15-
.b ~ .g { color: green; }
11+
.b ~ .c { color: red; }
12+
.c ~ .f { color: red; }
13+
.f ~ .g { color: red; }
14+
.b ~ .f { color: red; }
15+
.b ~ .g { color: red; }
1616
</style>
1717

1818
<div class="a"></div>

packages/svelte/tests/css/samples/siblings-combinator-slot/_config.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import { test } from '../../test';
22

33
export default test({
44
warnings: [
5-
{
6-
code: 'css_unused_selector',
7-
message: 'Unused CSS selector ".a + .b"',
8-
start: { character: 83, column: 1, line: 9 },
9-
end: { character: 90, column: 8, line: 9 }
10-
},
115
{
126
code: 'css_unused_selector',
137
message: 'Unused CSS selector ".b + .c"',
@@ -17,8 +11,8 @@ export default test({
1711
{
1812
code: 'css_unused_selector',
1913
message: 'Unused CSS selector ".c + .f"',
20-
start: { character: 137, column: 1, line: 11 },
21-
end: { character: 144, column: 8, line: 11 }
14+
start: { character: 135, column: 1, line: 11 },
15+
end: { character: 142, column: 8, line: 11 }
2216
}
2317
]
2418
});
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
.d.svelte-xyz + .e:where(.svelte-xyz) { color: green; }
3+
.a.svelte-xyz + .b:where(.svelte-xyz) { color: green; }
24

35
/* no match */
4-
/* (unused) .a + .b { color: green; }*/
5-
/* (unused) .b + .c { color: green; }*/
6-
/* (unused) .c + .f { color: green; }*/
6+
/* (unused) .b + .c { color: red; }*/
7+
/* (unused) .c + .f { color: red; }*/

packages/svelte/tests/css/samples/siblings-combinator-slot/input.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
<style>
66
.d + .e { color: green; }
7+
.a + .b { color: green; }
78
89
/* no match */
9-
.a + .b { color: green; }
10-
.b + .c { color: green; }
11-
.c + .f { color: green; }
10+
.b + .c { color: red; }
11+
.c + .f { color: red; }
1212
</style>
1313

1414
<div class="a"></div>

0 commit comments

Comments
 (0)