ClassSelector.js 673 B

1234567891011121314151617181920212223242526272829
  1. var TYPE = require('../../tokenizer').TYPE;
  2. var IDENT = TYPE.Ident;
  3. var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
  4. // '.' ident
  5. module.exports = {
  6. name: 'ClassSelector',
  7. structure: {
  8. name: String
  9. },
  10. parse: function() {
  11. if (!this.scanner.isDelim(FULLSTOP)) {
  12. this.error('Full stop is expected');
  13. }
  14. this.scanner.next();
  15. return {
  16. type: 'ClassSelector',
  17. loc: this.getLocation(this.scanner.tokenStart - 1, this.scanner.tokenEnd),
  18. name: this.consume(IDENT)
  19. };
  20. },
  21. generate: function(node) {
  22. this.chunk('.');
  23. this.chunk(node.name);
  24. }
  25. };