Skip to content

Commit 8818b83

Browse files
tomdalekrisselden
authored andcommitted
nodeValue property on comment and text nodes should be mutable
1 parent 7bfd802 commit 8818b83

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/@simple-dom/document/test/node-test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ moduleWithDocument('Node', (helper) => {
2929
assert.strictEqual(body.lastChild, div, 'parents last child is set');
3030
});
3131

32+
QUnit.test('nodeValue is mutable', (assert) => {
33+
const doc = helper.document;
34+
const text = doc.createTextNode('hello world');
35+
const comment = doc.createComment('goodbye cruel world');
36+
37+
assert.strictEqual(text.nodeValue, 'hello world', 'precond - node value is set');
38+
assert.strictEqual(comment.nodeValue, 'goodbye cruel world', 'precond - node value is set');
39+
40+
text.nodeValue = text.nodeValue.toUpperCase();
41+
comment.nodeValue = comment.nodeValue.toUpperCase();
42+
43+
assert.strictEqual(text.nodeValue, 'HELLO WORLD');
44+
assert.strictEqual(comment.nodeValue, 'GOODBYE CRUEL WORLD', 'precond - node value is set');
45+
});
3246
});

packages/@simple-dom/interface/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ export interface SimpleRawHTMLSection extends SimpleNodeBase {
148148

149149
export interface SimpleText extends SimpleNodeBase {
150150
readonly nodeType: NodeType.TEXT_NODE;
151-
readonly nodeValue: string;
151+
nodeValue: string;
152152
}
153153

154154
export interface SimpleComment extends SimpleNodeBase {
155155
readonly nodeType: NodeType.COMMENT_NODE;
156-
readonly nodeValue: string;
156+
nodeValue: string;
157157
}
158158

159159
/**

0 commit comments

Comments
 (0)