@@ -318,7 +318,16 @@ impl Format<CssFormatContext> for FormatDimension {
318318 [ format_replaced(
319319 & self . token,
320320 & text(
321- & map_dimension_casing( lowercase) ,
321+ // Most CSS dimensions can be formatted as lower case, but there are
322+ // a few that are more commonly formatted with some uppercase characters.
323+ // This maps those few cases to the correct casing. This matches the
324+ // behavior of the Prettier formatter.
325+ & match lowercase. as_str( ) {
326+ "hz" => String :: from( "Hz" ) ,
327+ "khz" => String :: from( "kHz" ) ,
328+ "q" => String :: from( "Q" ) ,
329+ _ => lowercase,
330+ } ,
322331 self . token. text_trimmed_range( ) . start( )
323332 ) ,
324333 ) ]
@@ -327,23 +336,3 @@ impl Format<CssFormatContext> for FormatDimension {
327336 }
328337 }
329338}
330-
331- /// Most CSS dimensions can be formatted as lower case, but there are a few that are more commonly
332- /// formatted with some uppercase characters. This function maps those few cases to the correct casing and returns the
333- /// rest as-is. This matches the behavior of the Prettier formatter.
334- ///
335- /// The function takes and returns ownership so that we can return the original and not reallocate if it is not modified.
336- ///
337- /// ***Note:*** Input is expected to be lowercase.
338- ///
339- /// # Reference
340- ///
341- /// [Absolute length units](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Values_and_units/Numeric_data_types#absolute_length_units)
342- fn map_dimension_casing ( value : String ) -> String {
343- match value. as_str ( ) {
344- "hz" => String :: from ( "Hz" ) ,
345- "khz" => String :: from ( "kHz" ) ,
346- "q" => String :: from ( "Q" ) ,
347- _ => value,
348- }
349- }
0 commit comments