diff --git a/lib/CSSStyleDeclaration.js b/lib/CSSStyleDeclaration.js index 0bb9eced..87f480e3 100644 --- a/lib/CSSStyleDeclaration.js +++ b/lib/CSSStyleDeclaration.js @@ -35,6 +35,9 @@ CSSStyleDeclaration.prototype = { * Returns the empty string if the property has not been set. */ getPropertyValue: function(name) { + if (name.indexOf('--') === 0 && this.hasOwnProperty(name)) { + return this[name]; + } if (!this._values.hasOwnProperty(name)) { return ''; } @@ -56,13 +59,19 @@ CSSStyleDeclaration.prototype = { this.removeProperty(name); return; } - var lowercaseName = name.toLowerCase(); - if (!allProperties.has(lowercaseName) && !allExtraProperties.has(lowercaseName)) { + var isCustomProperty = name.indexOf('--') === 0; + // custom properties are case-sensitive + var propertyName = isCustomProperty ? name : name.toLowerCase(); + if ( + !isCustomProperty && + !allProperties.has(propertyName) && + !allExtraProperties.has(propertyName) + ) { return; } - this[lowercaseName] = value; - this._importants[lowercaseName] = priority; + this[propertyName] = value; + this._importants[propertyName] = priority; }, _setProperty: function(name, value, priority) { if (value === undefined) {