Skip to content

Commit

Permalink
Merge pull request #920 from capricorn86/task/819-incorrect-html-stri…
Browse files Browse the repository at this point in the history
…ng-generated

#819@patch: Fixes issue where non-string values did not get converted…
  • Loading branch information
capricorn86 committed May 13, 2023
2 parents 84fc898 + ad5dffb commit 9ed4cbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -54,7 +54,7 @@ export default abstract class CharacterData extends Node implements ICharacterDa
*/
public set data(data: string) {
const oldValue = this._data;
this._data = data;
this._data = String(data);

if (this.isConnected) {
this.ownerDocument['_cacheID']++;
Expand Down
Expand Up @@ -37,6 +37,8 @@ describe('CharaterData', () => {
const node = <CharacterData>document.createComment('test');
node.data = 'new text';
expect(node.data).toBe('new text');
node.data = <string>(<unknown>0);
expect(node.data).toBe('0');
});
});

Expand All @@ -52,6 +54,8 @@ describe('CharaterData', () => {
const node = document.createTextNode('test');
node.nodeValue = 'new text';
expect(node.nodeValue).toBe('new text');
node.nodeValue = <string>(<unknown>0);
expect(node.nodeValue).toBe('0');
});
});

Expand All @@ -67,6 +71,8 @@ describe('CharaterData', () => {
const node = document.createComment('test');
node.textContent = 'new text';
expect(node.textContent).toBe('new text');
node.textContent = <string>(<unknown>0);
expect(node.textContent).toBe('0');
});
});

Expand Down

0 comments on commit 9ed4cbf

Please sign in to comment.