-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Style property used together with a spread property assigns to a read-only property #1664
Comments
Just revisiting this now... I might be losing my marbles but what is wrong here? It seems like it's behaving correctly! |
@Rich-Harris My bad, I wasn't clear enough here! 😬 The So, for a single In addition, it behaves correctly on modern browsers because they can handle assigning a string directly to the |
Ah, ok, it's a cross-browser thing. I brought it up because I was unable to create a failing test using export function setAttributes(node, attributes) {
for (var key in attributes) {
- if (key in node) {
+ if (key === 'style') {
+ node.style.cssText = attributes[key];
+ } else if (key in node) {
node[key] = attributes[key];
} else {
if (attributes[key] === undefined) removeAttribute(node, key);
else setAttribute(node, key, attributes[key]);
}
}
} |
for svg el just wrap in a other html tag will it works |
This looks like it's fixed in v3 — closing https://svelte.dev/repl/c1ef7df3e65546aba07137ff2bd7d91d?version=3.6.2 |
REPL
Generates a update function as:
The
setAttribute
finds thestyle
property in thenode
and tries to overwrite it:If you remove the
{...attrs}
, it generates as:The text was updated successfully, but these errors were encountered: