Skip to content

Commit

Permalink
chore: speed up regex (#11922)
Browse files Browse the repository at this point in the history
Svelte 4 version of #11918
  • Loading branch information
dummdidumm committed Jun 6, 2024
1 parent 32ebc46 commit dbe6057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-bears-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: speed up regex
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/preprocess/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ function stringify_tag_attributes(attributes) {
}

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

/**
* Calculate the updates required to process all instances of the specified tag.
Expand Down

0 comments on commit dbe6057

Please sign in to comment.