Make classes implicitly strict mode
This commit is contained in:
@@ -1292,12 +1292,15 @@ TreeWalker.prototype = {
|
||||
this.directives = Object.create(this.directives);
|
||||
} else if (node instanceof AST_Directive) {
|
||||
this.directives[node.value] = this.directives[node.value] ? "up" : true;
|
||||
} else if (node instanceof AST_Class) {
|
||||
this.directives = Object.create(this.directives);
|
||||
this.directives["use strict"] = this.directives["use strict"] ? "up" : true;
|
||||
}
|
||||
this.stack.push(node);
|
||||
},
|
||||
pop: function(node) {
|
||||
this.stack.pop();
|
||||
if (node instanceof AST_Lambda) {
|
||||
if (node instanceof AST_Lambda || node instanceof AST_Class) {
|
||||
this.directives = Object.getPrototypeOf(this.directives);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2039,6 +2039,9 @@ function parse($TEXT, options) {
|
||||
function class_(KindOfClass) {
|
||||
var start, method, class_name, extends_, a = [];
|
||||
|
||||
S.input.push_directives_stack(); // Push directive stack, but not scope stack
|
||||
S.input.add_directive("use strict");
|
||||
|
||||
if (S.token.type == "name" && S.token.value != "extends") {
|
||||
class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
|
||||
}
|
||||
@@ -2063,6 +2066,8 @@ function parse($TEXT, options) {
|
||||
if (is("punc", ";")) { next(); }
|
||||
}
|
||||
|
||||
S.input.pop_directives_stack();
|
||||
|
||||
next();
|
||||
|
||||
return new KindOfClass({
|
||||
|
||||
Reference in New Issue
Block a user