From 81458c06965d158ff870b3a50eec3eda93b5bfa2 Mon Sep 17 00:00:00 2001 From: OfirHaf Date: Sun, 10 May 2026 08:06:56 +0300 Subject: [PATCH] fix: strip trailing semicolons from style directive values before setProperty When a reactive style directive value contains a trailing semicolon (e.g. `style:background={`conic-gradient(...);'`}`), the initial render works because it goes through cssText which tolerates semicolons, but subsequent reactive updates call el.style.setProperty() which silently rejects values containing semicolons, leaving the style unchanged. Strip trailing semicolons from the value in update_styles before calling setProperty, making reactive updates consistent with the initial render. Fixes #18182 --- packages/svelte/src/internal/client/dom/elements/style.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/dom/elements/style.js b/packages/svelte/src/internal/client/dom/elements/style.js index 3e05eec30e..8fde5e1fea 100644 --- a/packages/svelte/src/internal/client/dom/elements/style.js +++ b/packages/svelte/src/internal/client/dom/elements/style.js @@ -15,7 +15,10 @@ function update_styles(dom, prev = {}, next, priority) { if (next[key] == null) { dom.style.removeProperty(key); } else { - dom.style.setProperty(key, value, priority); + // setProperty rejects values with trailing semicolons; strip them so that + // reactive updates behave consistently with the initial cssText assignment + var str_value = String(value).replace(/;+\s*$/, ''); + dom.style.setProperty(key, str_value, priority); } } }