Use terinary operator for inline appends

Allows for append operations to avoid breaking inline chain.
This commit is contained in:
kpdecker
2014-11-05 22:04:37 -06:00
parent a7000f8129
commit 9665379cdc
+12 -7
View File
@@ -289,13 +289,18 @@ JavaScriptCompiler.prototype = {
// If `value` is truthy, or 0, it is coerced into a string and appended
// Otherwise, the empty string is appended
append: function() {
// Force anything that is inlined onto the stack so we don't have duplication
// when we examine local
this.flushInline();
var local = this.popStack();
this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
if (this.environment.isSimple) {
this.pushSource("else { " + this.appendToBuffer("''") + " }");
if (this.isInline()) {
this.replaceStack(function(current) {
return ' != null ? ' + current + ' : ""';
});
this.pushSource(this.appendToBuffer(this.popStack()));
} else {
var local = this.popStack();
this.pushSource('if (' + local + ' != null) { ' + this.appendToBuffer(local) + ' }');
if (this.environment.isSimple) {
this.pushSource("else { " + this.appendToBuffer("''") + " }");
}
}
},