From 2fda34d9f6e656df5929fc486a8524dbff7c3775 Mon Sep 17 00:00:00 2001 From: Kamen Zhekov Date: Fri, 10 Sep 2021 13:36:32 +0000 Subject: [PATCH] [FIX] website: use better practices for classList manipulation Assigning a value to an element's classList is bad practice and unpredictable behaviour. The recommended way of manipulating the classList is to use the add(), toggle(), and remove() methods instead of direct assignment. This commit corrects 41f7c7bc which did that multiple times. closes odoo/odoo#76578 X-original-commit: 0c655afce51e0bd200ba101a183e4bef17c23cae Signed-off-by: Quentin Smetz (qsm) --- .../static/lib/multirange/multirange_custom.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/website/static/lib/multirange/multirange_custom.js b/addons/website/static/lib/multirange/multirange_custom.js index aaf3628e337..55b2f791c42 100644 --- a/addons/website/static/lib/multirange/multirange_custom.js +++ b/addons/website/static/lib/multirange/multirange_custom.js @@ -79,7 +79,7 @@ class Multirange { /* Wrap the input and add its ghost */ this.rangeDiv = document.createElement("div"); - this.rangeDiv.classList = "multirange-wrapper"; + this.rangeDiv.classList.add("multirange-wrapper"); this.input.parentNode.insertBefore(this.rangeDiv, this.input.nextSibling); this.rangeDiv.appendChild(this.input); this.ghost = this.input.cloneNode(); @@ -91,15 +91,15 @@ class Multirange { this.ghost.value = values[1] || this.max; this.inputTipLocator = document.createElement("div"); - this.inputTipLocator.classList = "tip-locator"; + this.inputTipLocator.classList.add("tip-locator"); this.ghostTipLocator = document.createElement("div"); - this.ghostTipLocator.classList = "tip-locator"; + this.ghostTipLocator.classList.add("tip-locator"); this.rangeDiv.insertBefore(this.ghostTipLocator, this.input.nextSibling); this.rangeDiv.insertBefore(this.inputTipLocator, this.ghost.nextSibling); this.leftCounter = document.createElement("span"); - this.leftCounter.classList = "multirange-min"; + this.leftCounter.classList.add("multirange-min"); this.rightCounter = document.createElement("span"); - this.rightCounter.classList = "multirange-max"; + this.rightCounter.classList.add("multirange-max"); this.tipLocatorOptions = { container: this.rangeDiv, html: true, @@ -130,8 +130,8 @@ class Multirange { this.leftInput.step = this.step; this.rightInput = this.leftInput.cloneNode(); - this.leftInput.classList = "multirange-min"; - this.rightInput.classList = "multirange-max"; + this.leftInput.classList.add("multirange-min"); + this.rightInput.classList.add("multirange-max"); this.leftCounter.parentNode.appendChild(this.leftInput); this.rightCounter.parentNode.appendChild(this.rightInput);