Landing in jQuery.contains, jQuery.fn.contains, and jQuery.fn.has support. Fixes #4101.
This commit is contained in:
parent
9e60fec46b
commit
4e27f17007
3 changed files with 53 additions and 1 deletions
|
@ -4,5 +4,6 @@ jQuery.expr[":"] = jQuery.expr.filters;
|
|||
jQuery.unique = Sizzle.uniqueSort;
|
||||
jQuery.getText = getText;
|
||||
jQuery.isXMLDoc = isXML;
|
||||
jQuery.contains = contains;
|
||||
|
||||
return;
|
||||
|
|
|
@ -57,6 +57,21 @@ jQuery.fn.extend({
|
|||
return ret;
|
||||
},
|
||||
|
||||
has: function( target ) {
|
||||
var targets = jQuery( target );
|
||||
return this.filter(function() {
|
||||
for ( var i = 0, l = targets.length; i < l; i++ ) {
|
||||
if ( jQuery.contains( this, targets[i] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
contains: function( target ) {
|
||||
return this.has( target ).length > 0;
|
||||
},
|
||||
|
||||
not: function( selector ) {
|
||||
return this.pushStack( winnow(this, selector, false), "not", selector);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue