Skip to content
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

fix(runtime-dom): <img width height> should be set as attribute #7659

Closed
wants to merge 2 commits into from
Closed

fix(runtime-dom): <img width height> should be set as attribute #7659

wants to merge 2 commits into from

Conversation

zh-lx
Copy link
Contributor

@zh-lx zh-lx commented Feb 6, 2023

fix #7658

When height and width of some embedded element such as <img><video><source> and <canvas> are string type, they will be rendered as 0. And they are rendered normally when they are number type. This is because of the height and width of these elements must be set as attribute when they are string type.

So in patchProp they should be modified by patchAttr instead of patchDOMProp.

<img width height> must be set as attribute. <video>, <picture> and <source> are also
<img width height> must be set as attribute. <video>, <picture> and <source> are also
@zh-lx zh-lx changed the title fix: <img width height> should be set as attribute fix(runtime-dom): <img width height> should be set as attribute Feb 6, 2023
@LinusBorg
Copy link
Member

Thanks for this PR, but the current behavior is just what the browser does according to the spec. We should not do any special handling here, the developer should provide the value in the correct type.

@LinusBorg LinusBorg closed this Feb 7, 2023
@Justineo
Copy link
Member

Justineo commented Feb 7, 2023

Current behavior for CSR and SSR is different. And under certain optimization in CSR the behavior is also different. I think this is a bug and should be fixed.

@LinusBorg
Copy link
Member

Different how? Is there an issue for that problem with SSR?

@zh-lx
Copy link
Contributor Author

zh-lx commented Feb 7, 2023

@zh-lx
Copy link
Contributor Author

zh-lx commented Feb 7, 2023

Thanks for this PR, but the current behavior is just what the browser does according to the spec. We should not do any special handling here, the developer should provide the value in the correct type.

Although the description of width of <img> on MDN must be a integer, it can also be a string type when used in html.I think the description on mdn is not necessarily accurate, and we should be more consistent with the actual use of html.

Here is an example to prove my point:

The attribute of <input> in mdn also has width and height and their description is consistent with that of <img>. But in fact, the width of input can only be changed through style. Neither setAttribute nor prop can change its width, even if its value is a integer. The following is the example about <input >:

https://sfc.vuejs.org/#eNp9j71Ow0AMx1/FeAlITa4MLFVaiY03YPFSEqdJlfuQ75IOUd4dX4oQAonN/w//ZC/4GkI1T4wHrGMjQ0gQOU3hRG6wwUuCBYQ7WKETb6HQakGOXONdTGDjBY45fyzeeBw9vHsZ24fiiVxt7jgFqUhsw3hOrAqg7p9Py7Itr2ttVG3u4MKUYC6tb3k8EmpOCLehTb2ql/2eUIu1+WbhDu83lvYcqmv0Tr9YMou+gkh4gM3Jnt6eNWGfUogHY2LX5N+vsfJyMTpVMrk0WK442vJD/C2yKJhw94Nh1JxZSmHXsrD8x/xV/cPN2JXciusn32yHkA==

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[runtime-dom]: when <img> width and height are of string type, they will be set to 0
3 participants