From f1bff47ae7a8297a2715ea71e5a2547ef1c433b5 Mon Sep 17 00:00:00 2001 From: MattMo Date: Sun, 20 Jul 2025 15:44:59 -0700 Subject: [PATCH] Fixed a bug with the onClassChanged and the Disabled template code. --- ignite-template.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ignite-template.js b/ignite-template.js index c2da413..9f18f92 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -1224,7 +1224,12 @@ class IgniteTemplate { } } else { this._attributes["disabled"] = null; - this._classes.splice(this._classes.indexOf("disabled"), 1); + + var disabledIndex = this._classes.indexOf("disabled"); + + if (disabledIndex >= 0) { + this._classes.splice(disabledIndex, 1); + } if (this.element) { this.element.removeAttribute("disabled"); @@ -1660,10 +1665,20 @@ class IgniteTemplate { } //Remove the old values from the template, but only remove one copy. - oldClasses.forEach((cl) => this._classes.splice(this._classes.indexOf(cl), 1)); + oldClasses.forEach((cl) => { + var clIndex = this._classes.indexOf(cl); + if (clIndex >= 0) { + this._classes.splice(clIndex, 1); + } + }); //Add the new classes to the template. - newClasses.forEach((cl) => this._classes.push(cl)); + newClasses.forEach((cl) => { + var clIndex = this._classes.indexOf(cl); + if (clIndex < 0) { + this._classes.push(cl); + } + }); //For any classes that are missing on the element, add them. If we have duplicates this //can happen.