From b819be3e2f35ae64abc26ff9a2fe944e1ffbb7e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82=C4=99biowski?= Date: Sun, 14 Jun 2015 00:34:05 +0200 Subject: [PATCH] Manipulation: Remove an internal argument to the remove method (cherry-picked from 349edbd6c53aa93d4fd207d3c0c4c24a7b0314dd) Fixes gh-2301 Closes gh-2366 --- src/manipulation.js | 56 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/manipulation.js b/src/manipulation.js index 4371b2493..4fc1e0cf3 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -233,6 +233,28 @@ function domManip( collection, args, callback, ignored ) { return collection; } +function remove( elem, selector, keepData ) { + var node, + elems = selector ? jQuery.filter( selector, elem ) : elem, + i = 0; + + for ( ; (node = elems[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>" ); @@ -350,6 +372,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 ? @@ -394,28 +424,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; @@ -508,10 +516,6 @@ jQuery.fn.extend({ // Force callback invocation }, ignored ); - }, - - detach: function( selector ) { - return this.remove( selector, true ); } }); -- 2.39.5