Closed jack-guy closed 2 years ago
I have no idea/memory why it sorts them. Seems odd. Try removing it and see if the tests break.
Also, perhaps you should add a test that uses that great example of padding-left: ....; padding: ...
to assert that output.find('padding:') > output.find('padding-left:')
or something.
Go for it!
@peterbe thanks for the quick response! Opened https://github.com/peterbe/premailer/pull/261 - if you're able to merge / release this change that would be a big help to me!
Cheers
if you're able to merge / release this change that would be a big help to me!
I'll say it now so I don't forget. Please remind me to kick off a release once this is merged. Just in case I forget.
For the following styles:
The browser should see the padding rules as all having the same precedence. As a tie-breaker, whichever appears last in the list applies (in this case
padding: 4px
).Premailer appears to be sorting styles alphabetically in
csstext_to_pairs
. This causes thepadding
rule to appear before the others and breaks the precedence.Is there any reason to be sorting styles in this way? Would you be open to a PR removing this sort?