]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: optimize widht/height element check
authorEvan You <yyx990803@gmail.com>
Thu, 30 Nov 2023 09:59:27 +0000 (17:59 +0800)
committerEvan You <yyx990803@gmail.com>
Thu, 30 Nov 2023 09:59:27 +0000 (17:59 +0800)
packages/runtime-dom/src/patchProp.ts

index 28753a90380e8a532f8eb7887ed4dd86a9ec2997..56deb38a57e8bdf9e5bd319fe547b658bb91c388 100644 (file)
@@ -13,8 +13,6 @@ const isNativeOn = (key: string) =>
   key.charCodeAt(2) > 96 &&
   key.charCodeAt(2) < 123
 
-const embeddedTags = ['IMG', 'VIDEO', 'CANVAS', 'SOURCE']
-
 type DOMRendererOptions = RendererOptions<Node, Element>
 
 export const patchProp: DOMRendererOptions['patchProp'] = (
@@ -113,11 +111,11 @@ function shouldSetAsProp(
   }
 
   // #8780 the width or heigth of embedded tags must be set as attribute
-  if (
-    (key === 'width' || key === 'height') &&
-    embeddedTags.includes(el.tagName)
-  ) {
-    return false
+  if (key === 'width' || key === 'height') {
+    const tag = el.tagName
+    return (
+      tag === 'IMG' || tag === 'VIDEO' || tag === 'CANVAS' || tag === 'SOURCE'
+    )
   }
 
   // native onclick with string value, must be set as attribute