Skip to content

Commit 9845f1d

Browse files
committed
chore: optimize widht/height element check
1 parent 38aaa8c commit 9845f1d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

packages/runtime-dom/src/patchProp.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const isNativeOn = (key: string) =>
1313
key.charCodeAt(2) > 96 &&
1414
key.charCodeAt(2) < 123
1515

16-
const embeddedTags = ['IMG', 'VIDEO', 'CANVAS', 'SOURCE']
17-
1816
type DOMRendererOptions = RendererOptions<Node, Element>
1917

2018
export const patchProp: DOMRendererOptions['patchProp'] = (
@@ -113,11 +111,11 @@ function shouldSetAsProp(
113111
}
114112

115113
// #8780 the width or heigth of embedded tags must be set as attribute
116-
if (
117-
(key === 'width' || key === 'height') &&
118-
embeddedTags.includes(el.tagName)
119-
) {
120-
return false
114+
if (key === 'width' || key === 'height') {
115+
const tag = el.tagName
116+
return (
117+
tag === 'IMG' || tag === 'VIDEO' || tag === 'CANVAS' || tag === 'SOURCE'
118+
)
121119
}
122120

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

0 commit comments

Comments
 (0)