Cast boolean and null before creating literal expression

This commit is contained in:
Tim Schaub
2013-06-11 11:07:50 -06:00
parent ce67aa2617
commit 3643ea164f
2 changed files with 43 additions and 5 deletions

View File

@@ -404,10 +404,14 @@ ol.expression.Parser.prototype.parsePrimaryExpression_ = function(lexer) {
if (type === ol.expression.TokenType.IDENTIFIER) {
expr = this.createIdentifier_(/** @type {string} */ (token.value));
} else if (type === ol.expression.TokenType.STRING_LITERAL ||
type === ol.expression.TokenType.NUMERIC_LITERAL ||
type === ol.expression.TokenType.BOOLEAN_LITERAL ||
type === ol.expression.TokenType.NULL_LITERAL) {
type === ol.expression.TokenType.NUMERIC_LITERAL) {
// numeric and string literals are already the correct type
expr = this.createLiteral_(token.value);
} else if (type === ol.expression.TokenType.BOOLEAN_LITERAL) {
// because booleans are valid member properties, tokens are still string
expr = this.createLiteral_(token.value === 'true');
} else if (type === ol.expression.TokenType.NULL_LITERAL) {
expr = this.createLiteral_(null);
} else {
throw new Error('Unexpected token: ' + token.value);
}