-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fix: wrap :id
, :where
:not
and :has
with :global
during migration
#13850
Conversation
🦋 Changeset detectedLatest commit: 60fb2b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
div:has(:is(span)){} | ||
div > :not(:is(span)){} | ||
div > :is(:is(span)){} | ||
div > :where(:is(span)){} |
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 wrapped
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.
Oh I know why...let me fix
Co-authored-by: Simon H <[email protected]>
:id
, :where
:not
and :has
:id
, :where
:not
and :has
with :global
during migration
I don't think this will ever come up in the wild, so I'm good with this approach, assuming we can deal with |
ouch i borked the fix...i need a bit more thinkering to fix this |
I don't think this is doable with regex only...we might need to interveen with some JS. Let me see what i can do |
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.
nice an simple
I'd still like to argue for providing a way to run only this migration (and other future migrations we write that are for upgrading Svelte 4 code to non-runes Svelte 5 code). I'm also worried about idempotency and this sort of change. When we're migrating a component, how do we know whether the user already made the appropriate changes for non-runes mode? Adding |
I'm not as worried about that since it's probably very rare that you'd escape scoping with one of these selectors. But yes, maybe we should do that change only when we detect it's not in runes mode yet? This is definitely tricky 😅 |
Surely the issue is that you write a scoped selector, run the migration (on your entire codebase, which happens to include this component that doesn't need migration), and now you have an unscoped selector? I'd previously suggested skipping the migration altogether for components that are already in runes mode for basically this reason, though it wouldn't help in the case of an ambiguous |
skipping it entirely is a bit too harsh potentially because you might have done runes but not event attributes yet, which are harmless to do. |
Co-authored-by: Simon H <[email protected]>
commit: |
Considering that this migration is literally it's own separate function we could split it in a separate command (and maybe ask in the cli if you want to migrate css too) |
This feels like too much overhead - most people will not know how to answer such questions. People who run the migration on a component (or project) do so with the intention of getting it transformed in a way that mimicks Svelte 4 as closely as possible while upgrading the syntax. It's impossible to know whether or not the intention of something being run on a component already in runes mode is to automatically convert the rest (like @paoloricciuti would probably do on his project after this lands; if he didn't already do it by hand) or leave it alone. I vote for erroring on the side of "wants more" and always do it. |
Yeah there's also to say that you still need to check the files and it's pretty easy to revert this changes with a click if you watch in diff mode in vscode |
Before submitting the PR, please make sure you do the following
Closes #13765...if you can think of more weird case to test please let me know.
EDIT: i've added a slightly better test and realised that we could have a problem if the user has something like this
in the template...should we care?
Also weirdly
replaceAll
fromMagicString
did not got the job done, might be worth opening an issue there.feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint