From a6f2ec85dab8713e5a9de9592c28943819c95b8b Mon Sep 17 00:00:00 2001 From: dingrf Date: Wed, 6 May 2015 14:03:31 +0800 Subject: [PATCH] add Array.isArray and Array.filter function for old IE browsers. --- lib/director/browser.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/director/browser.js b/lib/director/browser.js index 1e47293..3ec0041 100644 --- a/lib/director/browser.js +++ b/lib/director/browser.js @@ -6,6 +6,28 @@ * */ +Array.isArray = Array.isArray || function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; +}; + +Array.prototype.filter = Array.prototype.filter || function(fun){ + var len = this.length; + if (typeof fun != "function"){ + throw new TypeError(); + } + var res = new Array(); + var thisp = arguments[1]; + for (var i = 0; i < len; i++){ + if (i in this){ + var val = this[i]; + if (fun.call(thisp, val, i, this)) { + res.push(val); + } + } + } + return res; +}; + var dloc = document.location; function dlocHashEmpty() {