diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index c6ea9505de..01c1ee0729 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -145,11 +145,11 @@ Class.prototype.buildBody = function () { CLASS_NAME: className }); - instanceProps = util.buildDefineProperties(this.instanceMutatorMap, protoId); + instanceProps = util.buildDefineProperties(this.instanceMutatorMap, true); } if (this.hasStaticMutators) { - staticProps = util.buildDefineProperties(this.staticMutatorMap, className); + staticProps = util.buildDefineProperties(this.staticMutatorMap, true); } if (instanceProps || staticProps) { diff --git a/lib/6to5/util.js b/lib/6to5/util.js index e96d638d21..659ec25ed5 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -93,7 +93,7 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, computed, method) { map[kind] = method; }; -exports.buildDefineProperties = function (mutatorMap) { +exports.buildDefineProperties = function (mutatorMap, writable) { var objExpr = t.objectExpression([]); _.each(mutatorMap, function (map) { @@ -101,7 +101,9 @@ exports.buildDefineProperties = function (mutatorMap) { var propNode = t.property("init", map._key, mapNode, map._computed); + if (writable) map.writable = t.literal(true); map.enumerable = t.literal(true); + map.configurable = t.literal(true); _.each(map, function (node, key) { if (key[0] === "_") return; diff --git a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js index 6d90b4abd4..e9b1e3b709 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js @@ -16,7 +16,9 @@ var Test = (function () { set: function (val) { this._test = val; }, - enumerable: true + writable: true, + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-classes/instance-getter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter/expected.js index 10922e7805..af576011f1 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter/expected.js @@ -13,7 +13,9 @@ var Test = (function () { get: function () { return 5 + 5; }, - enumerable: true + writable: true, + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-classes/instance-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-setter/expected.js index 0fb2a379ef..d713ba3a2c 100644 --- a/test/fixtures/transformation/es6-classes/instance-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-setter/expected.js @@ -13,7 +13,9 @@ var Test = (function () { set: function (val) { this._test = val; }, - enumerable: true + writable: true, + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-classes/static/expected.js b/test/fixtures/transformation/es6-classes/static/expected.js index 59c3cfd171..7f0b2e0806 100644 --- a/test/fixtures/transformation/es6-classes/static/expected.js +++ b/test/fixtures/transformation/es6-classes/static/expected.js @@ -14,7 +14,9 @@ var A = (function () { b: { get: function () {}, set: function (b) {}, - enumerable: true + writable: true, + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-property-method-assignment/computed/expected.js b/test/fixtures/transformation/es6-property-method-assignment/computed/expected.js index 5622ed391e..aa6f306654 100644 --- a/test/fixtures/transformation/es6-property-method-assignment/computed/expected.js +++ b/test/fixtures/transformation/es6-property-method-assignment/computed/expected.js @@ -18,7 +18,8 @@ var obj = Object.defineProperties({}, _defineProperty({}, x, { set: function (value) { valueSet = value; }, - enumerable: true + enumerable: true, + configurable: true })); obj.y = "foo"; obj.y === 1 && valueSet === "foo"; diff --git a/test/fixtures/transformation/es6-property-method-assignment/getter-and-setter/expected.js b/test/fixtures/transformation/es6-property-method-assignment/getter-and-setter/expected.js index a15cb74461..036772d3c9 100644 --- a/test/fixtures/transformation/es6-property-method-assignment/getter-and-setter/expected.js +++ b/test/fixtures/transformation/es6-property-method-assignment/getter-and-setter/expected.js @@ -8,6 +8,7 @@ var obj = Object.defineProperties({}, { set: function (value) { this._foo = value; }, - enumerable: true + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-property-method-assignment/getter/expected.js b/test/fixtures/transformation/es6-property-method-assignment/getter/expected.js index 41284a6062..7e898ee4a1 100644 --- a/test/fixtures/transformation/es6-property-method-assignment/getter/expected.js +++ b/test/fixtures/transformation/es6-property-method-assignment/getter/expected.js @@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, { get: function () { return 5 + 5; }, - enumerable: true + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/es6-property-method-assignment/setter/expected.js b/test/fixtures/transformation/es6-property-method-assignment/setter/expected.js index dd3cb8477f..a04867b4aa 100644 --- a/test/fixtures/transformation/es6-property-method-assignment/setter/expected.js +++ b/test/fixtures/transformation/es6-property-method-assignment/setter/expected.js @@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, { set: function (value) { this._foo = value; }, - enumerable: true + enumerable: true, + configurable: true } }); diff --git a/test/fixtures/transformation/playground/object-getter-memoization/expected.js b/test/fixtures/transformation/playground/object-getter-memoization/expected.js index ac43f9b05d..8b6a42a193 100644 --- a/test/fixtures/transformation/playground/object-getter-memoization/expected.js +++ b/test/fixtures/transformation/playground/object-getter-memoization/expected.js @@ -22,13 +22,17 @@ var Foo = (function () { get: function () { return _defineProperty(this, "bar", complex()).bar; }, - enumerable: true + writable: true, + enumerable: true, + configurable: true } }, bar, { get: function () { return _defineProperty(this, bar, complex())[bar]; }, - enumerable: true + writable: true, + enumerable: true, + configurable: true })); return Foo; @@ -39,11 +43,13 @@ var foo = Object.defineProperties({}, _defineProperty({ get: function () { return _defineProperty(this, "bar", complex()).bar; }, - enumerable: true + enumerable: true, + configurable: true } }, bar, { get: function () { return _defineProperty(this, bar, complex())[bar]; }, - enumerable: true + enumerable: true, + configurable: true })); diff --git a/test/fixtures/transformation/source-maps/class/expected.js b/test/fixtures/transformation/source-maps/class/expected.js index 43d698e530..ced471078f 100644 --- a/test/fixtures/transformation/source-maps/class/expected.js +++ b/test/fixtures/transformation/source-maps/class/expected.js @@ -13,7 +13,9 @@ var Test = (function () { get: function () { throw new Error("wow"); }, - enumerable: true + writable: true, + enumerable: true, + configurable: true } });