add configurable and writable property to defined properties
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -16,7 +16,9 @@ var Test = (function () {
|
||||
set: function (val) {
|
||||
this._test = val;
|
||||
},
|
||||
enumerable: true
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ var Test = (function () {
|
||||
get: function () {
|
||||
return 5 + 5;
|
||||
},
|
||||
enumerable: true
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ var Test = (function () {
|
||||
set: function (val) {
|
||||
this._test = val;
|
||||
},
|
||||
enumerable: true
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ var A = (function () {
|
||||
b: {
|
||||
get: function () {},
|
||||
set: function (b) {},
|
||||
enumerable: true
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -8,6 +8,7 @@ var obj = Object.defineProperties({}, {
|
||||
set: function (value) {
|
||||
this._foo = value;
|
||||
},
|
||||
enumerable: true
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
|
||||
get: function () {
|
||||
return 5 + 5;
|
||||
},
|
||||
enumerable: true
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
|
||||
set: function (value) {
|
||||
this._foo = value;
|
||||
},
|
||||
enumerable: true
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
|
||||
}));
|
||||
|
||||
@@ -13,7 +13,9 @@ var Test = (function () {
|
||||
get: function () {
|
||||
throw new Error("wow");
|
||||
},
|
||||
enumerable: true
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user