From 43438682c74c40d911a38adacfcaed9534bc5ab8 Mon Sep 17 00:00:00 2001 From: Ozee31 Date: Fri, 15 Jun 2018 15:31:42 +0200 Subject: [PATCH] fix Uncaught TypeError: Cannot set property 'push' of undefined if tarteaucitron.job is undefined --- tarteaucitron.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 3d8e718..8b9b361 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -327,17 +327,20 @@ var tarteaucitron = { div.id = 'tarteaucitronRoot'; body.appendChild(div, body); div.innerHTML = html; - + if (tarteaucitron.job !== undefined) { tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); for (index = 0; index < tarteaucitron.job.length; index += 1) { tarteaucitron.addService(tarteaucitron.job[index]); } + } else { + tarteaucitron.job = [] } tarteaucitron.isAjax = true; + tarteaucitron.job.push = function (id) { - + // ie <9 hack if (typeof tarteaucitron.job.indexOf === 'undefined') { tarteaucitron.job.indexOf = function (obj, start) { @@ -349,7 +352,7 @@ var tarteaucitron = { return -1; }; } - + if (tarteaucitron.job.indexOf(id) === -1) { Array.prototype.push.call(this, id); }