feat: migrate css `:id`, `:where``:not` and `:has`

pull/13850/head
paoloricciuti 2 years ago
parent 86ef18165f
commit 091f02c9cc

@ -0,0 +1,5 @@
---
'svelte': minor
---
feat: migrate css `:id`, `:where``:not` and `:has`

@ -317,7 +317,15 @@ export function migrate(source, { filename } = {}) {
if (!parsed.instance && need_script) {
str.appendRight(insertion_point, '\n</script>\n\n');
}
return { code: str.toString() };
return {
code: str
.toString()
// for some reason replacing the magic string doesn't work
.replaceAll(
/(?<=<style[^>]*>[\s\S]*?:(?:is|not|where|has)\()([^)]+)(?=[\s\S]*?<\/style>)/gm,
':global($1)'
)
};
} catch (e) {
if (!(e instanceof MigrationError)) {
// eslint-disable-next-line no-console

@ -0,0 +1,20 @@
<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{
p:has(&){
}
:not(span > *){
:where(form){}
}
}
</style>

@ -0,0 +1,20 @@
<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{
p:has(:global(&)){
}
:not(:global(span > *)){
:where(:global(form)){}
}
}
</style>
Loading…
Cancel
Save