css-selector-tokenizer, 解析和 stringifies CSS选择器

分享于 

3分钟阅读

GitHub

  繁體 雙語
Parses and stringifies CSS selectors.
  • 源代码名称:css-selector-tokenizer
  • 源代码网址:http://www.github.com/css-modules/css-selector-tokenizer
  • css-selector-tokenizer源代码文档
  • css-selector-tokenizer源代码下载
  • Git URL:
    git://www.github.com/css-modules/css-selector-tokenizer.git
    Git Clone代码到本地:
    git clone http://www.github.com/css-modules/css-selector-tokenizer
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/css-modules/css-selector-tokenizer
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    CSS模块:CSS选择器标记器

    解析和 stringifies CSS选择器。

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

    建筑

    
    npm install
    
    
    npm test
    
    
    
    

    Build Status

    • 行:Coverage Status
    • 语句:codecov.io

    插件开发

    • npm autotest 将监视 libtest 以进行更改和重新测试

    许可证

    MIT

    感谢

    • 标记 Dalgleish
    • Glen Maddern
    • Bedford

    ,Koppers,2015.


    PAR  str  parse  Select  String  选择器  
    相关文章