Skip to content

Commit 2a0d0d6

Browse files
author
Nicholas K. Dionysopoulos
committed
Better handling of missing elements in cookie controls JS
1 parent c5fb257 commit 2a0d0d6

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

plugins/system/datacompliancecookie/media/js/datacompliancecookies.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,20 @@ var AkeebaDataComplianceCookies = function (options)
133133
var elAcceptedControls = document.getElementById('akeeba-dccc-controls-accepted');
134134
var elDeclinedControls = document.getElementById('akeeba-dccc-controls-declined');
135135

136-
if (typeof elAcceptedControls !== 'undefined')
136+
if ((elAcceptedControls !== null) && (typeof elAcceptedControls !== 'undefined'))
137137
{
138138
elAcceptedControls.style.display = 'none';
139139
}
140140

141-
if (typeof elDeclinedControls !== 'undefined')
141+
if ((elDeclinedControls !== null) && (typeof elDeclinedControls !== 'undefined'))
142142
{
143143
elDeclinedControls.style.display = 'none';
144144
}
145145

146146
// Show banner
147147
var elBanner = document.getElementById('akeeba-dccc-banner-container');
148148

149-
if (typeof elBanner !== 'undefined')
149+
if ((elBanner !== null) && (typeof elBanner !== 'undefined'))
150150
{
151151
elBanner.style.display = 'block';
152152
}
@@ -978,7 +978,7 @@ AkeebaDataComplianceCookies.documentReady(function ()
978978
// Hide the banner
979979
var elBanner = document.getElementById('akeeba-dccc-banner-container');
980980

981-
if (typeof elBanner !== 'undefined')
981+
if ((elBanner !== null) && (typeof elBanner !== 'undefined'))
982982
{
983983
elBanner.style.display = 'none';
984984
}
@@ -987,27 +987,27 @@ AkeebaDataComplianceCookies.documentReady(function ()
987987
var elAcceptedControls = document.getElementById('akeeba-dccc-controls-accepted');
988988
var elDeclinedControls = document.getElementById('akeeba-dccc-controls-declined');
989989

990-
if (typeof elAcceptedControls !== 'undefined')
990+
if ((elAcceptedControls !== null) && (typeof elAcceptedControls !== 'undefined'))
991991
{
992992
elAcceptedControls.style.display = 'none';
993993
}
994994

995-
if (typeof elDeclinedControls !== 'undefined')
995+
if ((elDeclinedControls !== null) && (typeof elDeclinedControls !== 'undefined'))
996996
{
997997
elDeclinedControls.style.display = 'none';
998998
}
999999

10001000
// Find the control holder (akeeba-dccc-controls). If it's not found, exit immediately.
10011001
var elHolder = document.getElementById('akeeba-dccc-controls');
10021002

1003-
if (typeof elHolder === 'undefined')
1003+
if ((elHolder === null) || (typeof elHolder === 'undefined'))
10041004
{
10051005
return;
10061006
}
10071007

10081008
if (window.AkeebaDataComplianceCookies.vars.accepted)
10091009
{
1010-
if (typeof elAcceptedControls !== 'undefined')
1010+
if ((elAcceptedControls !== null) && (typeof elAcceptedControls !== 'undefined'))
10111011
{
10121012
// Show akeeba-dccc-controls-accepted
10131013
elAcceptedControls.style.display = 'block';
@@ -1019,7 +1019,7 @@ AkeebaDataComplianceCookies.documentReady(function ()
10191019
return;
10201020
}
10211021

1022-
if (typeof elDeclinedControls !== 'undefined')
1022+
if ((elDeclinedControls !== null) && (typeof elDeclinedControls !== 'undefined'))
10231023
{
10241024
// Show akeeba-dccc-controls-declined
10251025
elDeclinedControls.style.display = 'block';

0 commit comments

Comments
 (0)