-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
Description
Describe the bug
If I or any third-party library assigns styles to an element using Object.assign, Svelte will remove those styles when updating the element's style attribute. This is really annoying and limiting; Can't Svelte do something about this? This doesn't happen in React.
Reproduction
<script lang="ts">
let width = $state("200px");
function testAction(node: HTMLDivElement) {
Object.assign(node.style, {
position: "absolute",
top: "0px",
right: "0px",
});
}
</script>
<input type="text" bind:value={width} />
<div use:testAction style="width: {width}; height: 200px; background: red;"></div>REPL
Just change the width from 200px to 20px.
Logs
System Info
System:
OS: Windows 11 10.0.26100
CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-12650H
Memory: 7.72 GB / 15.63 GB
Binaries:
Node: 23.11.0 - C:\nvm4w\nodejs\node.EXE
npm: 11.4.1 - C:\nvm4w\nodejs\npm.CMD
pnpm: 10.13.1 - C:\nvm4w\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (136.0.3240.64)
Internet Explorer: 11.0.26100.1882Severity
annoyance