From c87f85815bfc4da012c657e30b23b940794e2120 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 25 Jun 2015 23:04:17 +0100 Subject: [PATCH] used filter rather than setting init properties to null in properties.computed transformer - fixes #1831 --- .../transformers/es6/properties.computed.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/babel/transformation/transformers/es6/properties.computed.js b/src/babel/transformation/transformers/es6/properties.computed.js index ed832e8012..b1ce1939e3 100644 --- a/src/babel/transformation/transformers/es6/properties.computed.js +++ b/src/babel/transformation/transformers/es6/properties.computed.js @@ -2,8 +2,6 @@ import * as t from "../../../types"; function loose(node, body, objId) { for (var prop of (node.properties: Array)) { - if (!prop) continue; - body.push(t.expressionStatement( t.assignmentExpression( "=", @@ -19,8 +17,6 @@ function spec(node, body, objId, initProps, file) { // otherwise use Object.defineProperty for (let prop of (node.properties: Array)) { - if (!prop) continue; - // this wont work with Object.defineProperty if (t.isLiteral(t.toComputedKey(prop), { value: "__proto__" })) { initProps.push(prop); @@ -67,17 +63,18 @@ export var visitor = { var initProps = []; var stopInits = false; - for (var i = 0; i < node.properties.length; i++) { - let prop = node.properties[i]; + node.properties = node.properties.filter(function (prop) { if (prop.computed) { stopInits = true; } if (prop.kind !== "init" || !stopInits) { initProps.push(prop); - node.properties[i] = null; + return false; + } else { + return true; } - } + }); //