make class methods unenumerable - fixes #41
This commit is contained in:
@@ -91,19 +91,17 @@ var buildClassBody = function (body, className, superName, node) {
|
||||
throw util.errorWithNode(node, "unknown kind for constructor method");
|
||||
}
|
||||
} else {
|
||||
var add = addInstanceMethod;
|
||||
var mutatorMap = instanceMutatorMap;
|
||||
if (node.static) mutatorMap = staticMutatorMap;
|
||||
|
||||
if (node.static) {
|
||||
add = addStaticMethod;
|
||||
mutatorMap = staticMutatorMap
|
||||
var kind = node.kind;
|
||||
|
||||
if (kind === "") {
|
||||
kind = "value";
|
||||
util.pushMutatorMap(mutatorMap, methodName, "writeable", b.identifier("true"));
|
||||
}
|
||||
|
||||
if (node.kind === "") {
|
||||
add(body, className, methodName, method);
|
||||
} else {
|
||||
util.pushMutatorMap(mutatorMap, methodName, node.kind, node);
|
||||
}
|
||||
util.pushMutatorMap(mutatorMap, methodName, kind, node);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -177,19 +175,3 @@ var addConstructor = function (construct, method) {
|
||||
construct.body = method.body;
|
||||
construct.rest = method.rest;
|
||||
};
|
||||
|
||||
var addStaticMethod = function (body, className, methodName, method) {
|
||||
body.push(util.template("class-static-method", {
|
||||
METHOD_NAME: methodName,
|
||||
CLASS_NAME: className,
|
||||
FUNCTION: method
|
||||
}, true));
|
||||
};
|
||||
|
||||
var addInstanceMethod = function (body, className, methodName, method) {
|
||||
body.push(util.template("class-method", {
|
||||
METHOD_NAME: methodName,
|
||||
CLASS_NAME: className,
|
||||
FUNCTION: method
|
||||
}, true));
|
||||
};
|
||||
|
||||
@@ -97,10 +97,10 @@ exports.buildDefineProperties = function (mutatorMap, keyNode) {
|
||||
|
||||
var propNode = b.property("init", b.identifier(key), mapNode);
|
||||
|
||||
_.each(map, function (methodNode, type) {
|
||||
methodNode = _.clone(methodNode);
|
||||
if (methodNode.type === "MethodDefinition") methodNode = methodNode.value;
|
||||
mapNode.properties.push(b.property("init", b.identifier(type), methodNode));
|
||||
_.each(map, function (node, key) {
|
||||
node = _.clone(node);
|
||||
if (node.type === "MethodDefinition") node = node.value;
|
||||
mapNode.properties.push(b.property("init", b.identifier(key), node));
|
||||
});
|
||||
|
||||
objExpr.properties.push(propNode);
|
||||
|
||||
Reference in New Issue
Block a user