Urara-Blog/node_modules/.pnpm-store/v3/files/21/f3228fdf89de53d6994cf133454418d3c1e2a4086c9dbda79706533c5df5f75113def43fc4bcf30a53b18cd13a4b989048d77658727aba1c68af7e019b25b1
2022-08-14 01:14:53 +08:00

61 lines
1.6 KiB
Text

var TYPE = require('../../tokenizer').TYPE;
var IDENT = TYPE.Ident;
var FUNCTION = TYPE.Function;
var COLON = TYPE.Colon;
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
// : [ <ident> | <function-token> <any-value>? ) ]
module.exports = {
name: 'PseudoClassSelector',
structure: {
name: String,
children: [['Raw'], null]
},
parse: function() {
var start = this.scanner.tokenStart;
var children = null;
var name;
var nameLowerCase;
this.eat(COLON);
if (this.scanner.tokenType === FUNCTION) {
name = this.consumeFunctionName();
nameLowerCase = name.toLowerCase();
if (this.pseudo.hasOwnProperty(nameLowerCase)) {
this.scanner.skipSC();
children = this.pseudo[nameLowerCase].call(this);
this.scanner.skipSC();
} else {
children = this.createList();
children.push(
this.Raw(this.scanner.tokenIndex, null, false)
);
}
this.eat(RIGHTPARENTHESIS);
} else {
name = this.consume(IDENT);
}
return {
type: 'PseudoClassSelector',
loc: this.getLocation(start, this.scanner.tokenStart),
name: name,
children: children
};
},
generate: function(node) {
this.chunk(':');
this.chunk(node.name);
if (node.children !== null) {
this.chunk('(');
this.children(node);
this.chunk(')');
}
},
walkContext: 'function'
};