aboutsummaryrefslogtreecommitdiffstats
path: root/src/traversing.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-10-26 18:07:57 -0400
committerJohn Resig <jeresig@gmail.com>2009-10-26 18:07:57 -0400
commitbbffc99f7c60d42d4286786dfd6a43aa31d62ae2 (patch)
tree58bd5ac0bebdd51a7b04275edf4f71d0db3f688a /src/traversing.js
parentb7ccc58afec145120e8e675cf8fd30e9ea97f2a3 (diff)
downloadjquery-bbffc99f7c60d42d4286786dfd6a43aa31d62ae2.tar.gz
jquery-bbffc99f7c60d42d4286786dfd6a43aa31d62ae2.zip
Moved a bunch of methods out of the jQuery-specific Sizzle code into more-appropriate files, in jQuery itself.
Diffstat (limited to 'src/traversing.js')
-rw-r--r--src/traversing.js52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/traversing.js b/src/traversing.js
index 8f1e5eb50..583a303d6 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -10,8 +10,8 @@ var winnow = function( elements, qualifier, keep ) {
} else if( typeof qualifier === "string" ) {
var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 });
- if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep);
- else qualifier = jQuery.multiFilter( qualifier, elements );
+ if(isSimple.test( qualifier )) return jQuery.filter(qualifier, filtered, !keep);
+ else qualifier = jQuery.filter( qualifier, elements );
}
return jQuery.grep(elements, function(elem, i) {
@@ -128,7 +128,7 @@ jQuery.each({
var ret = jQuery.map( this, fn );
if ( selector && typeof selector === "string" ) {
- ret = jQuery.multiFilter( selector, ret );
+ ret = jQuery.filter( selector, ret );
}
ret = this.length > 1 ? jQuery.unique( ret ) : ret;
@@ -140,3 +140,49 @@ jQuery.each({
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;
+ }
+}); \ No newline at end of file