Fixes #13779. Remove nodes in document order

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
Rick Waldron 2013-04-16 22:26:22 -04:00
parent bdc4f3ebbe
commit e572eed269
2 changed files with 26 additions and 3 deletions

View File

@ -163,10 +163,9 @@ jQuery.fn.extend({
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 ) );

View File

@ -1827,6 +1827,30 @@ test( "remove() event cleaning ", 1, function() {
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");
});