source: trip-planner-front/node_modules/css-tree/lib/syntax/node/PseudoClassSelector.js@ 6a3a178

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

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1var TYPE = require('../../tokenizer').TYPE;
2
3var IDENT = TYPE.Ident;
4var FUNCTION = TYPE.Function;
5var COLON = TYPE.Colon;
6var RIGHTPARENTHESIS = TYPE.RightParenthesis;
7
8// : [ <ident> | <function-token> <any-value>? ) ]
9module.exports = {
10 name: 'PseudoClassSelector',
11 structure: {
12 name: String,
13 children: [['Raw'], null]
14 },
15 parse: function() {
16 var start = this.scanner.tokenStart;
17 var children = null;
18 var name;
19 var nameLowerCase;
20
21 this.eat(COLON);
22
23 if (this.scanner.tokenType === FUNCTION) {
24 name = this.consumeFunctionName();
25 nameLowerCase = name.toLowerCase();
26
27 if (this.pseudo.hasOwnProperty(nameLowerCase)) {
28 this.scanner.skipSC();
29 children = this.pseudo[nameLowerCase].call(this);
30 this.scanner.skipSC();
31 } else {
32 children = this.createList();
33 children.push(
34 this.Raw(this.scanner.tokenIndex, null, false)
35 );
36 }
37
38 this.eat(RIGHTPARENTHESIS);
39 } else {
40 name = this.consume(IDENT);
41 }
42
43 return {
44 type: 'PseudoClassSelector',
45 loc: this.getLocation(start, this.scanner.tokenStart),
46 name: name,
47 children: children
48 };
49 },
50 generate: function(node) {
51 this.chunk(':');
52 this.chunk(node.name);
53
54 if (node.children !== null) {
55 this.chunk('(');
56 this.children(node);
57 this.chunk(')');
58 }
59 },
60 walkContext: 'function'
61};
Note: See TracBrowser for help on using the repository browser.