From 2e88cbbd9f2c15f83f79d8e4a45416b968f30883 Mon Sep 17 00:00:00 2001 From: O2 Graphics Date: Sun, 1 Nov 2020 21:21:38 +0100 Subject: [PATCH] Don't run a replace() when not needed Also, replace "==" by "===": it's better, cleaner and consistent with the rest of the code. --- tarteaucitron.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 4ddce9e..3bcd8af 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -867,9 +867,12 @@ var tarteaucitron = { }, "respond": function (el, status) { "use strict"; + if (el.id === '') { + return; + } var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), ''); - if (key.substring(0, 13) == 'tarteaucitron' || key == "") {return;} + if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;} // return if same state if (tarteaucitron.state[key] === status) {