@@ -247,15 +247,16 @@ impl<'a> CSSInliner<'a> {
247
247
if let Some ( extra_css) = & self . options . extra_css {
248
248
process_css ( & document, extra_css, & mut styles) ;
249
249
}
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] ;
252
252
let element = if let Some ( element) = node. as_not_ignored_element_mut ( ) {
253
253
element
254
254
} else {
255
255
continue ;
256
256
} ;
257
257
let attributes = & mut element. attributes ;
258
258
if let Some ( existing_style) = attributes. get_style_mut ( ) {
259
+ styles. sort_unstable_by ( |_, ( a, _) , _, ( b, _) | a. cmp ( b) ) ;
259
260
* existing_style = merge_styles ( existing_style, & styles) ?. into ( ) ;
260
261
} else {
261
262
let mut final_styles = String :: with_capacity ( 128 ) ;
@@ -429,8 +430,6 @@ fn merge_styles(
429
430
// This property won't be taken from new styles unless it's !important
430
431
buffer. push ( name. to_string ( ) ) ;
431
432
}
432
- let mut new_styles = new_styles. iter ( ) . collect :: < Vec < _ > > ( ) ;
433
- new_styles. sort_unstable_by ( |( _, ( a, _) ) , ( _, ( b, _) ) | a. cmp ( b) ) ;
434
433
for ( property, ( _, value) ) in new_styles {
435
434
match (
436
435
value. strip_suffix ( "!important" ) ,
0 commit comments