Skip to content

Commit

Permalink
chore: optimize widht/height element check
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 30, 2023
1 parent 38aaa8c commit 9845f1d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/runtime-dom/src/patchProp.ts
Expand Up @@ -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'] = (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9845f1d

Please sign in to comment.