1- use crate :: utils:: convert_value;
21use crate :: StyleProperty ;
2+ use crate :: utils:: convert_value;
33use css:: {
4- css_to_classname, sheet_to_classname, sheet_to_variable_name, short_to_long, StyleSelector ,
4+ StyleSelector , css_to_classname, optimize_value, sheet_to_classname, sheet_to_variable_name,
5+ short_to_long,
56} ;
67use once_cell:: sync:: Lazy ;
78use std:: collections:: HashSet ;
89
9- #[ derive( Debug , PartialEq , Clone ) ]
10+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
1011pub struct ExtractStaticStyle {
1112 /// property
1213 property : String ,
@@ -46,11 +47,11 @@ impl ExtractStaticStyle {
4647 /// create a new ExtractStaticStyle
4748 pub fn new ( property : & str , value : & str , level : u8 , selector : Option < StyleSelector > ) -> Self {
4849 Self {
49- value : if MAINTAIN_VALUE_PROPERTIES . contains ( property) {
50+ value : optimize_value ( & if MAINTAIN_VALUE_PROPERTIES . contains ( property) {
5051 value. to_string ( )
5152 } else {
5253 convert_value ( value)
53- } ,
54+ } ) ,
5455 property : short_to_long ( property) ,
5556 level,
5657 selector,
@@ -65,11 +66,11 @@ impl ExtractStaticStyle {
6566 selector : Option < StyleSelector > ,
6667 ) -> Self {
6768 Self {
68- value : if MAINTAIN_VALUE_PROPERTIES . contains ( property) {
69+ value : optimize_value ( & if MAINTAIN_VALUE_PROPERTIES . contains ( property) {
6970 value. to_string ( )
7071 } else {
7172 convert_value ( value)
72- } ,
73+ } ) ,
7374 property : property. to_string ( ) ,
7475 level,
7576 selector,
@@ -109,20 +110,19 @@ impl ExtractStyleProperty for ExtractStaticStyle {
109110 StyleProperty :: ClassName ( sheet_to_classname (
110111 self . property . as_str ( ) ,
111112 self . level ,
112- Some (
113- if MAINTAIN_VALUE_PROPERTIES . contains ( self . property . as_str ( ) ) {
113+ Some ( & optimize_value (
114+ & if MAINTAIN_VALUE_PROPERTIES . contains ( self . property . as_str ( ) ) {
114115 self . value . to_string ( )
115116 } else {
116117 convert_value ( self . value . as_str ( ) )
117- }
118- . as_str ( ) ,
119- ) ,
118+ } ,
119+ ) ) ,
120120 s. as_deref ( ) ,
121121 self . style_order ,
122122 ) )
123123 }
124124}
125- #[ derive( Debug , PartialEq , Clone ) ]
125+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
126126pub struct ExtractCss {
127127 /// css code
128128 pub css : String ,
@@ -135,7 +135,7 @@ impl ExtractStyleProperty for ExtractCss {
135135 }
136136}
137137
138- #[ derive( Debug , PartialEq , Clone ) ]
138+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
139139pub struct ExtractDynamicStyle {
140140 /// property
141141 property : String ,
@@ -207,7 +207,7 @@ impl ExtractStyleProperty for ExtractDynamicStyle {
207207 }
208208 }
209209}
210- #[ derive( Debug , PartialEq , Clone ) ]
210+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
211211pub enum ExtractStyleValue {
212212 Static ( ExtractStaticStyle ) ,
213213 Typography ( String ) ,
0 commit comments