diff --git a/.changeset/strip-style-comments.md b/.changeset/strip-style-comments.md new file mode 100644 index 0000000000..6a27e431df --- /dev/null +++ b/.changeset/strip-style-comments.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: strip comments from inline `style` values in linear time diff --git a/packages/svelte/src/internal/shared/attributes.js b/packages/svelte/src/internal/shared/attributes.js index 487a40baf3..0a387dadc4 100644 --- a/packages/svelte/src/internal/shared/attributes.js +++ b/packages/svelte/src/internal/shared/attributes.js @@ -142,8 +142,9 @@ export function to_style(value, styles) { } if (value) { + // strip comments; surrounding whitespace is handled by the trims below value = String(value) - .replaceAll(/\s*\/\*.*?\*\/\s*/g, '') + .replaceAll(/\/\*.*?\*\//g, '') .trim(); /** @type {boolean | '"' | "'"} */