mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fixes #13779. Remove nodes in document order
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
parent
bdc4f3ebbe
commit
e572eed269
@ -163,10 +163,9 @@ jQuery.fn.extend({
|
|||||||
remove: function( selector, keepData ) {
|
remove: function( selector, keepData ) {
|
||||||
var elem,
|
var elem,
|
||||||
elems = selector ? jQuery.filter( selector, this ) : this,
|
elems = selector ? jQuery.filter( selector, this ) : this,
|
||||||
i = elems.length;
|
i = 0;
|
||||||
|
|
||||||
while ( i-- ) {
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
||||||
elem = elems[ i ];
|
|
||||||
|
|
||||||
if ( !keepData && elem.nodeType === 1 ) {
|
if ( !keepData && elem.nodeType === 1 ) {
|
||||||
jQuery.cleanData( getAll( elem ) );
|
jQuery.cleanData( getAll( elem ) );
|
||||||
|
@ -1827,6 +1827,30 @@ test( "remove() event cleaning ", 1, function() {
|
|||||||
cleanUp.remove();
|
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() {
|
test( "detach()", 11, function() {
|
||||||
testRemove("detach");
|
testRemove("detach");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user