From 56f0dc64ed2d113dc3e3765ef2a8540abd0dc62f Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 13 Jan 2014 14:44:18 +0800 Subject: [PATCH] MDL-43664 Javascript: Use YUI indexOf for pending_js tracking Some old browsers do not support indexOf and so cannot determine whether JS script is in progress. The YUI Y.Array module polyfills the indexOf functionality when it does not exist. --- lib/javascript-static.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index df36acd83d5..48ccc641045 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -817,7 +817,9 @@ M.util.js_watch_io(); * @return boolean - True if there is any pending js. */ M.util.js_complete = function(uniqid) { - var index = M.util.pending_js.indexOf(uniqid); + // Use the Y.Array.indexOf instead of the native because some older browsers do not support + // the native function. Y.Array polyfills the native function if it does not exist. + var index = Y.Array.indexOf(M.util.pending_js, uniqid); if (index >= 0) { M.util.complete_js.push(M.util.pending_js.splice(index, 1)); }