peterbe / premailer

Turns CSS blocks into style attributes
https://premailer.io
BSD 3-Clause "New" or "Revised" License
1.06k stars 188 forks source link

Bug: Global style with !important do not take precedence over the respective inline style #273

Open earshinov opened 2 years ago

earshinov commented 2 years ago

For example:

import premailer

html = """
<html>
    <style type="text/css">
        img { height: auto !important; }
    </style>
    <body>
        <img src="https://via.placeholder.com/200x200" style="height: 400px;"></img>
    </body>
</html>
"""

print(premailer.transform(html))
#<html>
#    <head></head><body>
#        <img src="https://via.placeholder.com/200x200" style="height:400px" height="400">
#    </body>
#</html>

Expected result - !important takes precedence:

<img src="https://via.placeholder.com/200x200" style="height:auto" height="auto">

❌ Actual result - inline style takes precedence:

<img src="https://via.placeholder.com/200x200" style="height:400px" height="400">

Version information:

>>> premailer.__version__
'3.10.0'