first commit
This commit is contained in:
45
build/node_modules/css-tree/lib/syntax/node/Dimension.js
generated
vendored
Normal file
45
build/node_modules/css-tree/lib/syntax/node/Dimension.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
var NUMBER = require('../../tokenizer').TYPE.Number;
|
||||
|
||||
// special reader for units to avoid adjoined IE hacks (i.e. '1px\9')
|
||||
function readUnit(scanner) {
|
||||
var unit = scanner.getTokenValue();
|
||||
var backSlashPos = unit.indexOf('\\');
|
||||
|
||||
if (backSlashPos > 0) {
|
||||
// patch token offset
|
||||
scanner.tokenStart += backSlashPos;
|
||||
|
||||
// return part before backslash
|
||||
return unit.substring(0, backSlashPos);
|
||||
}
|
||||
|
||||
// no backslash in unit name
|
||||
scanner.next();
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
// number ident
|
||||
module.exports = {
|
||||
name: 'Dimension',
|
||||
structure: {
|
||||
value: String,
|
||||
unit: String
|
||||
},
|
||||
parse: function() {
|
||||
var start = this.scanner.tokenStart;
|
||||
var value = this.scanner.consume(NUMBER);
|
||||
var unit = readUnit(this.scanner);
|
||||
|
||||
return {
|
||||
type: 'Dimension',
|
||||
loc: this.getLocation(start, this.scanner.tokenStart),
|
||||
value: value,
|
||||
unit: unit
|
||||
};
|
||||
},
|
||||
generate: function(processChunk, node) {
|
||||
processChunk(node.value);
|
||||
processChunk(node.unit);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user