-
Notifications
You must be signed in to change notification settings - Fork 779
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
Percent size is not supported for elements attribute width/height #412
Comments
That is not an acceptable DOM value. It's being dropped by the DOM not virtual-dom. Only a number (of pixels) is valid. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-width |
Is it? If I use the developer tools I can set |
it'd be ok to not accept it, but log when that's happening, rather than failing silently |
Btw, I confirm that adding manually an element with Weird how instead setting it in the devtools is possible... |
No, it's not virtual-dom's job to reimplement huge chunks of complicated DOM APIs like that. The DOM's behavior is to drop invalid values. Better to be aware of that than avoid it. |
@berdario When you set it in developer tools, you're setting
Unfortunately, as @bendrucker points out, the JS DOM API doesn't do anything when you set properties to invalid values or even when you try to write to a read-only property, in order for It's more feasible for devs to know the DOM API, unfortunately. |
Yup, I forgot to update you here, but I fixed this downstream (since I was an user of virtual-dom indirectly via purescript-halogen): purescript-halogen/purescript-halogen#321 This has the advantage of preventing the errors for other developers unaware of the nuances between Element's width and CSS's width, while at the same time not having any impact/slowdown at runtime, since all of the checks are done at compile-time :) I guess you can close this issue |
virtualDom.create(virtualDom.h('img', {width: '100.0%'})).width
Will yield 0
The text was updated successfully, but these errors were encountered: