shorthair
娜娜,你知道吗,你就像一直野猫,活的高傲又自由,却背负着无法痊愈的伤口。
粗线条的我,曾经认为这样很酷,却不知道那有多么的痛。
by NANA
使用文档
shorthair是什么
shorthair是一个严格遵循w3c关于css3-selector的文法约定(@w3c selector grammar)的语法解析器,基于@jcon项目实现。
shorthair的使用示例
/** * example * * selector 1: div.class#id * * selector 2: a[link^="http://"] * * selector 3: ns|section>ns|*[ns|link^="http"] * * selector 4: ul.news>li:nth-child(2n-1) * * selector 5: *.content>ns|div a[link^="http://"]:not([target=_blank]):first-child * * * */{ var shorthair = ; //对 "div.class#id" 的解析 var selector = 'div.class#id'; var selParseTree = shorthair; var selAstTree = selParseTree; JSON === JSON ? console : console; //对 "a[link^="http://"]" 的解析 var selector = 'a[link^="http://"]'; var selParseTree = shorthair; var selAstTree = selParseTree; JSON === JSON ? console : console; //对 "ns|section>ns|*[ns|link^="http://"]" 的解析 var selector = 'ns|section>ns|*[ns|link^="http://"]'; var selParseTree = shorthair; var selAstTree = selParseTree; JSON === JSON ? console : console; //对 "ul.news>li:nth-child(2n-1)" 的解析 var selector = 'ul.news>li:nth-child(2n-1)'; var selParseTree = shorthair; var selAstTree = selParseTree; JSON === JSON ? console : console; //对 "*.content>ns|div a[link^="http://"]:not([target=_blank]):first-child" 的解析 var selector = '*.content>ns|div a[link^="http://"]:not([target=_blank]):first-child'; var selParseTree = shorthair; var selAstTree = selParseTree; JSON === JSON ? console : console; };
关于作者
cc,曾就职于百度,奇虎360,目前就职于阿里巴巴集团无线事业部。