Skip to content
Merged
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
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ function print_declaration(node, css, indent_level) {
value = value.replace(/\s*\/\s*/, '/')
}

// Hacky: add a space in case of a `space toggle` during minification
if (value === EMPTY_STRING && OPTIONAL_SPACE === EMPTY_STRING) {
value += SPACE
}

return indent(indent_level) + property + COLON + OPTIONAL_SPACE + value
}

Expand Down
8 changes: 8 additions & 0 deletions test/atrules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ test('@media prelude formatting', () => {
}
})

test.skip('calc() inside @media', () => {
let actual = format(`
@media (min-width: calc(300px* 3)) {}
`)
let expected = `@media (min-width: calc(300px * 3)) {}`
assert.equal(actual, expected)
})

test('@supports prelude formatting', () => {
let fixtures = [
[`@supports (display:grid){}`, `@supports (display: grid) {}`],
Expand Down
37 changes: 37 additions & 0 deletions test/values.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ test('lowercases CSS functions', () => {
assert.is(actual, expected)
})

test('relative colors', () => {
let actual = format(`a {
color: rgb( from red 0 0 255);
color: rgb( from rgb( 200 0 0 ) r r r ) ;
color: hwb( from var( --base-color ) h w b / var( --standard-opacity ) ) ;
color: lch(from var(--base-color) calc(l + 20) c h);
}`)
let expected = `a {
color: rgb(from red 0 0 255);
color: rgb(from rgb(200 0 0) r r r);
color: hwb(from var(--base-color) h w b / var(--standard-opacity));
color: lch(from var(--base-color) calc(l + 20) c h);
}`
assert.is(actual, expected)
})

test('does not change casing of `NaN`', () => {
let actual = format(`a {
height: calc(1 * NaN);
Expand Down Expand Up @@ -223,4 +239,25 @@ test('formats unknown content in value', () => {
assert.is(actual, expected)
})

test('does not break space toggles', () => {
let actual = format(`a {
--ON: initial;
--OFF: ;
}`)
let expected = `a {
--ON: initial;
--OFF: ;
}`
assert.is(actual, expected)
})

test('does not break space toggles (minified)', () => {
let actual = format(`a {
--ON: initial;
--OFF: ;
}`, { minify: true })
let expected = `a{--ON:initial;--OFF: }`
assert.is(actual, expected)
})

test.run();