Skip to content

Commit

Permalink
fix(transformer): value => value[0] for legacyLogicalProperties to av…
Browse files Browse the repository at this point in the history
…oid duplicate !important
  • Loading branch information
dengfuping committed Dec 11, 2023
1 parent 343567c commit a8065bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/transformers/legacyLogicalProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const transform: Transformer = {
});
} else if (matchValue.length === 1) {
// Handle like `marginBlockStart` => `marginTop`
clone[matchValue[0]] = wrapImportantAndSkipCheck(value, important);
clone[matchValue[0]] = wrapImportantAndSkipCheck(values[0], important);
} else if (matchValue.length === 2) {
// Handle like `marginBlock` => `marginTop` & `marginBottom`
matchValue.forEach((matchKey, index) => {
Expand Down
5 changes: 4 additions & 1 deletion tests/transform.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,16 @@ describe('transform', () => {
css={{
'.box': {
paddingInline: '33px !important',
marginBlockStart: '33px !important',
marginBlockEnd: 'calc(2px + 3px) !important',
},
}}
/>,
);

const styleText = document.head.querySelector('style')?.innerHTML;
expect(styleText).toContain('33px!important');
expect(styleText).toContain('padding-left:33px!important;padding-right:33px!important');
expect(styleText).toContain('margin-top:33px!important;margin-bottom:calc(2px+3px)!important;');
});

it('split with calc() and var()', () => {
Expand Down

0 comments on commit a8065bf

Please sign in to comment.