Skip to content

Commit

Permalink
pretty print !important
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 7, 2024
1 parent 1d1fd46 commit d6a6322
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function toCss(ast: AstNode[]) {

// Declaration
else if (node.property !== '--tw-sort' && node.value !== undefined && node.value !== null) {
css += `${indent}${node.property}: ${node.value}${node.important ? '!important' : ''};\n`
css += `${indent}${node.property}: ${node.value}${node.important ? ' !important' : ''};\n`
}

return css
Expand Down
6 changes: 3 additions & 3 deletions packages/tailwindcss/src/compat/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1428,15 +1428,15 @@ test('important: true', async () => {

expect(compiler.build(['underline', 'hover:line-through', 'custom'])).toMatchInlineSnapshot(`
".custom {
color: red!important;
color: red !important;
}
.underline {
text-decoration-line: underline!important;
text-decoration-line: underline !important;
}
.hover\\:line-through {
&:hover {
@media (hover: hover) {
text-decoration-line: line-through!important;
text-decoration-line: line-through !important;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/tailwindcss/src/important.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ test('Utilities can be marked with important', async () => {

expect(compiler.build(['underline', 'hover:line-through'])).toMatchInlineSnapshot(`
".underline {
text-decoration-line: underline!important;
text-decoration-line: underline !important;
}
.hover\\:line-through {
&:hover {
@media (hover: hover) {
text-decoration-line: line-through!important;
text-decoration-line: line-through !important;
}
}
}
Expand All @@ -74,12 +74,12 @@ test('Utilities can be wrapped with a selector and marked as important', async (
expect(compiler.build(['underline', 'hover:line-through'])).toMatchInlineSnapshot(`
"#app {
.underline {
text-decoration-line: underline!important;
text-decoration-line: underline !important;
}
.hover\\:line-through {
&:hover {
@media (hover: hover) {
text-decoration-line: line-through!important;
text-decoration-line: line-through !important;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/intellisense.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ test('Utilities, when marked as important, show as important in intellisense', a
expect(design.candidatesToCss(['underline', 'hover:line-through'])).toMatchInlineSnapshot(`
[
".underline {
text-decoration-line: underline!important;
text-decoration-line: underline !important;
}
",
".hover\\:line-through {
&:hover {
@media (hover: hover) {
text-decoration-line: line-through!important;
text-decoration-line: line-through !important;
}
}
}
Expand Down

0 comments on commit d6a6322

Please sign in to comment.