@@ -157,9 +157,9 @@ fn specificity_same_selector() {
157157 padding: 10px;
158158 padding-left: 12px;
159159}"# ,
160- body = r#"<a class="test-class" href="https://example.com" >Test</a>"# ,
160+ body = r#"<a class="test-class">Test</a>"# ,
161161 // Then the final style should come from the more specific selector
162- expected = r#"<a class="test-class" href="https://example.com" style="padding-top: 15px;padding: 10px;padding-left: 12px;">Test</a>"#
162+ expected = r#"<a class="test-class" style="padding-top: 15px;padding: 10px;padding-left: 12px;">Test</a>"#
163163 )
164164}
165165
@@ -181,7 +181,16 @@ fn specificity_different_selectors_existing_style() {
181181.test { padding-left: 16px; }
182182h1 { padding: 0; }"# ,
183183 body = r#"<h1 class="test" style="color: blue;"></h1>"# ,
184- expected = r#"<h1 class="test" style="color: blue;padding: 0;padding-left: 16px"></h1>"#
184+ expected = r#"<h1 class="test" style="padding: 0;padding-left: 16px;color: blue"></h1>"#
185+ )
186+ }
187+
188+ #[ test]
189+ fn specificity_merge_with_existing_style ( ) {
190+ assert_inlined ! (
191+ style = ".test { padding: 0; }" ,
192+ body = r#"<h1 class="test" style="padding-left: 16px"></h1>"# ,
193+ expected = r#"<h1 class="test" style="padding: 0;padding-left: 16px"></h1>"#
185194 )
186195}
187196
@@ -243,7 +252,7 @@ fn important_no_rule_exists() {
243252 assert_inlined ! (
244253 style = "h1 { color: blue !important; }" ,
245254 body = r#"<h1 style="margin:0">Big Text</h1>"# ,
246- expected = r#"<h1 style="margin: 0;color: blue ">Big Text</h1>"#
255+ expected = r#"<h1 style="color: blue;margin: 0 ">Big Text</h1>"#
247256 )
248257}
249258
@@ -382,7 +391,7 @@ fn existing_styles_with_merge() {
382391 body = r#"<h1 style="color: blue">Hello world!</h1>"# ,
383392 // Then the existing rule should be preferred
384393 // And the new style should be merged
385- expected = r#"<h1 style="color: blue; font-size: 14px">Hello world!</h1>"#
394+ expected = r#"<h1 style="font-size: 14px;color: blue ">Hello world!</h1>"#
386395 )
387396}
388397
@@ -397,7 +406,7 @@ fn existing_styles_with_merge_multiple_tags() {
397406 r#"<h1 style="color: blue">Hello world!</h1><h1 style="color: blue">Hello world!</h1>"# ,
398407 // Then the existing rule should be preferred
399408 // And the new style should be merged
400- expected = r#"<h1 style="color: blue; font-size: 14px">Hello world!</h1><h1 style="color: blue; font-size: 14px">Hello world!</h1>"#
409+ expected = r#"<h1 style="font-size: 14px;color: blue ">Hello world!</h1><h1 style="font-size: 14px;color: blue ">Hello world!</h1>"#
401410 )
402411}
403412
0 commit comments