Merge pull request #150 from ozee31/fix-uncaught-typeerror-push-of-undefined

fix Uncaught TypeError: Cannot set property 'push' of undefined
This commit is contained in:
Amauri CHAMPEAUX 2018-06-15 15:54:44 +02:00 committed by GitHub
commit b0b4df1a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -327,17 +327,20 @@ var tarteaucitron = {
div.id = 'tarteaucitronRoot'; div.id = 'tarteaucitronRoot';
body.appendChild(div, body); body.appendChild(div, body);
div.innerHTML = html; div.innerHTML = html;
if (tarteaucitron.job !== undefined) { if (tarteaucitron.job !== undefined) {
tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
for (index = 0; index < tarteaucitron.job.length; index += 1) { for (index = 0; index < tarteaucitron.job.length; index += 1) {
tarteaucitron.addService(tarteaucitron.job[index]); tarteaucitron.addService(tarteaucitron.job[index]);
} }
} else {
tarteaucitron.job = []
} }
tarteaucitron.isAjax = true; tarteaucitron.isAjax = true;
tarteaucitron.job.push = function (id) { tarteaucitron.job.push = function (id) {
// ie <9 hack // ie <9 hack
if (typeof tarteaucitron.job.indexOf === 'undefined') { if (typeof tarteaucitron.job.indexOf === 'undefined') {
tarteaucitron.job.indexOf = function (obj, start) { tarteaucitron.job.indexOf = function (obj, start) {
@ -349,7 +352,7 @@ var tarteaucitron = {
return -1; return -1;
}; };
} }
if (tarteaucitron.job.indexOf(id) === -1) { if (tarteaucitron.job.indexOf(id) === -1) {
Array.prototype.push.call(this, id); Array.prototype.push.call(this, id);
} }