From 06a0d731c2dbddd244428477170f402cd95f9330 Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Tue, 30 Apr 2024 02:23:02 -0500 Subject: [PATCH] refactor: golf & fix comment --- src/diff/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diff/index.js b/src/diff/index.js index 3a78f31b30..fbef9a0aca 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -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; @@ -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: @@ -502,7 +502,7 @@ function diffElementNodes( newVNode, oldVNode, globalContext, - nodeType == 'foreignObject' ? 1 : namespace, + nodeType === 'foreignObject' ? 1 : namespace, excessDomChildren, commitQueue, excessDomChildren