mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Implement Text.wholeText
This getter returns the concatenation of the data of the contiguous Text nodes of `this` (being this plus its siblings) in tree order.
This commit is contained in:
parent
7dacd6be89
commit
69da6a0ce4
Notes:
github-actions[bot]
2024-07-20 17:03:45 +00:00
Author: https://github.com/aescarias 🔰
Commit: 69da6a0ce4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/725
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 76 additions and 1 deletions
36
Tests/LibWeb/Text/input/DOM/Text-wholeText.html
Normal file
36
Tests/LibWeb/Text/input/DOM/Text-wholeText.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
// HTML Text Nodes
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
const firstNode = document.createTextNode("A");
|
||||
fragment.appendChild(firstNode);
|
||||
println(`Text node ${firstNode.data} with no siblings: ${firstNode.wholeText}`);
|
||||
|
||||
const secondNode = document.createTextNode("B");
|
||||
fragment.appendChild(secondNode);
|
||||
println(`Text node ${secondNode.data} with previous sibling ${secondNode.previousSibling.data}: ${secondNode.wholeText}`);
|
||||
|
||||
const thirdNode = document.createTextNode("C");
|
||||
fragment.appendChild(thirdNode);
|
||||
println(`Text node ${secondNode.data} with previous sibling ${secondNode.previousSibling.data} and next sibling ${secondNode.nextSibling.data}: ${secondNode.wholeText}`);
|
||||
|
||||
// XML CDATA Sections
|
||||
const xmlDoc = new DOMParser().parseFromString("<root></root>", "application/xml");
|
||||
const xmlFrag = xmlDoc.querySelector("root");
|
||||
|
||||
const firstSection = xmlDoc.createCDATASection("D");
|
||||
xmlFrag.appendChild(firstSection);
|
||||
println(`CDATA section ${firstSection.data} with no siblings: ${firstSection.wholeText}`);
|
||||
|
||||
const secondSection = xmlDoc.createCDATASection("E");
|
||||
xmlFrag.appendChild(secondSection);
|
||||
println(`CDATA section ${secondSection.data} with previous sibling ${secondSection.previousSibling.data}: ${secondSection.wholeText}`);
|
||||
|
||||
const thirdSection = xmlDoc.createCDATASection("F");
|
||||
xmlFrag.appendChild(thirdSection);
|
||||
println(`CDATA section ${secondSection.data} with previous sibling ${secondSection.previousSibling.data} and next sibling ${secondSection.nextSibling.data}: ${secondSection.wholeText}`);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue