Closed SethFalco closed 1 year ago
That's a pretty interesting bug. There is no a big deal that css-tree treated from
/to
as TypeSelector
but CSSO should avoid applying usage filtering to @keyframe
rules as well as for other special at-rules like @page
(not the case for SVGO but still). I think to fix it we need add an additional check here that a rule don't belong to a special at-rule like @keyframe
, @page
etc.
When an SVG has key frames with
to
orfrom
, CSSO will remove them, which changes the animation.Expected Behavior
The
to
andfrom
frames should be preserved/converted, otherwise it modifies the animation.For example:
0%,to{clip-path:inset(84%0 0)}
, should not become0%{clip-path:inset(84%0 0)}
.Minimal Working Example
The SVG I'm optimizing in SVGO.
A minimal example (using my actual use-case) of how it's being passed to CSSO.
I think the issue is caused by
to
/from
being interpreted as aTypeSelector
in the AST, and then being stripped out because it's not in the whitelisted array oftags
.Before I do anything else, I'm wondering, is CSSTree correct to report that as a
TypeSelector
? 🤔This might be a bug in CSSTree, since
to
andfrom
aren't type selectors. (https://www.w3.org/TR/selectors-3/#type-selectors) If they had to be named, it'd probably fall under keyframe selectors, orKeyframeSelector
. (https://www.w3.org/TR/css-animations-1/#typedef-keyframe-selector)Related