Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

Commit f9466db

Browse files
committed
prefer Array.isArray when available to toString approach
1 parent d0f7ced commit f9466db

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/htmlbars-util/lib/array-utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ if (Array.prototype.indexOf) {
4343
};
4444
}
4545

46-
export var indexOfArray = getIdx;
46+
export var isArray = (Array.isArray || function(array) {
47+
return Object.prototype.toString.call(array) === '[object Array]';
48+
});
49+
50+
export var indexOfArray = getIdx;

packages/htmlbars-util/lib/template-utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { visitChildren } from "../htmlbars-util/morph-utils";
2+
import { isArray } from "./array-utils";
23

34
export function RenderState(renderNode) {
45
this.morphListStart = null;
@@ -85,7 +86,7 @@ export function renderAndCleanup(morph, env, options, shadowOptions, callback) {
8586
}
8687

8788
if (toClear) {
88-
if (Object.prototype.toString.call(toClear) === '[object Array]') {
89+
if (isArray(toClear)) {
8990
for (var i=0, l=toClear.length; i<l; i++) {
9091
clearMorph(toClear[i], env);
9192
}

0 commit comments

Comments
 (0)