diff --git a/src/selector-native.js b/src/selector-native.js index 90a3745cf..faba51148 100644 --- a/src/selector-native.js +++ b/src/selector-native.js @@ -196,9 +196,8 @@ jQuery.extend( { return ret; }, contains: function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) ); + var bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && a.contains( bup ) ); }, isXMLDoc: function( elem ) { var namespace = elem.namespaceURI, diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 348912e6e..6bae15465 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2837,6 +2837,49 @@ QUnit.test( "Make sure tr is not appended to the wrong tbody (gh-3439)", functio assert.strictEqual( htmlOut, htmlExpected ); } ); +[ true, false ].forEach( function( adoptedCase ) { + QUnit[ + typeof HTMLTemplateElement === "function" ? + "test" : + "skip" + ]( "Manip within content moved back & forth doesn't throw - " + ( + adoptedCase ? "explicitly adopted" : "not explicitly adopted" + ) + " (gh-5147)", + function( assert ) { + assert.expect( 1 ); + + var fragment, diva, divb, + div = jQuery( "" + + "