Baseline Widely available
The normalize()
method of the Node
interface puts the specified node and all of its sub-tree into a normalized form. In a normalized sub-tree, no text nodes in the sub-tree are empty and there are no adjacent text nodes.
None.
Return valueNone.
Example<output id="result"></output>
const wrapper = document.createElement("div");
wrapper.appendChild(document.createTextNode("Part 1 "));
wrapper.appendChild(document.createTextNode("Part 2 "));
let node = wrapper.firstChild;
let result = "Before normalization:\n";
while (node) {
result += ` ${node.nodeName}: ${node.nodeValue}\n`;
node = node.nextSibling;
}
wrapper.normalize();
node = wrapper.firstChild;
result += "\n\nAfter normalization:\n";
while (node) {
result += ` ${node.nodeName}: ${node.nodeValue}\n`;
node = node.nextSibling;
}
const output = document.getElementById("result");
output.innerText = result;
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4