MCPcopy Create free account
hub / github.com/components/jquery / tokenize

Function tokenize

jquery.js:674–744  ·  view source on GitHub ↗
( selector, parseOnly )

Source from the content-addressed store, hash-verified

672var tokenCache = createCache();
673
674function tokenize( selector, parseOnly ) {
675 var matched, match, tokens, type,
676 soFar, groups, preFilters,
677 cached = tokenCache[ selector + " " ];
678
679 if ( cached ) {
680 return parseOnly ? 0 : cached.slice( 0 );
681 }
682
683 soFar = selector;
684 groups = [];
685 preFilters = jQuery.expr.preFilter;
686
687 while ( soFar ) {
688
689 // Comma and first run
690 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
691 if ( match ) {
692
693 // Don't consume trailing commas as valid
694 soFar = soFar.slice( match[ 0 ].length ) || soFar;
695 }
696 groups.push( ( tokens = [] ) );
697 }
698
699 matched = false;
700
701 // Combinators
702 if ( ( match = rleadingCombinator.exec( soFar ) ) ) {
703 matched = match.shift();
704 tokens.push( {
705 value: matched,
706
707 // Cast descendant combinators to space
708 type: match[ 0 ].replace( rtrimCSS, " " )
709 } );
710 soFar = soFar.slice( matched.length );
711 }
712
713 // Filters
714 for ( type in filterMatchExpr ) {
715 if ( ( match = jQuery.expr.match[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
716 ( match = preFilters[ type ]( match ) ) ) ) {
717 matched = match.shift();
718 tokens.push( {
719 value: matched,
720 type: type,
721 matches: match
722 } );
723 soFar = soFar.slice( matched.length );
724 }
725 }
726
727 if ( !matched ) {
728 break;
729 }
730 }
731

Callers 4

jquery.jsFile · 0.70
findFunction · 0.70
compileFunction · 0.70
selectFunction · 0.70

Calls 1

selectorErrorFunction · 0.70

Tested by

no test coverage detected