diff --git a/.changeset/itchy-peaches-compare.md b/.changeset/itchy-peaches-compare.md new file mode 100644 index 0000000000..9f7ae884af --- /dev/null +++ b/.changeset/itchy-peaches-compare.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +chore: speed up regex diff --git a/packages/svelte/src/compiler/preprocess/index.js b/packages/svelte/src/compiler/preprocess/index.js index 9b101249a5..11cf9fdf7a 100644 --- a/packages/svelte/src/compiler/preprocess/index.js +++ b/packages/svelte/src/compiler/preprocess/index.js @@ -248,9 +248,9 @@ function stringify_tag_attributes(attributes) { } const regex_style_tags = - /|'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g; + /|'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g; const regex_script_tags = - /|'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g; + /|'"/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g; /** * Calculate the updates required to process all instances of the specified tag.