1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibWeb: Add Node.textContent

This requires moving remove_all_children() from ParentNode to
Node, which makes ParentNode.cpp empty, so remove it.

It also co-opts the existing Node::text_content() method and
tweaks it slightly to fit the semantics of Node.textContent.
This commit is contained in:
Nico Weber 2020-08-17 12:36:00 -04:00 committed by Andreas Kling
parent c0c7b4a098
commit e9b56b5b9c
7 changed files with 44 additions and 44 deletions

View file

@ -0,0 +1,20 @@
loadPage("file:///res/html/misc/small.html");
afterInitialPageLoad(() => {
test("Node.textContent", () => {
var p = document.getElementsByTagName("p")[0];
expect(p.textContent).toBe("This is a very small test page :^)");
expect(p.firstChild.textContent).toBe("This is a ");
expect(p.firstChild.firstChild).toBe(null);
p.firstChild.textContent = "foo";
expect(p.firstChild.textContent).toBe("foo");
expect(p.firstChild.firstChild).toBe(null);
expect(p.textContent).toBe("foovery small test page :^)");
p.textContent = "bar";
expect(p.textContent).toBe("bar");
expect(p.firstChild.textContent).toBe("bar");
expect(p.firstChild.firstChild).toBe(null);
});
});