diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js index b43b9af..798d46d 100644 --- a/lib/CSSStyleDeclaration.js +++ b/lib/CSSStyleDeclaration.js @@ -46,13 +46,24 @@ CSSOM.CSSStyleDeclaration.prototype = { this[this.length] = name; this.length++; } + + // If the priority value of the incoming property is "important", + // or the value of the existing property is not "important", + // then remove the existing property and rewrite it. + if (priority || !this._importants[name]) { + this.removeProperty(name); + this[this.length] = name; + this.length++; + this[name] = value + ''; + this._importants[name] = priority; + } } else { // New property. this[this.length] = name; this.length++; + this[name] = value + ''; + this._importants[name] = priority; } - this[name] = value + ""; - this._importants[name] = priority; }, /**