Skip to content

Commit

Permalink
Made sure that .remove now uses multiFilter. Fixes bug #4205.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Feb 20, 2009
1 parent db62240 commit a37ca9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -1224,7 +1224,7 @@ jQuery.each({
}, },


remove: function( selector ) { remove: function( selector ) {
if ( !selector || jQuery.filter( selector, [ this ] ).length ) { if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) {
// Prevent memory leaks // Prevent memory leaks
jQuery( "*", this ).add([this]).each(function(){ jQuery( "*", this ).add([this]).each(function(){
jQuery.event.remove(this); jQuery.event.remove(this);
Expand Down
5 changes: 4 additions & 1 deletion test/unit/core.js
Expand Up @@ -1713,7 +1713,7 @@ test("jQuery.className", function() {
}); });


test("remove()", function() { test("remove()", function() {
expect(6); expect(7);
jQuery("#ap").children().remove(); jQuery("#ap").children().remove();
ok( jQuery("#ap").text().length > 10, "Check text is not removed" ); ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
equals( jQuery("#ap").children().length, 0, "Check remove" ); equals( jQuery("#ap").children().length, 0, "Check remove" );
Expand All @@ -1723,6 +1723,9 @@ test("remove()", function() {
ok( jQuery("#ap").text().length > 10, "Check text is not removed" ); ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
equals( jQuery("#ap").children().length, 1, "Check filtered remove" ); equals( jQuery("#ap").children().length, 1, "Check filtered remove" );


jQuery("#ap").children().remove("a, code");
equals( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );

// using contents will get comments regular, text, and comment nodes // using contents will get comments regular, text, and comment nodes
equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" ); equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
jQuery("#nonnodes").contents().remove(); jQuery("#nonnodes").contents().remove();
Expand Down

0 comments on commit a37ca9e

Please sign in to comment.