diff --git a/src/index.test.js b/src/index.test.js index 436dd8d..f871ccf 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -91,6 +91,15 @@ it('allows omitting units for 0', () => runTest([ marginLeft: 0, })); +it('allows omitting units for margin shorthand', () => runTest([ + ['margin', '6 9'], +], { + marginTop: 6, + marginRight: 9, + marginBottom: 6, + marginLeft: 9, +})); + it('transforms strings', () => runTest([ ['color', 'red'], ], { color: 'red' })); @@ -432,6 +441,6 @@ it('allows blacklisting shorthands', () => { }); it('throws useful errors', () => { - expect(() => transformCss([['margin', '10']])) - .toThrow('Failed to parse declaration "margin: 10"'); + expect(() => transformCss([['margin', '#fff']])) + .toThrow('Failed to parse declaration "margin: #fff'); }); diff --git a/src/transforms/util.js b/src/transforms/util.js index 03bdcf1..bafe5a1 100644 --- a/src/transforms/util.js +++ b/src/transforms/util.js @@ -1,9 +1,9 @@ const { tokens } = require('../tokenTypes'); -const { LENGTH, PERCENT, SPACE } = tokens; +const { LENGTH, PERCENT, NUMBER, SPACE } = tokens; module.exports.directionFactory = ({ - types = [LENGTH, PERCENT], + types = [LENGTH, PERCENT, NUMBER], directions = ['Top', 'Right', 'Bottom', 'Left'], prefix = '', suffix = '',