@@ -157,9 +157,9 @@ fn specificity_same_selector() {
157
157
padding: 10px;
158
158
padding-left: 12px;
159
159
}"# ,
160
- body = r#"<a class="test-class" href="https://example.com" >Test</a>"# ,
160
+ body = r#"<a class="test-class">Test</a>"# ,
161
161
// 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>"#
163
163
)
164
164
}
165
165
@@ -181,7 +181,16 @@ fn specificity_different_selectors_existing_style() {
181
181
.test { padding-left: 16px; }
182
182
h1 { padding: 0; }"# ,
183
183
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>"#
185
194
)
186
195
}
187
196
@@ -243,7 +252,7 @@ fn important_no_rule_exists() {
243
252
assert_inlined ! (
244
253
style = "h1 { color: blue !important; }" ,
245
254
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>"#
247
256
)
248
257
}
249
258
@@ -382,7 +391,7 @@ fn existing_styles_with_merge() {
382
391
body = r#"<h1 style="color: blue">Hello world!</h1>"# ,
383
392
// Then the existing rule should be preferred
384
393
// 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>"#
386
395
)
387
396
}
388
397
@@ -397,7 +406,7 @@ fn existing_styles_with_merge_multiple_tags() {
397
406
r#"<h1 style="color: blue">Hello world!</h1><h1 style="color: blue">Hello world!</h1>"# ,
398
407
// Then the existing rule should be preferred
399
408
// 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>"#
401
410
)
402
411
}
403
412
0 commit comments