Skip to content

Commit 3921f63

Browse files
author
Richard Feldman
committed
Don't store !important separately from value.
1 parent 824f398 commit 3921f63

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

src/Css.elm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,15 @@ declaration.
17691769
-}
17701770
important : Style -> Style
17711771
important =
1772-
Preprocess.mapLastProperty (\property -> { property | important = True })
1772+
Preprocess.mapLastProperty (\property -> { property | value = makeImportant property.value })
1773+
1774+
1775+
makeImportant : String -> String
1776+
makeImportant value =
1777+
if String.endsWith " !important" (String.toLower value) then
1778+
value
1779+
else
1780+
value ++ " !important"
17731781

17741782

17751783
{-| A [`ColorValue`](#ColorValue) that does not have `red`, `green`, or `blue`
@@ -7744,7 +7752,7 @@ batch =
77447752
-}
77457753
property : String -> String -> Style
77467754
property key value =
7747-
{ key = key, value = value, important = False }
7755+
{ key = key, value = value }
77487756
|> Preprocess.AppendProperty
77497757

77507758

src/Css/Preprocess.elm

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ stylesheet snippets =
1919
type alias Property =
2020
{ key : String
2121
, value : String
22-
, important : Bool
2322
}
2423

2524

@@ -154,11 +153,4 @@ toPropertyPairs styles =
154153

155154
propertyToPair : Property -> ( String, String )
156155
propertyToPair property =
157-
let
158-
value =
159-
if property.important then
160-
property.value ++ " !important"
161-
else
162-
property.value
163-
in
164-
( property.key, value )
156+
( property.key, property.value )

src/Css/Structure.elm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ type alias Number compatible =
1616
{ compatible | value : String, number : Compatible }
1717

1818

19-
{-| A property consisting of a key, a value, and a flag for whether or not
20-
the property is `!important`.
19+
{-| A property consisting of a key and a value
2120
-}
2221
type alias Property =
23-
{ important : Bool
24-
, key : String
22+
{ key : String
2523
, value : String
2624
}
2725

src/Css/Structure/Output.elm

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,8 @@ combinatorToString combinator =
229229

230230

231231
prettyPrintProperty : Property -> String
232-
prettyPrintProperty { key, value, important } =
233-
let
234-
suffix =
235-
if important then
236-
" !important;"
237-
else
238-
";"
239-
in
240-
key ++ ": " ++ value ++ suffix
232+
prettyPrintProperty { key, value } =
233+
key ++ ": " ++ value ++ ";"
241234

242235

243236
{-| Indent the given string with 4 spaces

0 commit comments

Comments
 (0)