Skip to content

Commit

Permalink
fix: support -o-keyframes and -moz-keyframes (#2019)
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky authored Jun 14, 2024
1 parent 5481fc2 commit fea2637
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ const parseStylesheet = (css, dynamic) => {
}
if (cssNode.type === 'Atrule') {
if (
cssNode.name === 'keyframes' ||
cssNode.name === '-webkit-keyframes'
[
'keyframes',
'-webkit-keyframes',
'-o-keyframes',
'-moz-keyframes',
].includes(cssNode.name)
) {
return csstreeWalkSkip;
}
Expand Down
61 changes: 61 additions & 0 deletions lib/style.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,64 @@ it('ignores @-webkit-keyframes atrule', () => {
},
});
});
it('ignores @-moz-keyframes atrule', () => {
const root = parseSvg(`
<svg>
<style>
.a {
animation: loading 4s linear infinite;
}
@-moz-keyframes loading {
0% {
stroke-dashoffset: 440;
}
50% {
stroke-dashoffset: 0;
}
}
</style>
<rect id="element" class="a" />
</svg>
`);
const stylesheet = collectStylesheet(root);
expect(
computeStyle(stylesheet, getElementById(root, 'element')),
).toStrictEqual({
animation: {
type: 'static',
inherited: false,
value: 'loading 4s linear infinite',
},
});
});

it('ignores @-o-keyframes atrule', () => {
const root = parseSvg(`
<svg>
<style>
.a {
animation: loading 4s linear infinite;
}
@-o-keyframes loading {
0% {
stroke-dashoffset: 440;
}
50% {
stroke-dashoffset: 0;
}
}
</style>
<rect id="element" class="a" />
</svg>
`);
const stylesheet = collectStylesheet(root);
expect(
computeStyle(stylesheet, getElementById(root, 'element')),
).toStrictEqual({
animation: {
type: 'static',
inherited: false,
value: 'loading 4s linear infinite',
},
});
});

0 comments on commit fea2637

Please sign in to comment.