-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure non-matching elements are scoped for
:not(...)
selector
If the contents of a `:not` selector don't match, then it's actually a match for `:not` because it's inverted. Therefore, we need to scope such elements. Fixes #13974
- Loading branch information
1 parent
e99e865
commit f704196
Showing
10 changed files
with
90 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure non-matching elements are scoped for `:not(...)` selector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/css/samples/not-selector-global/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector ":global(.x) :not(.unused)"', | ||
start: { | ||
line: 17, | ||
column: 1, | ||
character: 289 | ||
}, | ||
end: { | ||
line: 17, | ||
column: 26, | ||
character: 314 | ||
} | ||
} | ||
] | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/css/samples/not-selector-global/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
.svelte-xyz:not(.foo) { | ||
color: green; | ||
} | ||
.svelte-xyz:not(.foo:where(.svelte-xyz)):not(.unused) { | ||
color: green; | ||
} | ||
.x:not(.foo.svelte-xyz) { | ||
color: green; | ||
} | ||
.x:not(.unused.svelte-xyz) { | ||
color: red; /* TODO would be nice to prune this one day */ | ||
} | ||
/* (unused) :global(.x) :not(.unused) { | ||
color: red; | ||
}*/ |
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/css/samples/not-selector-global/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p class="foo svelte-xyz">foo</p> <p class="bar svelte-xyz">bar</p> |
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/css/samples/not-selector-global/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p class="foo">foo</p> | ||
<p class="bar">bar</p> | ||
|
||
<style> | ||
:not(:global(.foo)) { | ||
color: green; | ||
} | ||
:not(.foo):not(:global(.unused)) { | ||
color: green; | ||
} | ||
:global(.x):not(.foo) { | ||
color: green; | ||
} | ||
:global(.x):not(.unused) { | ||
color: red; /* TODO would be nice to prune this one day */ | ||
} | ||
:global(.x) :not(.unused) { | ||
color: red; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p class="foo svelte-xyz">foo</p> <p class="bar svelte-xyz">bar</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters