-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
[runtime-dom]: when <img> width and height are of string type, they will be set to 0
#7658
Comments
0
0
0
Duplicate of #2801 |
I'm with edison here. The developer should provide a number as that's what's expected by the HTML spec. We should not start adding code to special handle such cases. |
Although the description of Here is an example to prove my point: The attribute of |
Certain browsers may support that, but it's not in the spec:
https://html.spec.whatwg.org/multipage/embedded-content-other.html#attr-dim-height Vue also supports strings, by the way, as long as they are convertible to integers which the spec expects as values. So if you provide a string containing just a number, free of a unit ( So this PR would "only" add code to be more compatible with nonstandard browser behavior. That is something we could want, but I'm still not exactly convinced it's worth being another special case to have in the codebase. @Justineo in what way does this break in certain cases in CSR? |
All right, thanks for your answer. |
I have the same problem. The description of |
core/packages/compiler-dom/src/transforms/stringifyStatic.ts Lines 83 to 86 in 6c6fe2c
There's currently a But if we decided not to support non-standard syntax which seems to be supported by all major browsers, current behavior should be fine. (And I just found out that browsers actually support not only |
Vue version
3.2.47
Link to minimal reproduction
https://sfc.vuejs.org/#eNp9UMtOwzAQ/JXFl17quA+KIAqV+A9fnHSTGGrHrJ0Wqcq/s24qQCBxsmd3PDOei3gJoTiNKEpRxYZsSBAxjWGvvXVhoAQXIGxhgpYGBwumLrTXvlIzm3kMErpwNAkZAVT9em9dVyk+r/hOSjjbQ+pLWK/ARvADOXME4w/Qo+14sbkPH3lj6ttOyvktC0Gk5lmLPqUQS6XOWAfTvBWvsRioU7YZvIzvoyGUkV8ei8ddbR62q6ZdNbt282Rwi9sinjot5hSstV4xyNZ9YpTNGSt2rNTXV8RSzA1IZwK7DZ47uuRQ+raIWpRwneQZN5Pxd9DYNrnZW06+FTT6ZB0WGJ2saThHJBbWYvlDQ/HwhCQJ/QEJ6T/NX9Q/ull20n4S0yeVPKVf
Steps to reproduce
Look the preview:
The
height
of<img>
is0
, but it should be24px
What is expected?
The
height
of<img>
should be24px
What is actually happening?
When
height
andwidth
of some embedded element such as<img>
、<video>
、<source>
and<canvas>
are string type, they will be rendered as0
. And they are rendered normally when they are number type. This is because of theheight
andwidth
of these elements must be set as attribute when they are string type, but inpatchProp
they are directly modified bypatchDOMProp
instead ofpatchAttr
.System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: