@@ -247,15 +247,16 @@ impl<'a> CSSInliner<'a> {
247247 if let Some ( extra_css) = & self . options . extra_css {
248248 process_css ( & document, extra_css, & mut styles) ;
249249 }
250- for ( node_id, styles) in styles {
251- let node = & mut document[ node_id] ;
250+ for ( node_id, styles) in styles. iter_mut ( ) {
251+ let node = & mut document[ * node_id] ;
252252 let element = if let Some ( element) = node. as_not_ignored_element_mut ( ) {
253253 element
254254 } else {
255255 continue ;
256256 } ;
257257 let attributes = & mut element. attributes ;
258258 if let Some ( existing_style) = attributes. get_style_mut ( ) {
259+ styles. sort_unstable_by ( |_, ( a, _) , _, ( b, _) | a. cmp ( b) ) ;
259260 * existing_style = merge_styles ( existing_style, & styles) ?. into ( ) ;
260261 } else {
261262 let mut final_styles = String :: with_capacity ( 128 ) ;
@@ -429,8 +430,6 @@ fn merge_styles(
429430 // This property won't be taken from new styles unless it's !important
430431 buffer. push ( name. to_string ( ) ) ;
431432 }
432- let mut new_styles = new_styles. iter ( ) . collect :: < Vec < _ > > ( ) ;
433- new_styles. sort_unstable_by ( |( _, ( a, _) ) , ( _, ( b, _) ) | a. cmp ( b) ) ;
434433 for ( property, ( _, value) ) in new_styles {
435434 match (
436435 value. strip_suffix ( "!important" ) ,
0 commit comments