pull/18595/merge
Jason Rasmussen 5 days ago committed by GitHub
commit 4f0d0b3292
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: do not consider `style` literals inside `<script>` blocks

@ -251,7 +251,7 @@ function stringify_tag_attributes(attributes) {
} }
const regex_style_tags = const regex_style_tags =
/<!--[^]*?-->|<style((?:\s+[^=>'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g; /<!--[^]*?-->|<script[^]*?<\/script>|<style((?:\s+[^=>'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
const regex_script_tags = const regex_script_tags =
/<!--[^]*?-->|<script((?:\s+[^=>'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g; /<!--[^]*?-->|<script((?:\s+[^=>'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;

@ -0,0 +1,13 @@
import * as assert from 'node:assert';
import { test } from '../../test';
export default test({
preprocess: {
style: ({ content }) => {
assert.equal(content, 'BEFORE');
return {
code: 'PROCESSED'
};
}
}
});

@ -0,0 +1,5 @@
<script>
const scope = (rules) => `<style>${rules.replaceAll('::highlight(a-', '::highlight(b-')}</style>`;
</script>
<style>BEFORE</style>

@ -0,0 +1,5 @@
<script>
const scope = (rules) => `<style>${rules.replaceAll('::highlight(a-', '::highlight(b-')}</style>`;
</script>
<style>PROCESSED</style>
Loading…
Cancel
Save