remove: function( selector, keepData ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
- i = elems.length;
+ i = 0;
- while ( i-- ) {
- elem = elems[ i ];
+ for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
cleanUp.remove();
});
+test( "remove() in document order #13779", 1, function() {
+ var last,
+ cleanData = jQuery.cleanData;
+
+ jQuery.cleanData = function( nodes ) {
+ last = nodes[0].textContent;
+ cleanData.call( this, nodes );
+ };
+
+ jQuery("#qunit-fixture").append(
+ jQuery.parseHTML(
+ "<div class='removal-fixture'>1</div>" +
+ "<div class='removal-fixture'>2</div>" +
+ "<div class='removal-fixture'>3</div>"
+ )
+ );
+
+ jQuery(".removal-fixture").remove();
+
+ equal( last, 3, "The removal fixtures were removed in document order" );
+
+ jQuery.cleanData = cleanData;
+});
+
test( "detach()", 11, function() {
testRemove("detach");
});