Search code examples
javascriptjquerytokenizesizzle

What does `Sizzle.tokenize` do


Sizzle.tokenize is undocumented and there is no comments in the source. What does it do?

The code


Solution

  • It split the string css selector. E

    Example: "div > button.btn", if you use this string to tokenize, Sizzle.tokenize returns an array with arrays as item and within that array item there is an object that has property type and value. In example above the results will be [[{type: "tag",value: "div"},{type: ">",value: " > "},{type: "tag",value: "button"},{type: "class",value: "btn"}]].

    If you use another selector with comma it adds new array inside the parent array.