Skip to content

Commit 9a3a612

Browse files
committed
fix: object setter has no effect
1 parent 7308c7f commit 9a3a612

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/CSSStyleDeclaration.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ CSSStyleDeclaration.prototype = {
3535
* Returns the empty string if the property has not been set.
3636
*/
3737
getPropertyValue: function(name) {
38-
if (name.indexOf('--') === 0 && this.hasOwnProperty(name)) {
39-
return this[name];
40-
}
4138
if (!this._values.hasOwnProperty(name)) {
4239
return '';
4340
}
@@ -60,18 +57,17 @@ CSSStyleDeclaration.prototype = {
6057
return;
6158
}
6259
var isCustomProperty = name.indexOf('--') === 0;
63-
// custom properties are case-sensitive
64-
var propertyName = isCustomProperty ? name : name.toLowerCase();
65-
if (
66-
!isCustomProperty &&
67-
!allProperties.has(propertyName) &&
68-
!allExtraProperties.has(propertyName)
69-
) {
60+
if (isCustomProperty) {
61+
this._setProperty(name, value, priority);
62+
return;
63+
}
64+
var lowercaseName = name.toLowerCase();
65+
if (!allProperties.has(lowercaseName) && !allExtraProperties.has(lowercaseName)) {
7066
return;
7167
}
7268

73-
this[propertyName] = value;
74-
this._importants[propertyName] = priority;
69+
this[lowercaseName] = value;
70+
this._importants[lowercaseName] = priority;
7571
},
7672
_setProperty: function(name, value, priority) {
7773
if (value === undefined) {

lib/CSSStyleDeclaration.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ describe('CSSStyleDeclaration', () => {
537537
const style = new CSSStyleDeclaration();
538538
style['--baz'] = 'yellow';
539539

540-
expect(style.getPropertyValue('--baz')).toEqual('yellow');
540+
expect(style.getPropertyValue('--baz')).toEqual('');
541541
});
542542

543543
test('custom properties are case-sensitive', () => {

0 commit comments

Comments
 (0)