fix: handle closing tags inside attribute values (#9486)

Related to https://github.com/sveltejs/language-tools/issues/2204
pull/9491/head
Simon H 1 year ago committed by GitHub
parent 50abbc81da
commit b2e1f1c102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: handle closing tags inside attribute values

@ -252,8 +252,10 @@ function stringify_tag_attributes(attributes) {
return value;
}
const regex_style_tags = /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
const regex_script_tags = /<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
const regex_style_tags =
/<!--[^]*?-->|<style((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s])|\s+[^=>'"\/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
const regex_script_tags =
/<!--[^]*?-->|<script((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s])|\s+[^=>'"\/]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;
/**
* Calculate the updates required to process all instances of the specified tag.

@ -0,0 +1,6 @@
export default {
preprocess: {
script: ({ attributes }) =>
attributes.generics && attributes.generics.includes('>') ? { code: '' } : null
}
};

@ -0,0 +1,3 @@
<script generics="T extends Record<string, string>">
foo {}
</script>

@ -0,0 +1 @@
<script generics="T extends Record<string, string>"></script>
Loading…
Cancel
Save