@@ -6,18 +6,13 @@ use css::{
66 style_selector:: StyleSelector ,
77} ;
88
9- use crate :: {
10- ExtractStyleProp ,
11- extract_style:: {
12- extract_static_style:: ExtractStaticStyle , extract_style_value:: ExtractStyleValue ,
13- } ,
14- } ;
9+ use crate :: extract_style:: extract_static_style:: ExtractStaticStyle ;
1510
1611pub fn css_to_style < ' a > (
1712 css : & str ,
1813 level : u8 ,
1914 selector : & Option < StyleSelector > ,
20- ) -> Vec < ExtractStyleProp < ' a > > {
15+ ) -> Vec < ExtractStaticStyle > {
2116 let mut styles = vec ! [ ] ;
2217 let mut input = css;
2318
@@ -86,21 +81,15 @@ pub fn css_to_style<'a>(
8681 styles. extend ( css_to_style_block ( input, level, selector) ) ;
8782 }
8883
89- styles. sort_by_key ( |a| {
90- if let crate :: ExtractStyleProp :: Static ( crate :: ExtractStyleValue :: Static ( a) ) = a {
91- a. property ( ) . to_string ( )
92- } else {
93- "" . to_string ( )
94- }
95- } ) ;
84+ styles. sort_by_key ( |a| a. property ( ) . to_string ( ) ) ;
9685 styles
9786}
9887
9988fn css_to_style_block < ' a > (
10089 css : & str ,
10190 level : u8 ,
10291 selector : & Option < StyleSelector > ,
103- ) -> Vec < ExtractStyleProp < ' a > > {
92+ ) -> Vec < ExtractStaticStyle > {
10493 rm_css_comment ( css)
10594 . split ( ";" )
10695 . filter_map ( |s| {
@@ -116,17 +105,20 @@ fn css_to_style_block<'a>(
116105 } else {
117106 value. to_string ( )
118107 } ;
119- Some ( ExtractStyleProp :: Static ( ExtractStyleValue :: Static (
120- ExtractStaticStyle :: new ( property, & value, level, selector. clone ( ) ) ,
121- ) ) )
108+ Some ( ExtractStaticStyle :: new (
109+ property,
110+ & value,
111+ level,
112+ selector. clone ( ) ,
113+ ) )
122114 }
123115 } )
124116 . collect ( )
125117}
126118
127119pub fn keyframes_to_keyframes_style < ' a > (
128120 keyframes : & str ,
129- ) -> BTreeMap < String , Vec < ExtractStyleProp < ' a > > > {
121+ ) -> BTreeMap < String , Vec < ExtractStaticStyle > > {
130122 let mut map = BTreeMap :: new ( ) ;
131123 let mut input = keyframes;
132124
@@ -137,13 +129,7 @@ pub fn keyframes_to_keyframes_style<'a>(
137129 let block = & rest[ ..end] ;
138130 let mut styles = css_to_style ( block, 0 , & None ) ;
139131
140- styles. sort_by_key ( |a| {
141- if let crate :: ExtractStyleProp :: Static ( crate :: ExtractStyleValue :: Static ( a) ) = a {
142- a. property ( ) . to_string ( )
143- } else {
144- "" . to_string ( )
145- }
146- } ) ;
132+ styles. sort_by_key ( |a| a. property ( ) . to_string ( ) ) ;
147133 map. insert ( key, styles) ;
148134 input = & rest[ end + 1 ..] ;
149135 } else {
@@ -489,14 +475,7 @@ mod tests {
489475 let styles = css_to_style ( input, 0 , & None ) ;
490476 let mut result: Vec < ( & str , & str , Option < StyleSelector > ) > = styles
491477 . iter ( )
492- . filter_map ( |prop| {
493- if let crate :: ExtractStyleProp :: Static ( crate :: ExtractStyleValue :: Static ( st) ) = prop
494- {
495- Some ( ( st. property ( ) , st. value ( ) , st. selector ( ) . cloned ( ) ) )
496- } else {
497- None
498- }
499- } )
478+ . map ( |prop| ( prop. property ( ) , prop. value ( ) , prop. selector ( ) . cloned ( ) ) )
500479 . collect ( ) ;
501480 result. sort ( ) ;
502481 let mut expected_sorted = expected. clone ( ) ;
@@ -567,15 +546,7 @@ mod tests {
567546 let styles = expected_styles;
568547 let mut result: Vec < ( & str , & str ) > = styles
569548 . iter ( )
570- . filter_map ( |prop| {
571- if let crate :: ExtractStyleProp :: Static ( crate :: ExtractStyleValue :: Static ( st) ) =
572- prop
573- {
574- Some ( ( st. property ( ) , st. value ( ) ) )
575- } else {
576- None
577- }
578- } )
549+ . map ( |prop| ( prop. property ( ) , prop. value ( ) ) )
579550 . collect ( ) ;
580551 result. sort ( ) ;
581552 let mut expected_sorted = expected
0 commit comments