MCPcopy Index your code
hub / github.com/jquery/jquery / tokenize

Function tokenize

dist-module/jquery.factory.slim.module.js:665–735  ·  view source on GitHub ↗
( selector, parseOnly )

Source from the content-addressed store, hash-verified

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

Callers 4

jQueryFactoryWrapperFunction · 0.70
findFunction · 0.70
compileFunction · 0.70
selectFunction · 0.70

Calls 1

selectorErrorFunction · 0.70

Tested by

no test coverage detected