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
2 changes: 1 addition & 1 deletion cjs/interface/css-style-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const handler = {
return getKeys(style).length;
if (/^\d+$/.test(name))
return getKeys(style)[name];
return style.get(uhyphen(name));
Comment thread
magicismight marked this conversation as resolved.
return style.get(uhyphen(name)) ?? '';
},

set(style, name, value) {
Expand Down
2 changes: 1 addition & 1 deletion esm/interface/css-style-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const handler = {
return getKeys(style).length;
if (/^\d+$/.test(name))
return getKeys(style)[name];
return style.get(uhyphen(name));
return style.get(uhyphen(name)) ?? '';
},

set(style, name, value) {
Expand Down
4 changes: 4 additions & 0 deletions test/interface/css-style-declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const {document} = parseHTML('');

let node = document.createElement('div');
assert(node.style.cssText, '', 'empty style');
// Per CSSOM, an unset property reads as the empty string, not undefined —
// matching getPropertyValue, which is routed through the same getter.
assert(node.style.color, '', 'unset property getter returns ""');
assert(node.style.getPropertyValue('color'), '', 'unset getPropertyValue returns ""');
node.style.cssText = 'background-color: blue; background-image: url("https://t.co/i.png");';
assert(node.style.backgroundColor, 'blue', 'style getter');
assert(node.style.backgroundImage, 'url("https://t.co/i.png")', 'style value with colon');
Expand Down
Loading