Manipulation: Remove an internal argument to the remove method

(cherry-picked from 349edbd6c5)

Fixes gh-2301
Closes gh-2366
This commit is contained in:
Michał Gołębiowski 2015-06-14 00:34:05 +02:00
parent 473d2db9fd
commit b819be3e2f

View File

@ -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></$2>" );
@ -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 );
}
});