Skip to content
Permalink
Browse files

Fix #11230. .appendTo and pals should always stack.

  • Loading branch information
dmethvin committed Dec 12, 2012
1 parent 40e08f8 commit 0018f7700bf8004d573c752ecbf66f299769c4de
Showing with 9 additions and 15 deletions.
  1. +4 −10 src/manipulation.js
  2. +5 −5 test/unit/manipulation.js
@@ -512,21 +512,15 @@ jQuery.each({
i = 0,
ret = [],
insert = jQuery( selector ),
l = insert.length,
parent = this.length === 1 && this[0].parentNode;
last = insert.length - 1;

if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
insert[ original ]( this[0] );
return this;
} else {
for ( ; i < l; i++ ) {
elems = ( i > 0 ? this.clone(true) : this ).get();
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone(true);
jQuery( insert[i] )[ original ]( elems );
ret = ret.concat( elems );
core_push.apply( ret, elems.get() );
}

return this.pushStack( ret );
}
};
});

@@ -2092,10 +2092,10 @@ test( "Ensure oldIE creates a new set on appendTo (#8894)", function() {

expect( 5 );

strictEqual( jQuery("<div/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" );
strictEqual( jQuery("<div/>").find("p").end().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" );
strictEqual( jQuery("<div/>").text("test").addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" );
strictEqual( jQuery("<bdi/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" );
strictEqual( jQuery("<div/>").clone().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" );
strictEqual( jQuery("<div/>").find("p").end().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" );
strictEqual( jQuery("<div/>").text("test").addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" );
strictEqual( jQuery("<bdi/>").clone().addClass("test").appendTo("<div/>").end().end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" );
strictEqual( jQuery("<p/>").appendTo("<div/>").end().length, jQuery("<p>test</p>").appendTo("<div/>").end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
});

@@ -2292,7 +2292,7 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e
"<ul id='test4087-complex'><li class='test4087'><div>c1</div>h1</li><li><div>c2</div>h2</li></ul>",
"<div id='test4087-simple'><div class='test4087-1'>1<div class='test4087-2'>2</div><div class='test4087-3'>3</div></div></div>",
"<div id='test4087-multiple'><div class='test4087-multiple'>1</div><div class='test4087-multiple'>2</div></div>"
] ).appendTo( "#qunit-fixture" );
].join("") ).appendTo( "#qunit-fixture" );

// complex case based on http://jsfiddle.net/pbramos/gZ7vB/
jQuery("#test4087-complex div")[ name ]("#test4087-complex li:last-child div:last-child");

0 comments on commit 0018f77

Please sign in to comment.
You can’t perform that action at this time.