]> source.dussan.org Git - jquery.git/commitdiff
Manipulation: Remove an internal argument to the remove method 2366/head
authorMichał Gołębiowski <m.goleb@gmail.com>
Mon, 1 Jun 2015 19:35:13 +0000 (21:35 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Sat, 13 Jun 2015 22:07:31 +0000 (00:07 +0200)
Fixes gh-2301
Closes gh-2366

src/manipulation.js

index 6424d8394cd60e89e8469e64fbcf462fed5b3ad6..4bac1417faddcef99cf38bc15c03d9a0761596fa 100644 (file)
@@ -196,6 +196,27 @@ function domManip( collection, args, callback, ignored ) {
        return collection;
 }
 
+function remove( elem, selector, keepData ) {
+       var node,
+               nodes = selector ? jQuery.filter( selector, elem ) : elem,
+               i = 0;
+
+       for ( ; (node = nodes[i]) != null; i++ ) {
+               if ( !keepData && node.nodeType === 1 ) {
+                       jQuery.cleanData( getAll( node ) );
+               }
+
+               if ( node.parentNode ) {
+                       if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
+                               setGlobalEval( getAll( node, "script" ) );
+                       }
+                       node.parentNode.removeChild( node );
+               }
+       }
+
+       return elem;
+}
+
 jQuery.extend({
        htmlPrefilter: function( html ) {
                return html.replace( rxhtmlTag, "<$1></$2>" );
@@ -268,6 +289,14 @@ jQuery.extend({
 });
 
 jQuery.fn.extend({
+       detach: function( selector ) {
+               return remove( this, selector, true );
+       },
+
+       remove: function( selector ) {
+               return remove( this, selector );
+       },
+
        text: function( value ) {
                return access( this, function( value ) {
                        return value === undefined ?
@@ -314,27 +343,6 @@ jQuery.fn.extend({
                });
        },
 
-       remove: function( selector, keepData /* Internal Use Only */ ) {
-               var elem,
-                       elems = selector ? jQuery.filter( selector, this ) : this,
-                       i = 0;
-
-               for ( ; (elem = elems[i]) != null; i++ ) {
-                       if ( !keepData && elem.nodeType === 1 ) {
-                               jQuery.cleanData( getAll( elem ) );
-                       }
-
-                       if ( elem.parentNode ) {
-                               if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
-                                       setGlobalEval( getAll( elem, "script" ) );
-                               }
-                               elem.parentNode.removeChild( elem );
-                       }
-               }
-
-               return this;
-       },
-
        empty: function() {
                var elem,
                        i = 0;
@@ -417,10 +425,6 @@ jQuery.fn.extend({
 
                // Force callback invocation
                }, ignored );
-       },
-
-       detach: function( selector ) {
-               return this.remove( selector, true );
        }
 });