Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prioritize important styles #398

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

tborg
Copy link
Contributor

@tborg tborg commented Nov 14, 2024

When two selectors would set a property for an element, if one of those selectors is important then it should take precedence over non-important selector. If they are both important, or neither are important, then specificity is enough.

I observed this issue when comparing generated emails against the output of the node inline-css library. Here's a simple playground input/output that demonstrates the problem:

<html>
  <head>
    <style>
      .tw-text-secondary { color: rgb(119, 119, 119) !important; }
      ._reset_q8zsn_1 { color: unset; }
    </style>
  </head>
  <body>
    <span class="_reset_q8zsn_1 tw-text-secondary">Big Text</span>
  </body>
</html>
<html><head>
    
  </head>
  <body>
    <span class="pc-reset _reset_q8zsn_1 tw-font-body tw-text-ssm tw-text-substack-secondary" style="color: unset;">Big Text</span>
  
</body></html>

Note that if you reverse the order of the rule declarations, you get the correct behavior.

Copy link

codspeed-hq bot commented Nov 14, 2024

CodSpeed Performance Report

Merging #398 will not alter performance

Comparing tborg:tborg-fix-merge (72154dd) with master (143cd63)

Summary

✅ 6 untouched benchmarks

css-inline/src/lib.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.22%. Comparing base (143cd63) to head (72154dd).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #398      +/-   ##
==========================================
+ Coverage   89.17%   89.22%   +0.04%     
==========================================
  Files          18       18              
  Lines        1913     1921       +8     
==========================================
+ Hits         1706     1714       +8     
  Misses        207      207              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tborg tborg marked this pull request as ready for review November 14, 2024 01:15
@tborg
Copy link
Contributor Author

tborg commented Nov 14, 2024

Hi @Stranger6667 — very glad you were able to release 0.14.2 on Monday!

Here's another patch for you — please let me know if this seems reasonable to you and whether there's anything I can do to make it better.

@Stranger6667
Copy link
Owner

Hi @tborg

Thank you so much for fixing this :) Absolutely reasonable! I am going to make a new patch release soon

@Stranger6667 Stranger6667 merged commit 606cc93 into Stranger6667:master Nov 14, 2024
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants