Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ describe('@stylexjs/babel-plugin', () => {
`);
});

test('strip leading zeros from negative values', () => {
const code = transform(`
import stylex from 'stylex';
const styles = stylex.create({ x: { marginTop: '-0.5px' } });
`);
expect(code).toContain('margin-top:-.5px');
expect(code).not.toContain('-0.5px');
});

test('use double quotes in empty strings', () => {
expect(
transform(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function normalizeLeadingZero(
return;
}
const dimension = parser.unit(node.value);
if (value < 1 && value >= 0) {
if (Math.abs(value) < 1) {
node.value =
value.toString().replace('0.', '.') + (dimension ? dimension.unit : '');
}
Expand Down