fix writable being set on accessors

This commit is contained in:
Sebastian McKenzie 2015-01-11 04:55:27 +11:00
parent 24616fa08a
commit 82aa2686f9
8 changed files with 7 additions and 11 deletions

View File

@ -141,11 +141,11 @@ Class.prototype.buildBody = function () {
var staticProps;
if (this.hasInstanceMutators) {
instanceProps = util.buildDefineProperties(this.instanceMutatorMap, true);
instanceProps = util.buildDefineProperties(this.instanceMutatorMap);
}
if (this.hasStaticMutators) {
staticProps = util.buildDefineProperties(this.staticMutatorMap, true);
staticProps = util.buildDefineProperties(this.staticMutatorMap);
}
if (instanceProps || staticProps) {

View File

@ -93,7 +93,7 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, computed, method) {
map[kind] = method;
};
exports.buildDefineProperties = function (mutatorMap, writable) {
exports.buildDefineProperties = function (mutatorMap) {
var objExpr = t.objectExpression([]);
_.each(mutatorMap, function (map) {
@ -101,7 +101,10 @@ exports.buildDefineProperties = function (mutatorMap, writable) {
var propNode = t.property("init", map._key, mapNode, map._computed);
if (writable) map.writable = t.literal(true);
if (!map.get && !map.set) {
map.writable = t.literal(true);
}
map.enumerable = t.literal(true);
map.configurable = t.literal(true);

View File

@ -16,7 +16,6 @@ var Test = (function () {
set: function (val) {
this._test = val;
},
writable: true,
enumerable: true,
configurable: true
}

View File

@ -13,7 +13,6 @@ var Test = (function () {
get: function () {
return 5 + 5;
},
writable: true,
enumerable: true,
configurable: true
}

View File

@ -13,7 +13,6 @@ var Test = (function () {
set: function (val) {
this._test = val;
},
writable: true,
enumerable: true,
configurable: true
}

View File

@ -14,7 +14,6 @@ var A = (function () {
b: {
get: function () {},
set: function (b) {},
writable: true,
enumerable: true,
configurable: true
}

View File

@ -22,7 +22,6 @@ var Foo = (function () {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
},
writable: true,
enumerable: true,
configurable: true
}
@ -30,7 +29,6 @@ var Foo = (function () {
get: function () {
return _defineProperty(this, bar, complex())[bar];
},
writable: true,
enumerable: true,
configurable: true
}));

View File

@ -13,7 +13,6 @@ var Test = (function () {
get: function () {
throw new Error("wow");
},
writable: true,
enumerable: true,
configurable: true
}