mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
Ignore keyframes in computeStyle
Ref https://github.com/svg/svgo/issues/1408
This commit is contained in:
@ -61,6 +61,9 @@ const parseStylesheet = (css, dynamic) => {
|
||||
return csstree.walk.skip;
|
||||
}
|
||||
if (cssNode.type === 'Atrule') {
|
||||
if (cssNode.name === 'keyframes') {
|
||||
return csstree.walk.skip;
|
||||
}
|
||||
csstree.walk(cssNode, (ruleNode) => {
|
||||
if (ruleNode.type === 'Rule') {
|
||||
rules.push(parseRule(ruleNode, dynamic || true));
|
||||
|
@ -212,4 +212,35 @@ describe('computeStyle', () => {
|
||||
});
|
||||
expect(computeStyle(root.querySelector('#invalid-type'))).to.deep.equal({});
|
||||
});
|
||||
|
||||
it('ignores keyframes atrule', () => {
|
||||
const root = svg2js(`
|
||||
<svg>
|
||||
<style>
|
||||
.a {
|
||||
animation: loading 4s linear infinite;
|
||||
}
|
||||
@keyframes loading {
|
||||
0% {
|
||||
stroke-dashoffset: 440;
|
||||
}
|
||||
50% {
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
50.1% {
|
||||
stroke-dashoffset: 880;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<rect id="element" class="a" />
|
||||
</svg>
|
||||
`);
|
||||
expect(computeStyle(root.querySelector('#element'))).to.deep.equal({
|
||||
animation: {
|
||||
type: 'static',
|
||||
inherited: false,
|
||||
value: 'loading 4s linear infinite',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user