Merge branch 'master' into visitor-update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Exception from "../exception";
|
||||
import {isArray} from "../utils";
|
||||
import {isArray, indexOf} from "../utils";
|
||||
import AST from "./ast";
|
||||
|
||||
var slice = [].slice;
|
||||
@@ -400,7 +400,7 @@ Compiler.prototype = {
|
||||
blockParamIndex: function(name) {
|
||||
for (var depth = 0, len = this.options.blockParams.length; depth < len; depth++) {
|
||||
var blockParams = this.options.blockParams[depth],
|
||||
param = blockParams && blockParams.indexOf(name);
|
||||
param = blockParams && indexOf(blockParams, name);
|
||||
if (blockParams && param >= 0) {
|
||||
return [depth, param];
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ JavaScriptCompiler.prototype = {
|
||||
if (bufferStart) {
|
||||
bufferStart.prepend('return ');
|
||||
bufferEnd.add(';');
|
||||
} else {
|
||||
} else if (!sourceSeen) {
|
||||
this.source.push('return "";');
|
||||
}
|
||||
} else {
|
||||
@@ -263,7 +263,7 @@ JavaScriptCompiler.prototype = {
|
||||
}
|
||||
|
||||
if (varDeclarations) {
|
||||
this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n '));
|
||||
this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n'));
|
||||
}
|
||||
|
||||
return this.source.merge();
|
||||
|
||||
@@ -48,6 +48,16 @@ export var isArray = Array.isArray || function(value) {
|
||||
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
||||
};
|
||||
|
||||
// Older IE versions do not directly support indexOf so we must implement our own, sadly.
|
||||
export function indexOf(array, value) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (array[i] === value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
export function escapeExpression(string) {
|
||||
// don't escape SafeStrings, since they're already safe
|
||||
|
||||
Reference in New Issue
Block a user