Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/CSSStyleDeclaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ CSSStyleDeclaration.prototype = {
this.removeProperty(name);
return;
}
var isCustomProperty = name.indexOf('--') === 0;
if (isCustomProperty) {
this._setProperty(name, value, priority);
return;
}
var lowercaseName = name.toLowerCase();
if (!allProperties.has(lowercaseName) && !allExtraProperties.has(lowercaseName)) {
return;
Expand Down
29 changes: 29 additions & 0 deletions lib/CSSStyleDeclaration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,33 @@ describe('CSSStyleDeclaration', () => {
expect(0).toEqual(style.length);
expect(undefined).toEqual(style[0]);
});

test('getPropertyValue for custom properties in cssText', () => {
const style = new CSSStyleDeclaration();
style.cssText = '--foo: red';

expect(style.getPropertyValue('--foo')).toEqual('red');
});

test('getPropertyValue for custom properties with setProperty', () => {
const style = new CSSStyleDeclaration();
style.setProperty('--bar', 'blue');

expect(style.getPropertyValue('--bar')).toEqual('blue');
});

test('getPropertyValue for custom properties with object setter', () => {
const style = new CSSStyleDeclaration();
style['--baz'] = 'yellow';

expect(style.getPropertyValue('--baz')).toEqual('');
});

test('custom properties are case-sensitive', () => {
const style = new CSSStyleDeclaration();
style.cssText = '--fOo: purple';

expect(style.getPropertyValue('--foo')).toEqual('');
expect(style.getPropertyValue('--fOo')).toEqual('purple');
});
});