Commit 64c8027
fix: preserve !important when merging styles onto elements with existing inline styles
Two bugs in `merge_styles` caused `!important` flags to be lost during
CSS inlining when the target element already had an inline `style`
attribute:
1. Separator mismatch with minify_css: The property lookup in the
declarations buffer always used `": "` (STYLE_SEPARATOR), but when
minify_css is enabled, buffered declarations use `":"` (STYLE_SEPARATOR_MIN).
This caused the find to miss existing properties, leading to
duplicated declarations and lost `!important` flags.
2. !important stripped unconditionally: The `strip_suffix("!important")`
used internally to detect important rules was never re-appended to the
output. Both the override path (Some, Some) and the new-property path
(Some, None) wrote values without restoring the `!important` suffix.
Bug 1 affects only `minify_css: true`. Bug 2 affects all configurations.
This is particularly impactful for HTML email inlining where
`keep_style_tags: true` is used alongside rules like
`a[x-apple-data-detectors] { color: inherit !important }` that remain
in `<style>` tags — the missing `!important` on inlined button styles
allowed these reset rules to override intended button styling.1 parent 6fa8127 commit 64c8027
2 files changed
+90
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
703 | 708 | | |
704 | 709 | | |
705 | 710 | | |
| |||
708 | 713 | | |
709 | 714 | | |
710 | 715 | | |
711 | | - | |
712 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
713 | 719 | | |
714 | 720 | | |
715 | 721 | | |
716 | 722 | | |
717 | 723 | | |
718 | 724 | | |
719 | 725 | | |
720 | | - | |
721 | | - | |
| 726 | + | |
722 | 727 | | |
| 728 | + | |
723 | 729 | | |
724 | 730 | | |
725 | 731 | | |
726 | | - | |
727 | 732 | | |
728 | 733 | | |
729 | 734 | | |
| |||
732 | 737 | | |
733 | 738 | | |
734 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
735 | 747 | | |
736 | 748 | | |
737 | 749 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
306 | 374 | | |
307 | 375 | | |
308 | 376 | | |
| |||
332 | 400 | | |
333 | 401 | | |
334 | 402 | | |
335 | | - | |
| 403 | + | |
336 | 404 | | |
337 | 405 | | |
338 | 406 | | |
| |||
0 commit comments