Skip to content

Commit

Permalink
use set for attribute props
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed May 22, 2024
1 parent b7c43d9 commit f41ccd5
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ function setStyle(style, key, value) {
}
}

const ATTRIBUTE_PROPS = new Set([
'width',
'height',
'href',
'list',
'form',
// Default value in browsers is `-1` and an empty string is
// cast to `0` instead
'tabIndex',
'download',
'rowSpan',
'colSpan',
'role',
'popover',
])

// A logical clock to solve issues like https://github.com/preactjs/preact/issues/3927.
// When the DOM performs an event it leaves micro-ticks in between bubbling up which means that
// an event can trigger on a newly reated DOM-node while the event bubbles up.
Expand Down Expand Up @@ -104,19 +120,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
// - className --> class
name = name.replace(/xlink(H|:h)/, 'h').replace(/sName$/, 's');
} else if (
name != 'width' &&
name != 'height' &&
name != 'href' &&
name != 'list' &&
name != 'form' &&
// Default value in browsers is `-1` and an empty string is
// cast to `0` instead
name != 'tabIndex' &&
name != 'download' &&
name != 'rowSpan' &&
name != 'colSpan' &&
name != 'role' &&
name != 'popover' &&
!ATTRIBUTE_PROPS.has(name) &&
name in dom
) {
try {
Expand Down

0 comments on commit f41ccd5

Please sign in to comment.