Skip to content

Commit

Permalink
refactor: Apply PR suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Marvin Hagemeister <[email protected]>
  • Loading branch information
rschristian and marvinhagemeister committed Jun 25, 2024
1 parent 4a23fa2 commit 64ca5df
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ let eventClock = 0;
* @param {string} namespace Whether or not this DOM node is an SVG node or not
*/
export function setProperty(dom, name, value, oldValue, namespace) {
let useCapture,
split = name.split(':');
if (split.length > 1) name = split[1];
let useCapture, prefix;
if (name[0] == 'a' || name[0] == 'p') {
let idx = name.indexOf(':');
if (idx > -1) {
// Only slices here, should be faster than array allocation
prefix = name.slice(0, idx);
name = name.slice(idx + 1);
}
}

o: if (name === 'style') {
if (typeof value == 'string') {
Expand Down Expand Up @@ -106,8 +112,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
// - className --> class
name = name.replace(/xlink(H|:h)/, 'h').replace(/sName$/, 's');
} else if (
split[0] == 'prop' ||
(split[0] != 'attr' &&
(prefix != 'attr' &&
name != 'width' &&
name != 'height' &&
name != 'href' &&
Expand All @@ -121,7 +126,8 @@ export function setProperty(dom, name, value, oldValue, namespace) {
name != 'colSpan' &&
name != 'role' &&
name != 'popover' &&
name in dom)
name in dom) ||
prefix == 'prop'
) {
try {
dom[name] = value == null ? '' : value;
Expand Down

0 comments on commit 64ca5df

Please sign in to comment.