You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The appearance of the following SVG is broken (in some browsers) by the inlineStyles plugin in conjuction with the convertStylesToAttrs plugin (both enabled by default).
It seems that not all browsers honour this — e.g. Firefox applies the fill="#FFF" although the '.c2' selector still matches — the problem is thus not visible. Other browsers (Chrome and Safari at least) apply the rule of the '.c2' selector so that the optimized image is visually different from the original.
If my understanding is right, the solution is to disable the convertStylesToAttrs plugin per default because it turns high precedence style attributes into low precedence fill (and the like) attributes. Although I've hit this issue because inlineStyles moves rules to the style attribute, the problem should also strike in case the original SVG has style attributes.
A more advanced solution would require convertStylesToAttrs to check whether the element matches any CSS selector that defines the same property and, if so, refrains from transforming the style attribute to the respective SVG attribute.
The text was updated successfully, but these errors were encountered:
@fatalmind: I always assumed that there is a precedence in this order (least specific to most specific): <style>; style="..."; style="... !important"attribute, hence the attribute value should always apply after everything else.
Disabling the onlyMatchedOnce option may be helpful because this would inline all styles that match.
There can be still an issue with non-inlineable styles though.
The appearance of the following SVG is broken (in some browsers) by the inlineStyles plugin in conjuction with the convertStylesToAttrs plugin (both enabled by default).
First, the inlineStyles plugin does it's work, which is fine:
Even though the '.c2' rule still applies to the second
rect
, thestyle
attribute takes precedence over thestyle
element.However, then the convertStyleToAttrs comes and turns the
style
attribute into afill
attribute (or the like).The problem is that the
fill
attribute has a very low precedence (as opposed tostyle
, which has the highest possible precedence).This is at least what I understand from the spec: https://www.w3.org/TR/CSS2/cascade.html#preshint
It seems that not all browsers honour this — e.g. Firefox applies the
fill="#FFF"
although the '.c2' selector still matches — the problem is thus not visible. Other browsers (Chrome and Safari at least) apply the rule of the '.c2' selector so that the optimized image is visually different from the original.If my understanding is right, the solution is to disable the convertStylesToAttrs plugin per default because it turns high precedence
style
attributes into low precedencefill
(and the like) attributes. Although I've hit this issue becauseinlineStyles
moves rules to thestyle
attribute, the problem should also strike in case the original SVG hasstyle
attributes.A more advanced solution would require convertStylesToAttrs to check whether the element matches any CSS selector that defines the same property and, if so, refrains from transforming the
style
attribute to the respective SVG attribute.The text was updated successfully, but these errors were encountered: