Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
T/16957 [PFW] Styles.inliner.inline does not take selectors specificity into account and duplicates rules. #348
The fix keeps the order of the css rules when parsing. The rules containing class selectors have higher priority and are applied first.
The styles already existing on the element are not overwritten which means:
The second point above means that the styles inlining applies rules containing class selectors first in a reversed order (so the last on goes first) and then rest of the rules also in reversed order.
Please keep in mind that this solution is a minimalistic (almost) approach to solve this specific issue. There are some cases which are not covered (more complex selectors, rules with multiple selectors, etc), however as Excel or Word does not generate such styles it is sufficient.
As for specificity we need only a minimal viable product here. So as long as current implementation solves the problem, this is all we need.
I checked a fancy/complex word file with multiple and haven't faced case like this. In case if some version will ever produce any incompatible markup we'll simply fix it in a patch release.
I find proposed structure redundant. I feel that it might be simplified by turning returned result into an array, and change a strucutre of entries.
So rather than:
Does it look feel better? Please drop a