Skip to content

Commit

Permalink
fix(manipulation): Have text turn passed values to strings (#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 authored Aug 14, 2021
1 parent a8b9d13 commit 3d3ed11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/api/manipulation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,11 @@ describe('$(...)', () => {
expect(text).toBe('M&M');
});

it('should turn passed values to strings', () => {
$('.apple').text(1 as any);
expect($('.apple')[0].childNodes[0]).toHaveProperty('data', '1');
});

it('( undefined ) : should act as an accessor', () => {
const $div = $('<div>test</div>');
expect(typeof $div.text(undefined as any)).toBe('string');
Expand Down
2 changes: 1 addition & 1 deletion src/api/manipulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ export function text<T extends Node>(
child.next = child.prev = child.parent = null;
});

const textNode = new Text(str);
const textNode = new Text(`${str}`);

updateDOM(textNode, el);
});
Expand Down

0 comments on commit 3d3ed11

Please sign in to comment.