diff --git a/index.js b/index.js index 1c8b67b..cc274bd 100644 --- a/index.js +++ b/index.js @@ -428,6 +428,10 @@ export function format(css, { minify = false } = {}) { value += SPACE } + if (node.important) { + value += OPTIONAL_SPACE + '!important' + } + return indent(indent_level) + property + COLON + OPTIONAL_SPACE + value } diff --git a/test/declarations.test.js b/test/declarations.test.js index ff7446c..d987dab 100644 --- a/test/declarations.test.js +++ b/test/declarations.test.js @@ -73,14 +73,18 @@ test('does not lowercase custom properties', () => { assert.is(actual, expected) }) -test.skip('preserves comments', () => { - let actual = format(`a { - /* comment */color: green; - color/* comment */: green; - }`) +test('!important is added', () => { + let actual = format(`a { color: green !important}`) + let expected = `a { + color: green !important; +}` + assert.is(actual, expected) +}) + +test('!important is lowercase', () => { + let actual = format(`a { color: green !IMPORTANT }`) let expected = `a { - /* comment */color: green; - color/* comment */: green; + color: green !important; }` assert.is(actual, expected) }) diff --git a/test/minify.test.js b/test/minify.test.js index cfc774c..026bd7b 100644 --- a/test/minify.test.js +++ b/test/minify.test.js @@ -77,4 +77,10 @@ test('minified Vadims example', () => { assert.equal(actual, expected) }) +test('removes whitespace before !important', () => { + let actual = minify(`a { color: green !important }`) + let expected = `a{color:green!important}` + assert.equal(actual, expected) +}) + test.run()