Skip to content

Commit

Permalink
refactor: golf & fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Apr 30, 2024
1 parent 76dabd4 commit 06a0d73
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function diffElementNodes(
let inputValue;
let checked;

// Tracks entering and exiting SVG namespace when descending through the tree.
// Tracks entering and exiting namespaces when descending through the tree.
if (nodeType === 'svg') namespace = 2;
else if (nodeType === 'math') namespace = 3;

Expand Down Expand Up @@ -403,15 +403,15 @@ function diffElementNodes(
return document.createTextNode(newProps);
}

if (namespace == 2) {
dom = document.createElementNS('http://www.w3.org/2000/svg', nodeType);
} else if (namespace == 3) {
if (namespace == 1) {
dom = document.createElement(nodeType, newProps.is && newProps);
} else {
dom = document.createElementNS(
'http://www.w3.org/1998/Math/MathML',
namespace == 2
? 'http://www.w3.org/2000/svg'
: 'http://www.w3.org/1998/Math/MathML',
nodeType
);
} else {
dom = document.createElement(nodeType, newProps.is && newProps);
}

// we created a new parent, so none of the previously attached children can be reused:
Expand Down Expand Up @@ -502,7 +502,7 @@ function diffElementNodes(
newVNode,
oldVNode,
globalContext,
nodeType == 'foreignObject' ? 1 : namespace,
nodeType === 'foreignObject' ? 1 : namespace,
excessDomChildren,
commitQueue,
excessDomChildren
Expand Down

0 comments on commit 06a0d73

Please sign in to comment.