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.