Skip to content

Commit 319f3b4

Browse files
committed
refactor: Inline namespaces
1 parent da96940 commit 319f3b4

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export const MATCHED = 1 << 1;
1010
/** Reset all mode flags */
1111
export const RESET_MODE = ~(MODE_HYDRATE | MODE_SUSPENDED);
1212

13-
export const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
14-
export const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
15-
export const MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
13+
//export const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
14+
//export const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
15+
//export const MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1616

1717
export const EMPTY_OBJ = /** @type {any} */ ({});
1818
export const EMPTY_ARR = [];

src/diff/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import {
22
EMPTY_OBJ,
3-
MATH_NAMESPACE,
43
MODE_HYDRATE,
54
MODE_SUSPENDED,
6-
RESET_MODE,
7-
SVG_NAMESPACE,
8-
XHTML_NAMESPACE
5+
RESET_MODE
96
} from '../constants';
107
import { BaseComponent, getDomSibling } from '../component';
118
import { Fragment } from '../create-element';
@@ -424,9 +421,9 @@ function diffElementNodes(
424421
let checked;
425422

426423
// Tracks entering and exiting namespaces when descending through the tree.
427-
if (nodeType == 'svg') namespace = SVG_NAMESPACE;
428-
else if (nodeType == 'math') namespace = MATH_NAMESPACE;
429-
else if (!namespace) namespace = XHTML_NAMESPACE;
424+
if (nodeType == 'svg') namespace = 'http://www.w3.org/2000/svg';
425+
else if (nodeType == 'math') namespace = 'http://www.w3.org/1998/Math/MathML';
426+
else if (!namespace) namespace = 'http://www.w3.org/1999/xhtml';
430427

431428
if (excessDomChildren != null) {
432429
for (i = 0; i < excessDomChildren.length; i++) {
@@ -549,7 +546,9 @@ function diffElementNodes(
549546
newVNode,
550547
oldVNode,
551548
globalContext,
552-
nodeType == 'foreignObject' ? XHTML_NAMESPACE : namespace,
549+
nodeType == 'foreignObject'
550+
? 'http://www.w3.org/1999/xhtml'
551+
: namespace,
553552
excessDomChildren,
554553
commitQueue,
555554
excessDomChildren

src/diff/props.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IS_NON_DIMENSIONAL, SVG_NAMESPACE } from '../constants';
1+
import { IS_NON_DIMENSIONAL } from '../constants';
22
import options from '../options';
33

44
function setStyle(style, key, value) {
@@ -96,7 +96,7 @@ export function setProperty(dom, name, value, oldValue, namespace) {
9696
);
9797
}
9898
} else {
99-
if (namespace == SVG_NAMESPACE) {
99+
if (namespace == 'http://www.w3.org/2000/svg') {
100100
// Normalize incorrect prop usage for SVG:
101101
// - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)
102102
// - className --> class

0 commit comments

Comments
 (0)