Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
2 |
|
---|
3 | var IDENT = TYPE.Ident;
|
---|
4 | var FUNCTION = TYPE.Function;
|
---|
5 | var COLON = TYPE.Colon;
|
---|
6 | var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
---|
7 |
|
---|
8 | // :: [ <ident> | <function-token> <any-value>? ) ]
|
---|
9 | module.exports = {
|
---|
10 | name: 'PseudoElementSelector',
|
---|
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 | this.eat(COLON);
|
---|
23 |
|
---|
24 | if (this.scanner.tokenType === FUNCTION) {
|
---|
25 | name = this.consumeFunctionName();
|
---|
26 | nameLowerCase = name.toLowerCase();
|
---|
27 |
|
---|
28 | if (this.pseudo.hasOwnProperty(nameLowerCase)) {
|
---|
29 | this.scanner.skipSC();
|
---|
30 | children = this.pseudo[nameLowerCase].call(this);
|
---|
31 | this.scanner.skipSC();
|
---|
32 | } else {
|
---|
33 | children = this.createList();
|
---|
34 | children.push(
|
---|
35 | this.Raw(this.scanner.tokenIndex, null, false)
|
---|
36 | );
|
---|
37 | }
|
---|
38 |
|
---|
39 | this.eat(RIGHTPARENTHESIS);
|
---|
40 | } else {
|
---|
41 | name = this.consume(IDENT);
|
---|
42 | }
|
---|
43 |
|
---|
44 | return {
|
---|
45 | type: 'PseudoElementSelector',
|
---|
46 | loc: this.getLocation(start, this.scanner.tokenStart),
|
---|
47 | name: name,
|
---|
48 | children: children
|
---|
49 | };
|
---|
50 | },
|
---|
51 | generate: function(node) {
|
---|
52 | this.chunk('::');
|
---|
53 | this.chunk(node.name);
|
---|
54 |
|
---|
55 | if (node.children !== null) {
|
---|
56 | this.chunk('(');
|
---|
57 | this.children(node);
|
---|
58 | this.chunk(')');
|
---|
59 | }
|
---|
60 | },
|
---|
61 | walkContext: 'function'
|
---|
62 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.