Permalink
Browse files

Manipulation: Remove an internal argument to the remove method

Fixes gh-2301
Closes gh-2366
  • Loading branch information...
mgol committed Jun 1, 2015
1 parent 04a2969 commit 349edbd6c53aa93d4fd207d3c0c4c24a7b0314dd
Showing with 29 additions and 25 deletions.
  1. +29 −25 src/manipulation.js
View
@@ -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 );
}
});

0 comments on commit 349edbd

Please sign in to comment.