diff options
author | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:17:16 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:17:16 -0600 |
commit | f4d337d252c8f1f390cd0bdebbf1f57497591721 (patch) | |
tree | ada8d78a467bee23037a0146f9719ba30567595c /lib/handlebars/compiler/javascript-compiler.js | |
parent | cbfec5b9e9e7e2459c36fbfce599a3d5c082c61e (diff) | |
download | handlebars.js-f4d337d252c8f1f390cd0bdebbf1f57497591721.zip handlebars.js-f4d337d252c8f1f390cd0bdebbf1f57497591721.tar.gz handlebars.js-f4d337d252c8f1f390cd0bdebbf1f57497591721.tar.bz2 |
Fix incorrect stack pop when replacing literals
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 7fbddf7..22937f6 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -687,7 +687,8 @@ JavaScriptCompiler.prototype = { replaceStack: function(callback) { var prefix = '', inline = this.isInline(), - stack; + stack, + usedLiteral; // If we are currently inline then we want to merge the inline statement into the // replacement statement via ',' @@ -697,6 +698,7 @@ JavaScriptCompiler.prototype = { if (top instanceof Literal) { // Literals do not need to be inlined stack = top.value; + usedLiteral = true; } else { // Get or create the current stack name for use by the inline var name = this.stackSlot ? this.topStackName() : this.incrStack(); @@ -711,7 +713,7 @@ JavaScriptCompiler.prototype = { var item = callback.call(this, stack); if (inline) { - if (this.inlineStack.length || this.compileStack.length) { + if (!usedLiteral) { this.popStack(); } this.push('(' + prefix + item + ')'); |