From: Evan You Date: Thu, 30 Nov 2023 09:59:27 +0000 (+0800) Subject: chore: optimize widht/height element check X-Git-Tag: v3.3.10~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9845f1d2a1ea8df7ae6db7ac3e012d1989fb448b;p=thirdparty%2Fvuejs%2Fcore.git chore: optimize widht/height element check --- diff --git a/packages/runtime-dom/src/patchProp.ts b/packages/runtime-dom/src/patchProp.ts index 28753a9038..56deb38a57 100644 --- a/packages/runtime-dom/src/patchProp.ts +++ b/packages/runtime-dom/src/patchProp.ts @@ -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 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