Moved a bunch of methods out of the jQuery-specific Sizzle code into more-appropriate files, in jQuery itself.
This commit is contained in:
parent
b7ccc58afe
commit
bbffc99f7c
|
@ -222,7 +222,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
is: function( selector ) {
|
is: function( selector ) {
|
||||||
return !!selector && jQuery.multiFilter( selector, this ).length > 0;
|
return !!selector && jQuery.filter( selector, this ).length > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
// For internal use only.
|
// For internal use only.
|
||||||
|
|
16
src/css.js
16
src/css.js
|
@ -197,3 +197,19 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||||
|
jQuery.expr.filters.hidden = function(elem){
|
||||||
|
var width = elem.offsetWidth, height = elem.offsetHeight,
|
||||||
|
force = /^tr$/i.test( elem.nodeName ); // ticket #4512
|
||||||
|
return ( width === 0 && height === 0 && !force ) ?
|
||||||
|
true :
|
||||||
|
( width !== 0 && height !== 0 && !force ) ?
|
||||||
|
false :
|
||||||
|
!!( jQuery.curCSS(elem, "display") === "none" );
|
||||||
|
};
|
||||||
|
|
||||||
|
jQuery.expr.filters.visible = function(elem){
|
||||||
|
return !jQuery.expr.filters.hidden(elem);
|
||||||
|
};
|
||||||
|
}
|
|
@ -420,3 +420,11 @@ jQuery.extend( jQuery.fx, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||||
|
jQuery.expr.filters.animated = function(elem){
|
||||||
|
return jQuery.grep(jQuery.timers, function(fn){
|
||||||
|
return elem === fn.elem;
|
||||||
|
}).length;
|
||||||
|
};
|
||||||
|
}
|
|
@ -333,7 +333,7 @@ jQuery.each({
|
||||||
jQuery.each({
|
jQuery.each({
|
||||||
// keepData is for internal use only--do not document
|
// keepData is for internal use only--do not document
|
||||||
remove: function( selector, keepData ) {
|
remove: function( selector, keepData ) {
|
||||||
if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) {
|
if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
|
||||||
if ( !keepData && this.nodeType === 1 ) {
|
if ( !keepData && this.nodeType === 1 ) {
|
||||||
cleanData( this.getElementsByTagName("*") );
|
cleanData( this.getElementsByTagName("*") );
|
||||||
cleanData( [ this ] );
|
cleanData( [ this ] );
|
||||||
|
|
|
@ -998,67 +998,6 @@ var posProcess = function(selector, context){
|
||||||
jQuery.find = Sizzle;
|
jQuery.find = Sizzle;
|
||||||
jQuery.expr = Sizzle.selectors;
|
jQuery.expr = Sizzle.selectors;
|
||||||
jQuery.expr[":"] = jQuery.expr.filters;
|
jQuery.expr[":"] = jQuery.expr.filters;
|
||||||
|
|
||||||
Sizzle.selectors.filters.hidden = function(elem){
|
|
||||||
var width = elem.offsetWidth, height = elem.offsetHeight,
|
|
||||||
force = /^tr$/i.test( elem.nodeName ); // ticket #4512
|
|
||||||
return ( width === 0 && height === 0 && !force ) ?
|
|
||||||
true :
|
|
||||||
( width !== 0 && height !== 0 && !force ) ?
|
|
||||||
false :
|
|
||||||
!!( jQuery.curCSS(elem, "display") === "none" );
|
|
||||||
};
|
|
||||||
|
|
||||||
Sizzle.selectors.filters.visible = function(elem){
|
|
||||||
return !Sizzle.selectors.filters.hidden(elem);
|
|
||||||
};
|
|
||||||
|
|
||||||
Sizzle.selectors.filters.animated = function(elem){
|
|
||||||
return jQuery.grep(jQuery.timers, function(fn){
|
|
||||||
return elem === fn.elem;
|
|
||||||
}).length;
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) {
|
|
||||||
if ( not ) {
|
|
||||||
expr = ":not(" + expr + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
return Sizzle.matches(expr, elems);
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.dir = function( elem, dir ){
|
|
||||||
var matched = [], cur = elem[dir];
|
|
||||||
while ( cur && cur != document ) {
|
|
||||||
if ( cur.nodeType == 1 )
|
|
||||||
matched.push( cur );
|
|
||||||
cur = cur[dir];
|
|
||||||
}
|
|
||||||
return matched;
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.nth = function(cur, result, dir, elem){
|
|
||||||
result = result || 1;
|
|
||||||
var num = 0;
|
|
||||||
|
|
||||||
for ( ; cur; cur = cur[dir] )
|
|
||||||
if ( cur.nodeType == 1 && ++num == result )
|
|
||||||
break;
|
|
||||||
|
|
||||||
return cur;
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.sibling = function(n, elem){
|
|
||||||
var r = [];
|
|
||||||
|
|
||||||
for ( ; n; n = n.nextSibling ) {
|
|
||||||
if ( n.nodeType == 1 && n != elem )
|
|
||||||
r.push( n );
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery.unique = Sizzle.uniqueSort;
|
jQuery.unique = Sizzle.uniqueSort;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,8 +10,8 @@ var winnow = function( elements, qualifier, keep ) {
|
||||||
} else if( typeof qualifier === "string" ) {
|
} else if( typeof qualifier === "string" ) {
|
||||||
var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 });
|
var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 });
|
||||||
|
|
||||||
if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep);
|
if(isSimple.test( qualifier )) return jQuery.filter(qualifier, filtered, !keep);
|
||||||
else qualifier = jQuery.multiFilter( qualifier, elements );
|
else qualifier = jQuery.filter( qualifier, elements );
|
||||||
}
|
}
|
||||||
|
|
||||||
return jQuery.grep(elements, function(elem, i) {
|
return jQuery.grep(elements, function(elem, i) {
|
||||||
|
@ -128,7 +128,7 @@ jQuery.each({
|
||||||
var ret = jQuery.map( this, fn );
|
var ret = jQuery.map( this, fn );
|
||||||
|
|
||||||
if ( selector && typeof selector === "string" ) {
|
if ( selector && typeof selector === "string" ) {
|
||||||
ret = jQuery.multiFilter( selector, ret );
|
ret = jQuery.filter( selector, ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = this.length > 1 ? jQuery.unique( ret ) : ret;
|
ret = this.length > 1 ? jQuery.unique( ret ) : ret;
|
||||||
|
@ -140,3 +140,49 @@ jQuery.each({
|
||||||
return this.pushStack( ret, name, selector );
|
return this.pushStack( ret, name, selector );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery.extend({
|
||||||
|
filter: function( expr, elems, not ) {
|
||||||
|
if ( not ) {
|
||||||
|
expr = ":not(" + expr + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
return jQuery.find.matches(expr, elems);
|
||||||
|
},
|
||||||
|
|
||||||
|
dir: function( elem, dir ) {
|
||||||
|
var matched = [], cur = elem[dir];
|
||||||
|
while ( cur && cur.nodeType !== 9 ) {
|
||||||
|
if ( cur.nodeType === 1 ) {
|
||||||
|
matched.push( cur );
|
||||||
|
}
|
||||||
|
cur = cur[dir];
|
||||||
|
}
|
||||||
|
return matched;
|
||||||
|
},
|
||||||
|
|
||||||
|
nth: function( cur, result, dir, elem ) {
|
||||||
|
result = result || 1;
|
||||||
|
var num = 0;
|
||||||
|
|
||||||
|
for ( ; cur; cur = cur[dir] ) {
|
||||||
|
if ( cur.nodeType === 1 && ++num === result ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cur;
|
||||||
|
},
|
||||||
|
|
||||||
|
sibling: function( n, elem ) {
|
||||||
|
var r = [];
|
||||||
|
|
||||||
|
for ( ; n; n = n.nextSibling ) {
|
||||||
|
if ( n.nodeType === 1 && n !== elem ) {
|
||||||
|
r.push( n );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue