[d565449] | 1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
| 2 |
|
---|
| 3 | var DELIM = TYPE.Delim;
|
---|
| 4 | var IDENT = TYPE.Ident;
|
---|
| 5 | var DIMENSION = TYPE.Dimension;
|
---|
| 6 | var PERCENTAGE = TYPE.Percentage;
|
---|
| 7 | var NUMBER = TYPE.Number;
|
---|
| 8 | var HASH = TYPE.Hash;
|
---|
| 9 | var COLON = TYPE.Colon;
|
---|
| 10 | var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
|
---|
| 11 | var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
|
---|
| 12 | var ASTERISK = 0x002A; // U+002A ASTERISK (*)
|
---|
| 13 | var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
|
---|
| 14 | var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
|
---|
| 15 | var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
|
---|
| 16 | var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
|
---|
| 17 | var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
|
---|
| 18 | var TILDE = 0x007E; // U+007E TILDE (~)
|
---|
| 19 |
|
---|
| 20 | function getNode(context) {
|
---|
| 21 | switch (this.scanner.tokenType) {
|
---|
| 22 | case LEFTSQUAREBRACKET:
|
---|
| 23 | return this.AttributeSelector();
|
---|
| 24 |
|
---|
| 25 | case HASH:
|
---|
| 26 | return this.IdSelector();
|
---|
| 27 |
|
---|
| 28 | case COLON:
|
---|
| 29 | if (this.scanner.lookupType(1) === COLON) {
|
---|
| 30 | return this.PseudoElementSelector();
|
---|
| 31 | } else {
|
---|
| 32 | return this.PseudoClassSelector();
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | case IDENT:
|
---|
| 36 | return this.TypeSelector();
|
---|
| 37 |
|
---|
| 38 | case NUMBER:
|
---|
| 39 | case PERCENTAGE:
|
---|
| 40 | return this.Percentage();
|
---|
| 41 |
|
---|
| 42 | case DIMENSION:
|
---|
| 43 | // throws when .123ident
|
---|
| 44 | if (this.scanner.source.charCodeAt(this.scanner.tokenStart) === FULLSTOP) {
|
---|
| 45 | this.error('Identifier is expected', this.scanner.tokenStart + 1);
|
---|
| 46 | }
|
---|
| 47 | break;
|
---|
| 48 |
|
---|
| 49 | case DELIM:
|
---|
| 50 | var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
|
---|
| 51 |
|
---|
| 52 | switch (code) {
|
---|
| 53 | case PLUSSIGN:
|
---|
| 54 | case GREATERTHANSIGN:
|
---|
| 55 | case TILDE:
|
---|
| 56 | context.space = null;
|
---|
| 57 | context.ignoreWSAfter = true;
|
---|
| 58 | return this.Combinator();
|
---|
| 59 |
|
---|
| 60 | case SOLIDUS: // /deep/
|
---|
| 61 | return this.Combinator();
|
---|
| 62 |
|
---|
| 63 | case FULLSTOP:
|
---|
| 64 | return this.ClassSelector();
|
---|
| 65 |
|
---|
| 66 | case ASTERISK:
|
---|
| 67 | case VERTICALLINE:
|
---|
| 68 | return this.TypeSelector();
|
---|
| 69 |
|
---|
| 70 | case NUMBERSIGN:
|
---|
| 71 | return this.IdSelector();
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | break;
|
---|
| 75 | }
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | module.exports = {
|
---|
| 79 | getNode: getNode
|
---|
| 80 | };
|
---|