-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: wrap :id
, :where
:not
and :has
with :global
during migration
#13850
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
Merged
+180
−1
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
091f02c
feat: migrate css `:id`, `:where``:not` and `:has`
paoloricciuti 4774d10
chore: better test
paoloricciuti 276ba98
Update .changeset/sour-feet-carry.md
paoloricciuti 897d429
chore: add more tests
paoloricciuti d18fd1b
chore: update output
paoloricciuti 13f52cd
chore: update regex
paoloricciuti 24fafc3
chore: update input
paoloricciuti ce53bd6
fix: migrate css with JS and not regex
paoloricciuti 68f71c9
chore: simplify
paoloricciuti 60fb2b5
fix: handle already global selectors
paoloricciuti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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: wrap `:id`, `:where``:not` and `:has` with `:global` during migration |
This file contains hidden or 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
58 changes: 58 additions & 0 deletions
58
packages/svelte/tests/migrate/samples/is-not-where-has/input.svelte
This file contains hidden or 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,58 @@ | ||
<script> | ||
function is(){} | ||
function where(){} | ||
function not(){} | ||
function has(){} | ||
|
||
// looks like css but it's not in style tag | ||
const x = { | ||
div:is(42), | ||
span:where(42), | ||
form:not(42), | ||
input:has(42), | ||
} | ||
</script> | ||
|
||
what if i'm talking about `:has()` in my blog? | ||
|
||
```css | ||
:has(.is_cool) | ||
``` | ||
|
||
<style lang="postcss"> | ||
div:has(span){} | ||
div > :not(span){} | ||
div > :is(span){} | ||
div > :where(span){} | ||
|
||
div:has(:is(span)){} | ||
div > :not(:is(span)){} | ||
div > :is(:is(span)){} | ||
div > :where(:is(span)){} | ||
|
||
div:has(.class:is(span)){} | ||
div > :not(.class:is(span)){} | ||
div > :is(.class:is(span)){} | ||
div > :where(.class:is(span)){} | ||
|
||
div :has(.class:is(span:where(:focus))){} | ||
div :not(.class:is(span:where(:focus-within))){} | ||
div :is(.class:is(span:is(:hover))){} | ||
div :where(.class:is(span:has(* > *))){} | ||
div :is(.class:is(span:is(:hover)), .x){} | ||
|
||
paoloricciuti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
div :has( :global(.class:is(span:where(:focus)))){} | ||
div :not(:global(.class:is(span:where(:focus-within)))){} | ||
div :is(:global(.class:is(span:is(:hover)))){} | ||
div :where(:global(.class:is(span:has(* > *)))){} | ||
div :is(:global(.class:is(span:is(:hover)), .x)){} | ||
|
||
div{ | ||
p:has(&){ | ||
|
||
} | ||
:not(span > *){ | ||
:where(form){} | ||
} | ||
} | ||
</style> |
58 changes: 58 additions & 0 deletions
58
packages/svelte/tests/migrate/samples/is-not-where-has/output.svelte
This file contains hidden or 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,58 @@ | ||
<script> | ||
function is(){} | ||
function where(){} | ||
function not(){} | ||
function has(){} | ||
|
||
// looks like css but it's not in style tag | ||
const x = { | ||
div:is(42), | ||
span:where(42), | ||
form:not(42), | ||
input:has(42), | ||
} | ||
</script> | ||
|
||
what if i'm talking about `:has()` in my blog? | ||
|
||
```css | ||
:has(.is_cool) | ||
``` | ||
|
||
<style lang="postcss"> | ||
div:has(:global(span)){} | ||
div > :not(:global(span)){} | ||
div > :is(:global(span)){} | ||
div > :where(:global(span)){} | ||
|
||
div:has(:global(:is(span))){} | ||
div > :not(:global(:is(span))){} | ||
div > :is(:global(:is(span))){} | ||
div > :where(:global(:is(span))){} | ||
|
||
div:has(:global(.class:is(span))){} | ||
div > :not(:global(.class:is(span))){} | ||
div > :is(:global(.class:is(span))){} | ||
div > :where(:global(.class:is(span))){} | ||
|
||
div :has(:global(.class:is(span:where(:focus)))){} | ||
div :not(:global(.class:is(span:where(:focus-within)))){} | ||
div :is(:global(.class:is(span:is(:hover)))){} | ||
div :where(:global(.class:is(span:has(* > *)))){} | ||
div :is(:global(.class:is(span:is(:hover)), .x)){} | ||
|
||
paoloricciuti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
div :has( :global(.class:is(span:where(:focus)))){} | ||
div :not(:global(.class:is(span:where(:focus-within)))){} | ||
div :is(:global(.class:is(span:is(:hover)))){} | ||
div :where(:global(.class:is(span:has(* > *)))){} | ||
div :is(:global(.class:is(span:is(:hover)), .x)){} | ||
|
||
div{ | ||
p:has(:global(&)){ | ||
|
||
} | ||
:not(:global(span > *)){ | ||
:where(:global(form)){} | ||
} | ||
} | ||
</style> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for safety: can we add more tests around nested braces? Like
:has(.x:not(...))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure...if you can think of any other case please let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
div :is(.class:is(span:is(:hover)), .x){}
-> the.x
isn't properly wrappedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I know why...let me fix