Technically, width / height on `<img>`, `<video>` etc must be integers and cannot contain units. When set as a DOM property, the DOM force converts strings with units to 0. However, this is such a common mistake that most browsers nowadays supports such usage, and it makes sense for Vue to at least let it be set as an attribute.
expect(el.value).toBe('baz')
})
+ // #8780
+ test('embedded tag with width and height', () => {
+ // Width and height of some embedded element such as img、video、source、canvas
+ // must be set as attribute
+ const el = document.createElement('img')
+ patchProp(el, 'width', null, '24px')
+ expect(el.getAttribute('width')).toBe('24px')
+ })
+
test('translate attribute', () => {
const el = document.createElement('div')
patchProp(el, 'translate', null, 'no')
const nativeOnRE = /^on[a-z]/
+const embeddedTags = ['IMG', 'VIDEO', 'CANVAS', 'SOURCE']
+
type DOMRendererOptions = RendererOptions<Node, Element>
export const patchProp: DOMRendererOptions['patchProp'] = (
return false
}
+ // #8780 the width or heigth of embedded tags must be set as attribute
+ if (
+ (key === 'width' || key === 'height') &&
+ embeddedTags.includes(el.tagName)
+ ) {
+ return false
+ }
+
// native onclick with string value, must be set as attribute
if (nativeOnRE.test(key) && isString(value)) {
return false