Skip to content

Commit

Permalink
fix(manipulation): .html should move passed nodes (#1923)
Browse files Browse the repository at this point in the history
Fixes #940.
  • Loading branch information
fb55 committed Jun 8, 2021
1 parent 5cd2b9c commit 258b26b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/api/manipulation.spec.ts
Expand Up @@ -1770,6 +1770,13 @@ describe('$(...)', () => {
expect(html).toBe('<li class="durian">Durian</li>');
});

it('(elem) : should move the passed element (#940)', () => {
$('.apple').html($('.orange'));
expect($fruits.html()).toBe(
'<li class="apple"><li class="orange">Orange</li></li><li class="pear">Pear</li>'
);
});

it('() : should allow element reinsertion', () => {
const $children = $fruits.children();

Expand Down
2 changes: 1 addition & 1 deletion src/api/manipulation.ts
Expand Up @@ -939,7 +939,7 @@ export function html<T extends Node>(
opts.context = el;

const content = isCheerio(str)
? str.clone().get()
? str.toArray()
: parse(`${str}`, opts, false).children;

updateDOM(content, el);
Expand Down

0 comments on commit 258b26b

Please sign in to comment.