summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r--lib/handlebars/compiler/compiler.js4
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js13
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 99d6f4f..c702d00 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -372,9 +372,7 @@ Compiler.prototype = {
},
pushParams: function(params) {
- var i = params.length;
-
- while(i--) {
+ for(var i=0, l=params.length; i<l; i++) {
this.pushParam(params[i]);
}
},
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index 514dfcc..8bb5da6 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -915,16 +915,19 @@ JavaScriptCompiler.prototype = {
options.inverse = inverse;
}
- for (var i = 0; i < paramSize; i++) {
+ // The parameters go on to the stack in order (making sure that they are evaluated in order)
+ // so we need to pop them off the stack in reverse order
+ var i = paramSize;
+ while (i--) {
param = this.popStack();
- params.push(param);
+ params[i] = param;
if (this.trackIds) {
- ids.push(this.popStack());
+ ids[i] = this.popStack();
}
if (this.stringParams) {
- types.push(this.popStack());
- contexts.push(this.popStack());
+ types[i] = this.popStack();
+ contexts[i] = this.popStack();
}
}