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,
@@ -113,7 +114,7 @@ impl ExtractStyleProperty for ExtractStaticStyle {
113114 if MAINTAIN_VALUE_PROPERTIES . contains ( self . property . as_str ( ) ) {
114115 self . value . to_string ( )
115116 } else {
116- convert_value ( self . value . as_str ( ) )
117+ optimize_value ( convert_value ( self . value . as_str ( ) ) . as_str ( ) )
117118 }
118119 . as_str ( ) ,
119120 ) ,
@@ -122,7 +123,7 @@ impl ExtractStyleProperty for ExtractStaticStyle {
122123 ) )
123124 }
124125}
125- #[ derive( Debug , PartialEq , Clone ) ]
126+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
126127pub struct ExtractCss {
127128 /// css code
128129 pub css : String ,
@@ -135,7 +136,7 @@ impl ExtractStyleProperty for ExtractCss {
135136 }
136137}
137138
138- #[ derive( Debug , PartialEq , Clone ) ]
139+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
139140pub struct ExtractDynamicStyle {
140141 /// property
141142 property : String ,
@@ -207,7 +208,7 @@ impl ExtractStyleProperty for ExtractDynamicStyle {
207208 }
208209 }
209210}
210- #[ derive( Debug , PartialEq , Clone ) ]
211+ #[ derive( Debug , PartialEq , Clone , Eq , Hash , Ord , PartialOrd ) ]
211212pub enum ExtractStyleValue {
212213 Static ( ExtractStaticStyle ) ,
213214 Typography ( String ) ,
0 commit comments