\href{https://travis-ci.org/css-modules/css-selector-tokenizer}{\texttt{ }} \href{https://coveralls.io/r/css-modules/css-selector-tokenizer?branch=master}{\texttt{ }} \href{https://codecov.io/github/css-modules/css-selector-tokenizer?branch=master}{\texttt{ }}

Parses and stringifies CSS selectors.


\begin{DoxyCode}{0}
\DoxyCodeLine{import Tokenizer from "{}css-\/selector-\/tokenizer"{};}
\DoxyCodeLine{}
\DoxyCodeLine{let input = "{}a\#content.active > div::first-\/line [data-\/content], a:not(:visited)"{};}
\DoxyCodeLine{}
\DoxyCodeLine{Tokenizer.parse(input); // === expected}
\DoxyCodeLine{let expected = \{}
\DoxyCodeLine{  type: "{}selectors"{},}
\DoxyCodeLine{  nodes: [}
\DoxyCodeLine{    \{}
\DoxyCodeLine{      type: "{}selector"{},}
\DoxyCodeLine{      nodes: [}
\DoxyCodeLine{        \{ type: "{}element"{}, name: "{}a"{} \},}
\DoxyCodeLine{        \{ type: "{}id"{}, name: "{}content"{} \},}
\DoxyCodeLine{        \{ type: "{}class"{}, name: "{}active"{} \},}
\DoxyCodeLine{        \{ type: "{}operator"{}, operator: "{}>"{}, before: "{} "{}, after: "{} "{} \},}
\DoxyCodeLine{        \{ type: "{}element"{}, name: "{}div"{} \},}
\DoxyCodeLine{        \{ type: "{}pseudo-\/element"{}, name: "{}first-\/line"{} \},}
\DoxyCodeLine{        \{ type: "{}spacing"{}, value: "{} "{} \},}
\DoxyCodeLine{        \{ type: "{}attribute"{}, content: "{}data-\/content"{} \},}
\DoxyCodeLine{      ]}
\DoxyCodeLine{    \},}
\DoxyCodeLine{    \{}
\DoxyCodeLine{      type: "{}selector"{},}
\DoxyCodeLine{      nodes: [}
\DoxyCodeLine{        \{ type: "{}element"{}, name: "{}a"{} \},}
\DoxyCodeLine{        \{ type: "{}nested-\/pseudo-\/class"{}, name: "{}not"{}, nodes: [}
\DoxyCodeLine{          \{}
\DoxyCodeLine{            type: "{}selector"{},}
\DoxyCodeLine{            nodes: [}
\DoxyCodeLine{              \{ type: "{}pseudo-\/class"{}, name: "{}visited"{} \}}
\DoxyCodeLine{            ]}
\DoxyCodeLine{          \}}
\DoxyCodeLine{        ] \}}
\DoxyCodeLine{      ],}
\DoxyCodeLine{      before: "{} "{}}
\DoxyCodeLine{    \}}
\DoxyCodeLine{  ]}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{Tokenizer.stringify(expected) // === input}
\DoxyCodeLine{}
\DoxyCodeLine{// * => \{ type: "{}universal"{} \}}
\DoxyCodeLine{// foo|element = \{ type: "{}element"{}, name: "{}element"{}, namespace: "{}foo"{} \}}
\DoxyCodeLine{// *|* = \{ type: "{}universal"{}, namespace: "{}*"{} \}}
\DoxyCodeLine{// :has(h1, h2) => \{ type: "{}nested-\/pseudo-\/class"{}, name: "{}has"{}, nodes: [}
\DoxyCodeLine{//     \{}
\DoxyCodeLine{//       type: "{}selector"{},}
\DoxyCodeLine{//       nodes: [}
\DoxyCodeLine{//         \{ type: "{}element"{}, name: "{}h1"{} \}}
\DoxyCodeLine{//       ]}
\DoxyCodeLine{//     \},}
\DoxyCodeLine{//     \{}
\DoxyCodeLine{//       type: "{}selector"{},}
\DoxyCodeLine{//       nodes: [}
\DoxyCodeLine{//         \{ type: "{}element"{}, name: "{}h2"{} \}}
\DoxyCodeLine{//       ],}
\DoxyCodeLine{//       before: "{} "{}}
\DoxyCodeLine{//     \}}
\DoxyCodeLine{//   ] \} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7228}{}\doxysection{Building}\label{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7228}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install}
\DoxyCodeLine{npm test }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7229}{}\doxysection{Development}\label{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7229}

\begin{DoxyItemize}
\item {\ttfamily npm test -\/-\/ -\/w} will watch {\ttfamily lib} and {\ttfamily test} for changes and retest
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7230}{}\doxysection{License}\label{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7230}
MIT\hypertarget{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7231}{}\doxysection{With thanks}\label{md_sfcode_node_modules_css_selector_tokenizer_README_autotoc_md7231}

\begin{DoxyItemize}
\item Mark Dalgleish
\item Glen Maddern
\item Guy Bedford
\end{DoxyItemize}

\DoxyHorRuler{0}
 Tobias Koppers, 2015. 