-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Width of img becomes zero when using spread props #6752
Comments
This is presumably the result of the The svelte/src/runtime/internal/dom.ts Line 294 in fc4797c
I don't know what the solution to this is, and I don't know where the balance is between optimal behavior and having to ship a whole bunch of attribute/property lookup information to the browser with the app whenever someone uses spread attributes. |
Unlike #6751 this happens on firefox as well |
width need to be a number |
svelte/src/runtime/internal/dom.ts Line 305 in 7b7c312
By the way, @Conduitry mentioned this before.
I think this is like this. export function set_attributes(node: Element & ElementCSSInlineStyle, attributes: { [x: string]: string }) {
// @ts-ignore
const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
for (const key in attributes) {
if (attributes[key] == null) {
node.removeAttribute(key);
} else if (key === 'style') {
node.style.cssText = attributes[key];
} else if (key === '__value') {
(node as any).value = node[key] = attributes[key];
} else if (descriptors[key] && descriptors[key].set) {
+ const is_different = node[key] !== attributes[key];
node[key] = attributes[key];
+ if (is_different && node[key] !== attributes[key]) attr(node, key, attributes[key]);
} else {
attr(node, key, attributes[key]);
}
}
} In my opinion, now we have 2 ways.
So I prefer option 1. |
Is there any update on this? Spread props are super useful but seems like they're best to be avoided until this gets resolved... |
fixes #6752 --------- Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Tan Li Hau <[email protected]>
This has been fixed in 3.59.0 - https://svelte.dev/repl/0e6f7df1207e4b9faaaa0fb2597badd9?version=3.59.0 |
Describe the bug
When using width attribute along with spread props on img, width is always zero.
The rendered HTML has
width="0"
Reproduction
REPL
REPL uses
$$restProps
but bug occurs with spreading any object.Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: