From 6a71b970ce084ed086fbf0aa9c64e773c9d2843e Mon Sep 17 00:00:00 2001 From: Gauthier Fiorentino Date: Tue, 30 May 2023 10:13:02 +0200 Subject: [PATCH] Fix event sent before state update Closes #1106 --- tarteaucitron.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index db9bbcc..18f822c 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1023,16 +1023,16 @@ var tarteaucitron = { tarteaucitron.sendEvent(key + '_loaded'); } var itemStatusElem = document.getElementById('tacCurrentStatus'+key); - if(status == true){ - itemStatusElem.innerHTML = tarteaucitron.lang.allowed; - tarteaucitron.sendEvent(key + '_allowed'); - }else{ - itemStatusElem.innerHTML = tarteaucitron.lang.disallowed; - tarteaucitron.sendEvent(key + '_disallowed'); - } tarteaucitron.state[key] = status; tarteaucitron.cookie.create(key, status); tarteaucitron.userInterface.color(key, status); + if (status == true) { + itemStatusElem.innerHTML = tarteaucitron.lang.allowed; + tarteaucitron.sendEvent(key + '_allowed'); + } else { + itemStatusElem.innerHTML = tarteaucitron.lang.disallowed; + tarteaucitron.sendEvent(key + '_disallowed'); + } } } }, @@ -1071,16 +1071,16 @@ var tarteaucitron = { } } var itemStatusElem = document.getElementById('tacCurrentStatus'+key); - if(status == true){ - itemStatusElem.innerHTML = tarteaucitron.lang.allowed; - tarteaucitron.sendEvent(key + '_allowed'); - }else{ - itemStatusElem.innerHTML = tarteaucitron.lang.disallowed; - tarteaucitron.sendEvent(key + '_disallowed'); - } tarteaucitron.state[key] = status; tarteaucitron.cookie.create(key, status); tarteaucitron.userInterface.color(key, status); + if (status == true) { + itemStatusElem.innerHTML = tarteaucitron.lang.allowed; + tarteaucitron.sendEvent(key + '_allowed'); + } else { + itemStatusElem.innerHTML = tarteaucitron.lang.disallowed; + tarteaucitron.sendEvent(key + '_disallowed'); + } }, "color": function (key, status) { "use strict";