source: trip-planner-front/node_modules/css-tree/lib/syntax/scope/selector.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1var TYPE = require('../../tokenizer').TYPE;
2
3var DELIM = TYPE.Delim;
4var IDENT = TYPE.Ident;
5var DIMENSION = TYPE.Dimension;
6var PERCENTAGE = TYPE.Percentage;
7var NUMBER = TYPE.Number;
8var HASH = TYPE.Hash;
9var COLON = TYPE.Colon;
10var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
11var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
12var ASTERISK = 0x002A; // U+002A ASTERISK (*)
13var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
14var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
15var FULLSTOP = 0x002E; // U+002E FULL STOP (.)
16var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
17var VERTICALLINE = 0x007C; // U+007C VERTICAL LINE (|)
18var TILDE = 0x007E; // U+007E TILDE (~)
19
20function 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
78module.exports = {
79 getNode: getNode
80};
Note: See TracBrowser for help on using the repository browser.