diff options
author | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:17:50 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-12-31 21:17:50 -0600 |
commit | ddfe457abfe85b14ba4c95c3a9f434d04e02ec23 (patch) | |
tree | a9ac481f8a31df4a8aa6f3e3c7fbfd98bba629d3 /lib/handlebars/compiler/javascript-compiler.js | |
parent | f4d337d252c8f1f390cd0bdebbf1f57497591721 (diff) | |
download | handlebars.js-ddfe457abfe85b14ba4c95c3a9f434d04e02ec23.zip handlebars.js-ddfe457abfe85b14ba4c95c3a9f434d04e02ec23.tar.gz handlebars.js-ddfe457abfe85b14ba4c95c3a9f434d04e02ec23.tar.bz2 |
Fix stack id "leak" on replaceStack
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index 22937f6..7ad400c 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -688,6 +688,7 @@ JavaScriptCompiler.prototype = { var prefix = '', inline = this.isInline(), stack, + createdStack, usedLiteral; // If we are currently inline then we want to merge the inline statement into the @@ -701,7 +702,8 @@ JavaScriptCompiler.prototype = { usedLiteral = true; } else { // Get or create the current stack name for use by the inline - var name = this.stackSlot ? this.topStackName() : this.incrStack(); + createdStack = !this.stackSlot; + var name = !createdStack ? this.topStackName() : this.incrStack(); prefix = '(' + this.push(name) + ' = ' + top + '),'; stack = this.topStack(); @@ -716,6 +718,9 @@ JavaScriptCompiler.prototype = { if (!usedLiteral) { this.popStack(); } + if (createdStack) { + this.stackSlot--; + } this.push('(' + prefix + item + ')'); } else { // Prevent modification of the context depth variable. Through replaceStack |