From fc0f891aa41065755fea6312d3781f32e3ab42b8 Mon Sep 17 00:00:00 2001 From: dnukumamras Date: Thu, 16 Jul 2026 13:14:24 -0700 Subject: [PATCH] fix: strip comments from inline style values in linear time Co-Authored-By: Claude Opus 4.8 --- .changeset/strip-style-comments.md | 5 +++++ packages/svelte/src/internal/shared/attributes.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/strip-style-comments.md 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 | '"' | "'"} */