force computed property on number literal property
This commit is contained in:
parent
16024242b0
commit
ed833be34a
@ -1,5 +1,6 @@
|
|||||||
var util = require("../../util");
|
var util = require("../../util");
|
||||||
var t = require("../../types");
|
var t = require("../../types");
|
||||||
|
var _ = require("lodash");
|
||||||
|
|
||||||
exports.UnaryExpression = function (node, print) {
|
exports.UnaryExpression = function (node, print) {
|
||||||
var hasSpace = /[a-z]$/.test(node.operator);
|
var hasSpace = /[a-z]$/.test(node.operator);
|
||||||
@ -103,7 +104,12 @@ exports.MemberExpression = function (node, print) {
|
|||||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.computed) {
|
var computed = node.computed;
|
||||||
|
if (t.isLiteral(node.property) && _.isNumber(node.property.value)) {
|
||||||
|
computed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (computed) {
|
||||||
this.push("[");
|
this.push("[");
|
||||||
print(node.property);
|
print(node.property);
|
||||||
this.push("]");
|
this.push("]");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user