Closed Stadly closed 8 years ago
isn't this a duplicate of #155 ?
Yes. How did I overlook that? 👎 It seems that https://github.com/tijsverkoyen/CssToInlineStyles/pull/155 fixes the first issue, while the second issue where inline styles are not put last is not fixed by that PR.
Improved this and made https://github.com/tijsverkoyen/CssToInlineStyles/pull/160.
Fixed in #160
When a property can be set using different names, such as
padding
andpadding-left
, the inlined styles were not always correctly ordered.Examples:
Will result in
<span style="background-color: blue; background: red;">This should be blue</span>
even thoughbackground-color: blue;
has higher specificity thanbackground: red;
. This issue is fixed by sorting all rules by specificity instead of order of appearance: https://github.com/tijsverkoyen/CssToInlineStyles/commit/bdf1c2e623ccfcf4de2d6d30264687632715228dWill result in
<span style="background-color: blue; background: red;">This should be blue</span>
since the styles being inlined are positioned after the styles that were already inline. This issue is fixed by positioning the styles that were already inline last: https://github.com/tijsverkoyen/CssToInlineStyles/commit/716da4a48b2d76b05c4069e41fd03433e39c3633, https://github.com/tijsverkoyen/CssToInlineStyles/commit/e7d45286a41bd43ae6acba96e9c5412218c8c6e3