hyperapp: Height attribute on img element not working
I was using hyperapp 1.0.1 and this was working
<img src="https://i.pinimg.com/originals/87/b8/67/87b8671c2d08dc83554806539022bde7.gif" height="100px"/>
I update to hyperapp 1.1.2 and now it doesn’t work, but it does without the “px” like this
<img src="https://i.pinimg.com/originals/87/b8/67/87b8671c2d08dc83554806539022bde7.gif" height="100"/>
Here is the Codepen
So I went and check what changes were made, and apparently, this breaks after the version 1.0.2. The problem is here on line 138 where before it was always using setAttribute
if (value == null || value === false) {
element.removeAttribute(name)
} else {
element.setAttribute(name, value)
}
and now is using
if (typeof value === "function" || (name in element && !isSVG)) {
element[name] = value == null ? "" : value
} else if (value != null && value !== false) {
element.setAttribute(name, value)
}
If the element has the attribute and because the image height attribute is an int and not a string it is set to 0.
It’s not a big issue you could just write the number without the “px”. However, there are people who use the “px” like I was doing and then the whole images on the site disappear. Probably there are similar cases like this with other elements.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (9 by maintainers)
I would prefer to keep current behavior when you must specify image height and with without
px
, not a bug IMO.