Spaces:
Configuration error
Configuration error
File size: 1,473 Bytes
a053984 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import {
Ident,
Function as FunctionToken,
Colon,
RightParenthesis
} from '../../tokenizer/index.js';
export const name = 'PseudoClassSelector';
export const walkContext = 'function';
export const structure = {
name: String,
children: [['Raw'], null]
};
// : [ <ident> | <function-token> <any-value>? ) ]
export function parse() {
const start = this.tokenStart;
let children = null;
let name;
let nameLowerCase;
this.eat(Colon);
if (this.tokenType === FunctionToken) {
name = this.consumeFunctionName();
nameLowerCase = name.toLowerCase();
if (hasOwnProperty.call(this.pseudo, nameLowerCase)) {
this.skipSC();
children = this.pseudo[nameLowerCase].call(this);
this.skipSC();
} else {
children = this.createList();
children.push(
this.Raw(this.tokenIndex, null, false)
);
}
this.eat(RightParenthesis);
} else {
name = this.consume(Ident);
}
return {
type: 'PseudoClassSelector',
loc: this.getLocation(start, this.tokenStart),
name,
children
};
}
export function generate(node) {
this.token(Colon, ':');
if (node.children === null) {
this.token(Ident, node.name);
} else {
this.token(FunctionToken, node.name + '(');
this.children(node);
this.token(RightParenthesis, ')');
}
}
|