Skip to content

Commit 5b00286

Browse files
committed
fix(runtime-dom): fix width and height prop check condition
close #9762
1 parent d74d364 commit 5b00286

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/runtime-dom/__tests__/patchProps.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ describe('runtime-dom: props patching', () => {
300300
expect(el.getAttribute('width')).toBe('24px')
301301
})
302302

303+
// # 9762 should fallthrough to `key in el` logic for non embedded tags
304+
test('width and height on custom elements', () => {
305+
const el = document.createElement('foobar')
306+
patchProp(el, 'width', null, '24px')
307+
expect(el.getAttribute('width')).toBe('24px')
308+
})
309+
303310
test('translate attribute', () => {
304311
const el = document.createElement('div')
305312
patchProp(el, 'translate', null, 'no')

packages/runtime-dom/src/patchProp.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ function shouldSetAsProp(
113113
// #8780 the width or height of embedded tags must be set as attribute
114114
if (key === 'width' || key === 'height') {
115115
const tag = el.tagName
116-
return !(
116+
if (
117117
tag === 'IMG' ||
118118
tag === 'VIDEO' ||
119119
tag === 'CANVAS' ||
120120
tag === 'SOURCE'
121-
)
121+
) {
122+
return false
123+
}
122124
}
123125

124126
// native onclick with string value, must be set as attribute

0 commit comments

Comments
 (0)