Fix a bug where registers were shared
This commit is contained in:
@@ -393,14 +393,14 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
this.isChild = !!context;
|
||||
this.context = context || {
|
||||
programs: [],
|
||||
aliases: { },
|
||||
registers: {list: []}
|
||||
aliases: { }
|
||||
};
|
||||
|
||||
this.preamble();
|
||||
|
||||
this.stackSlot = 0;
|
||||
this.stackVars = [];
|
||||
this.registers = { list: [] };
|
||||
this.compileStack = [];
|
||||
|
||||
this.compileChildren(environment, options);
|
||||
@@ -456,10 +456,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
},
|
||||
|
||||
createFunctionContext: function(asObject) {
|
||||
var locals = this.stackVars;
|
||||
if (!this.isChild) {
|
||||
locals = locals.concat(this.context.registers.list);
|
||||
}
|
||||
var locals = this.stackVars.concat(this.registers.list);
|
||||
|
||||
if(locals.length > 0) {
|
||||
this.source[1] = this.source[1] + ", " + locals.join(", ");
|
||||
@@ -854,9 +851,9 @@ Handlebars.JavaScriptCompiler = function() {};
|
||||
},
|
||||
|
||||
useRegister: function(name) {
|
||||
if(!this.context.registers[name]) {
|
||||
this.context.registers[name] = true;
|
||||
this.context.registers.list.push(name);
|
||||
if(!this.registers[name]) {
|
||||
this.registers[name] = true;
|
||||
this.registers.list.push(name);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user