diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2013-09-09 19:13:01 -0500 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2013-09-09 22:51:11 -0500 |
commit | 2f627494f28c08e5bba3c32d6c9d9167503322fc (patch) | |
tree | f05e01ccebcf4d8c9db7475083d1d99359cc0402 /src/traversing.js | |
parent | 6c573391121c61b6e3797005c0fa932ae94ef4d1 (diff) | |
download | jquery-2f627494f28c08e5bba3c32d6c9d9167503322fc.tar.gz jquery-2f627494f28c08e5bba3c32d6c9d9167503322fc.zip |
Separate jQuery.fn.init into its own module (for lighter core dependencies across all modules). Restore proper support property for effects.
Conflicts:
src/attributes/classes.js
src/core.js
src/manipulation.js
src/traversing.js
Diffstat (limited to 'src/traversing.js')
-rw-r--r-- | src/traversing.js | 100 |
1 files changed, 5 insertions, 95 deletions
diff --git a/src/traversing.js b/src/traversing.js index 4f3bba0fc..02ea249fe 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -1,11 +1,12 @@ define([ "./core", + "./traversing/var/rneedsContext", + "./core/init", + "./traversing/findFilter", "./selector" -], function( jQuery ) { +], function( jQuery, rneedsContext ) { -var isSimple = /^.[^:#\[\.,]*$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - rneedsContext = jQuery.expr.match.needsContext, +var rparentsprev = /^(?:parents|prev(?:Until|All))/, // methods guaranteed to produce a unique set when starting from a unique set guaranteedUnique = { children: true, @@ -14,51 +15,7 @@ var isSimple = /^.[^:#\[\.,]*$/, prev: true }; -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, not ) { - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep( elements, function( elem, i ) { - /* jshint -W018 */ - return !!qualifier.call( elem, i, elem ) !== not; - }); - - } - - if ( qualifier.nodeType ) { - return jQuery.grep( elements, function( elem ) { - return ( elem === qualifier ) !== not; - }); - - } - - if ( typeof qualifier === "string" ) { - if ( isSimple.test( qualifier ) ) { - return jQuery.filter( qualifier, elements, not ); - } - - qualifier = jQuery.filter( qualifier, elements ); - } - - return jQuery.grep( elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; - }); -} - jQuery.extend({ - filter: function( expr, elems, not ) { - var elem = elems[ 0 ]; - - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 && elem.nodeType === 1 ? - jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : - jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { - return elem.nodeType === 1; - })); - }, - dir: function( elem, dir, until ) { var matched = [], cur = elem[ dir ]; @@ -86,32 +43,6 @@ jQuery.extend({ }); jQuery.fn.extend({ - find: function( selector ) { - var i, - ret = [], - self = this, - len = self.length; - - if ( typeof selector !== "string" ) { - return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }) ); - } - - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, self[ i ], ret ); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); - ret.selector = this.selector ? this.selector + " " + selector : selector; - return ret; - }, - has: function( target ) { var i, targets = jQuery( target, this ), @@ -126,27 +57,6 @@ jQuery.fn.extend({ }); }, - not: function( selector ) { - return this.pushStack( winnow(this, selector || [], true) ); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector || [], false) ); - }, - - is: function( selector ) { - return !!winnow( - this, - - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === "string" && rneedsContext.test( selector ) ? - jQuery( selector ) : - selector || [], - false - ).length; - }, - closest: function( selectors, context ) { var cur, i = 0, |