forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This method puts the given node and all of its sub tree into a normalized form. A normalized subtree has no empty text nodes and no adjacent text nodes.
- Loading branch information
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Document fragment initial text: 12, child nodes: 3 | ||
Element initial text: 34, child nodes: 2 | ||
Element text after document.normalize(): 34, child nodes: 2 | ||
Document fragment text after documentFragment.normalize(): 1234, child nodes: 2 | ||
Text node 1 data: 12 | ||
Text node 2 data: 2 | ||
Text node 3 data: 34 | ||
Text node 4 data: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<script src="../include.js"></script> | ||
<script> | ||
test(() => { | ||
const documentFragment = document.createDocumentFragment(); | ||
const textNode1 = document.createTextNode("1"); | ||
const textNode2 = document.createTextNode("2"); | ||
const textNode3 = document.createTextNode("3"); | ||
const textNode4 = document.createTextNode("4"); | ||
const emptyTextNode = document.createTextNode(""); | ||
documentFragment.appendChild(textNode1); | ||
documentFragment.appendChild(emptyTextNode); | ||
documentFragment.appendChild(textNode2); | ||
println(`Document fragment initial text: ${documentFragment.textContent}, child nodes: ${documentFragment.childNodes.length}`); | ||
let element = document.createElement('div'); | ||
documentFragment.appendChild(element); | ||
element.appendChild(textNode3); | ||
element.appendChild(textNode4); | ||
println(`Element initial text: ${element.textContent}, child nodes: ${element.childNodes.length}`); | ||
document.normalize(); | ||
println(`Element text after document.normalize(): ${element.textContent}, child nodes: ${element.childNodes.length}`); | ||
documentFragment.normalize(); | ||
println(`Document fragment text after documentFragment.normalize(): ${documentFragment.textContent}, child nodes: ${documentFragment.childNodes.length}`); | ||
println(`Text node 1 data: ${textNode1.data}`); | ||
println(`Text node 2 data: ${textNode2.data}`); | ||
println(`Text node 3 data: ${textNode3.data}`); | ||
println(`Text node 4 data: ${textNode4.data}`); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters