Unify isArray/isFunction/toString implementations
Restores Array.isArray polyfill for all use cases. Fixes #645
This commit is contained in:
+3
-17
@@ -12,25 +12,11 @@ export var REVISION_CHANGES = {
|
|||||||
4: '>= 1.0.0'
|
4: '>= 1.0.0'
|
||||||
};
|
};
|
||||||
|
|
||||||
var toString = Object.prototype.toString,
|
var isArray = Utils.isArray,
|
||||||
|
isFunction = Utils.isFunction,
|
||||||
|
toString = Utils.toString,
|
||||||
objectType = '[object Object]';
|
objectType = '[object Object]';
|
||||||
|
|
||||||
// Sourced from lodash
|
|
||||||
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
|
|
||||||
var isFunction = function(value) {
|
|
||||||
return typeof value === 'function';
|
|
||||||
};
|
|
||||||
// fallback for older versions of Chrome and Safari
|
|
||||||
if (isFunction(/x/)) {
|
|
||||||
isFunction = function(value) {
|
|
||||||
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function isArray(value) {
|
|
||||||
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function HandlebarsEnvironment(helpers, partials) {
|
export function HandlebarsEnvironment(helpers, partials) {
|
||||||
this.helpers = helpers || {};
|
this.helpers = helpers || {};
|
||||||
this.partials = partials || {};
|
this.partials = partials || {};
|
||||||
|
|||||||
+20
-2
@@ -1,7 +1,5 @@
|
|||||||
import SafeString from "./safe-string";
|
import SafeString from "./safe-string";
|
||||||
|
|
||||||
var isArray = Array.isArray;
|
|
||||||
|
|
||||||
var escape = {
|
var escape = {
|
||||||
"&": "&",
|
"&": "&",
|
||||||
"<": "<",
|
"<": "<",
|
||||||
@@ -26,6 +24,26 @@ export function extend(obj, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export var toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
// Sourced from lodash
|
||||||
|
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
|
||||||
|
var isFunction = function(value) {
|
||||||
|
return typeof value === 'function';
|
||||||
|
};
|
||||||
|
// fallback for older versions of Chrome and Safari
|
||||||
|
if (isFunction(/x/)) {
|
||||||
|
isFunction = function(value) {
|
||||||
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export var isFunction;
|
||||||
|
|
||||||
|
export var isArray = Array.isArray || function(value) {
|
||||||
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export function escapeExpression(string) {
|
export function escapeExpression(string) {
|
||||||
// don't escape SafeStrings, since they're already safe
|
// don't escape SafeStrings, since they're already safe
|
||||||
if (string instanceof SafeString) {
|
if (string instanceof SafeString) {
|
||||||
|
|||||||
Reference in New Issue
Block a user