From: Errietta Kostala Date: Thu, 2 Jul 2015 14:51:26 +0000 (+0000) Subject: Needed polyfill. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb397725e1317b588411813734a44fda3ec6dab2;p=scpubgit%2Fstemmaweb.git Needed polyfill. --- diff --git a/root/js/common.js b/root/js/common.js new file mode 100644 index 0000000..7c38cd6 --- /dev/null +++ b/root/js/common.js @@ -0,0 +1,24 @@ +//Array.find polyfill for browsers that don't support it + +if (!Array.prototype.find) { + Array.prototype.find = function(predicate) { + if (this == null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + }; +} diff --git a/root/src/header.tt b/root/src/header.tt index 02d3466..1a99b34 100644 --- a/root/src/header.tt +++ b/root/src/header.tt @@ -10,6 +10,7 @@ [% IF applicationstyle -%] [% END -%] +