Selector.js 790 B

1234567891011121314151617181920212223242526272829303132
  1. module.exports = {
  2. name: 'Selector',
  3. structure: {
  4. children: [[
  5. 'TypeSelector',
  6. 'IdSelector',
  7. 'ClassSelector',
  8. 'AttributeSelector',
  9. 'PseudoClassSelector',
  10. 'PseudoElementSelector',
  11. 'Combinator',
  12. 'WhiteSpace'
  13. ]]
  14. },
  15. parse: function() {
  16. var children = this.readSequence(this.scope.Selector);
  17. // nothing were consumed
  18. if (this.getFirstListNode(children) === null) {
  19. this.error('Selector is expected');
  20. }
  21. return {
  22. type: 'Selector',
  23. loc: this.getLocationFromList(children),
  24. children: children
  25. };
  26. },
  27. generate: function(node) {
  28. this.children(node);
  29. }
  30. };