Skip to content

Commit

Permalink
Add support for margin and padding jsdom#154
Browse files Browse the repository at this point in the history
  • Loading branch information
BramMeerten committed Jun 26, 2024
1 parent 0f99b28 commit 2d8c96c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/CSSStyleDeclaration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,11 @@ describe('CSSStyleDeclaration', () => {

test('supports calc', () => {
const style = new CSSStyleDeclaration();
style.setProperty('width', 'calc(100% - 100px)');
expect(style.getPropertyValue('width')).toEqual('calc(100% - 100px)');
['width', 'height', 'margin', 'margin-top', 'bottom', 'right', 'padding'].forEach(
(property) => {
style.setProperty(property, 'calc(100% - 100px)');
expect(style.getPropertyValue(property)).toEqual('calc(100% - 100px)');
}
);
});
});
1 change: 1 addition & 0 deletions lib/properties/margin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var isValid = function (v) {
type === TYPES.NULL_OR_EMPTY_STR ||
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
type === TYPES.CALC ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
Expand Down
1 change: 1 addition & 0 deletions lib/properties/padding.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var isValid = function (v) {
type === TYPES.NULL_OR_EMPTY_STR ||
type === TYPES.LENGTH ||
type === TYPES.PERCENT ||
type === TYPES.CALC ||
(type === TYPES.INTEGER && (v === '0' || v === 0))
);
};
Expand Down

0 comments on commit 2d8c96c

Please sign in to comment.