add configurable and writable property to defined properties

This commit is contained in:
Sebastian McKenzie
2015-01-11 02:43:17 +11:00
parent 7fc484d82e
commit 286d2f84bd
12 changed files with 38 additions and 16 deletions

View File

@@ -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) {

View File

@@ -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;