diff --git a/src/api/manipulation.spec.ts b/src/api/manipulation.spec.ts index 787d5be208..c3134222fe 100644 --- a/src/api/manipulation.spec.ts +++ b/src/api/manipulation.spec.ts @@ -1770,6 +1770,13 @@ describe('$(...)', () => { expect(html).toBe('
  • Durian
  • '); }); + it('(elem) : should move the passed element (#940)', () => { + $('.apple').html($('.orange')); + expect($fruits.html()).toBe( + '
  • Orange
  • Pear
  • ' + ); + }); + it('() : should allow element reinsertion', () => { const $children = $fruits.children(); diff --git a/src/api/manipulation.ts b/src/api/manipulation.ts index 6d2656fe0b..74a7719ebc 100644 --- a/src/api/manipulation.ts +++ b/src/api/manipulation.ts @@ -939,7 +939,7 @@ export function html( opts.context = el; const content = isCheerio(str) - ? str.clone().get() + ? str.toArray() : parse(`${str}`, opts, false).children; updateDOM(content, el);