Skip to content

Commit

Permalink
Merge pull request #174 from timreichen/text-textContent-setter
Browse files Browse the repository at this point in the history
fix: Text.textContent setter
  • Loading branch information
b-fuze authored Aug 12, 2024
2 parents d50e746 + 71617e2 commit 4658549
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/dom/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,6 @@ export class Text extends CharacterData {
_shallowClone(): Node {
return new Text(this.textContent);
}

get textContent(): string {
return <string> this.nodeValue;
}
}

export class Comment extends CharacterData {
Expand Down
11 changes: 11 additions & 0 deletions test/units/CharacterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,14 @@ Deno.test("CharacterData.after/before/remove/replaceWith", () => {
assertEquals(comment.previousSibling, null);
assertEquals(comment.nextSibling, null);
});

Deno.test("CharacterData.textContent", () => {
const doc = new DOMParser().parseFromString(
`<body>foo</body>`,
"text/html",
);
const text = doc.body.childNodes[0];
assertEquals(text.textContent, "foo");
text.textContent = "bar";
assertEquals(text.textContent, "bar");
});

0 comments on commit 4658549

Please sign in to comment.