Skip to content

Commit 3d3ed11

Browse files
authored
fix(manipulation): Have text turn passed values to strings (#2047)
1 parent a8b9d13 commit 3d3ed11

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/api/manipulation.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,11 @@ describe('$(...)', () => {
19011901
expect(text).toBe('M&M');
19021902
});
19031903

1904+
it('should turn passed values to strings', () => {
1905+
$('.apple').text(1 as any);
1906+
expect($('.apple')[0].childNodes[0]).toHaveProperty('data', '1');
1907+
});
1908+
19041909
it('( undefined ) : should act as an accessor', () => {
19051910
const $div = $('<div>test</div>');
19061911
expect(typeof $div.text(undefined as any)).toBe('string');

src/api/manipulation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ export function text<T extends Node>(
10041004
child.next = child.prev = child.parent = null;
10051005
});
10061006

1007-
const textNode = new Text(str);
1007+
const textNode = new Text(`${str}`);
10081008

10091009
updateDOM(textNode, el);
10101010
});

0 commit comments

Comments
 (0)