Skip to content

Commit e488665

Browse files
committed
Display namespace on tag closers
1 parent b16e814 commit e488665

File tree

2 files changed

+25
-45
lines changed

2 files changed

+25
-45
lines changed

html-api-debugger/print-html-tree.js

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,57 +27,36 @@ export function printHtmlApiTree(node, ul, options = {}) {
2727
if (node.childNodes[i].nodeName) {
2828
const code = document.createElement('code');
2929

30+
let nodeText = options.showInvisible
31+
? replaceInvisible(node.childNodes[i].nodeName)
32+
: node.childNodes[i].nodeName;
33+
if (
34+
node.childNodes[i]._namespace &&
35+
node.childNodes[i]._namespace !== 'html'
36+
) {
37+
nodeText = `${node.childNodes[i]._namespace}:${nodeText}`;
38+
} else if (
39+
node.childNodes[i].namespaceURI &&
40+
node.childNodes[i].namespaceURI !== 'http://www.w3.org/1999/xhtml'
41+
) {
42+
const nsSuffix = node.childNodes[i].namespaceURI.split('/').at(-1);
43+
const ns =
44+
nsSuffix === 'svg'
45+
? 'svg'
46+
: nsSuffix === 'MathML'
47+
? 'math'
48+
: nsSuffix;
49+
nodeText = `${ns}:${nodeText}`;
50+
}
51+
3052
if (node.childNodes[i]._closer) {
3153
if (options.showClosers) {
32-
code.appendChild(
33-
document.createTextNode(
34-
`/${
35-
options.showInvisible
36-
? replaceInvisible(node.childNodes[i].nodeName)
37-
: node.childNodes[i].nodeName
38-
}`,
39-
),
40-
);
54+
code.appendChild(document.createTextNode(`/${nodeText}`));
4155
} else {
4256
continue;
4357
}
4458
} else {
45-
if (
46-
node.childNodes[i]._namespace &&
47-
node.childNodes[i]._namespace !== 'html'
48-
) {
49-
const nodeText = `${node.childNodes[i]._namespace}:${node.childNodes[i].nodeName}`;
50-
code.appendChild(
51-
document.createTextNode(
52-
options.showInvisible ? replaceInvisible(nodeText) : nodeText,
53-
),
54-
);
55-
} else if (
56-
node.childNodes[i].namespaceURI &&
57-
node.childNodes[i].namespaceURI !== 'http://www.w3.org/1999/xhtml'
58-
) {
59-
const nsSuffix = node.childNodes[i].namespaceURI.split('/').at(-1);
60-
const ns =
61-
nsSuffix === 'svg'
62-
? 'svg'
63-
: nsSuffix === 'MathML'
64-
? 'math'
65-
: nsSuffix;
66-
const nodeText = `${ns}:${node.childNodes[i].nodeName}`;
67-
code.appendChild(
68-
document.createTextNode(
69-
options.showInvisible ? replaceInvisible(nodeText) : nodeText,
70-
),
71-
);
72-
} else {
73-
code.appendChild(
74-
document.createTextNode(
75-
options.showInvisible
76-
? replaceInvisible(node.childNodes[i].nodeName)
77-
: node.childNodes[i].nodeName,
78-
),
79-
);
80-
}
59+
code.appendChild(document.createTextNode(nodeText));
8160
}
8261

8362
if (node.childNodes[i].nodeValue) {

html-api-debugger/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ Add a page to wp-admin for debugging the HTML API.
7878
= 1.6 =
7979
* Replace TABLE based layout with CSS grid.
8080
* Fix a crash on meta tags with a content attribute.
81+
* Display namespace on tag closers.

0 commit comments

Comments
 (0)