first commit
This commit is contained in:
73
build/node_modules/css-tree/lib/syntax/node/MediaFeature.js
generated
vendored
Normal file
73
build/node_modules/css-tree/lib/syntax/node/MediaFeature.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
var TYPE = require('../../tokenizer').TYPE;
|
||||
|
||||
var IDENTIFIER = TYPE.Identifier;
|
||||
var NUMBER = TYPE.Number;
|
||||
var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
||||
var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
||||
var COLON = TYPE.Colon;
|
||||
var SOLIDUS = TYPE.Solidus;
|
||||
|
||||
module.exports = {
|
||||
name: 'MediaFeature',
|
||||
structure: {
|
||||
name: String,
|
||||
value: ['Identifier', 'Number', 'Dimension', 'Ratio', null]
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var name;
|
||||
var value = null;
|
||||
|
||||
this.scanner.eat(LEFTPARENTHESIS);
|
||||
this.scanner.skipSC();
|
||||
|
||||
name = this.scanner.consume(IDENTIFIER);
|
||||
this.scanner.skipSC();
|
||||
|
||||
if (this.scanner.tokenType !== RIGHTPARENTHESIS) {
|
||||
this.scanner.eat(COLON);
|
||||
this.scanner.skipSC();
|
||||
|
||||
switch (this.scanner.tokenType) {
|
||||
case NUMBER:
|
||||
if (this.scanner.lookupType(1) === IDENTIFIER) {
|
||||
value = this.Dimension();
|
||||
} else if (this.scanner.lookupNonWSType(1) === SOLIDUS) {
|
||||
value = this.Ratio();
|
||||
} else {
|
||||
value = this.Number();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IDENTIFIER:
|
||||
value = this.Identifier();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
this.scanner.error('Number, dimension, ratio or identifier is expected');
|
||||
}
|
||||
|
||||
this.scanner.skipSC();
|
||||
}
|
||||
|
||||
this.scanner.eat(RIGHTPARENTHESIS);
|
||||
|
||||
return {
|
||||
type: 'MediaFeature',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
name: name,
|
||||
value: value
|
||||
};
|
||||
},
|
||||
generate: function(processChunk, node) {
|
||||
processChunk('(');
|
||||
processChunk(node.name);
|
||||
if (node.value !== null) {
|
||||
processChunk(':');
|
||||
this.generate(processChunk, node.value);
|
||||
}
|
||||
processChunk(')');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user