Skip to content

Commit dbe6057

Browse files
authored
chore: speed up regex (#11922)
Svelte 4 version of #11918
1 parent 32ebc46 commit dbe6057

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/cyan-bears-refuse.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: speed up regex

packages/svelte/src/compiler/preprocess/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ function stringify_tag_attributes(attributes) {
253253
}
254254

255255
const regex_style_tags =
256-
/<!--[^]*?-->|<style((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
256+
/<!--[^]*?-->|<style((?:\s+[^=>'"\/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
257257
const regex_script_tags =
258-
/<!--[^]*?-->|<script((?:\s+[^=>'"\/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;
258+
/<!--[^]*?-->|<script((?:\s+[^=>'"\/\s]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"\/\s]+)*\s*)(?:\/>|>([\S\s]*?)<\/script>)/g;
259259

260260
/**
261261
* Calculate the updates required to process all instances of the specified tag.

0 commit comments

Comments
 (0)