Skip to content

Commit fe9a68d

Browse files
committed
Fix prefixed animation name replacement
1 parent 17000e3 commit fe9a68d

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ indent_size = 2
88
charset = utf-8
99
trim_trailing_whitespace = true
1010

11+
[test/**/expected.css]
12+
insert_final_newline = false
13+
1114
[{package.json,.travis.yml,.eslintrc.json}]
1215
indent_style = space
1316
indent_size = 2

src/css/Stylesheet.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { getLocator } from 'locate-character';
44
import Selector from './Selector';
55
import getCodeFrame from '../utils/getCodeFrame';
66
import hash from '../utils/hash';
7-
import isKeyframesNode from '../utils/isKeyframesNode';
7+
import removeCSSPrefix from '../utils/removeCSSPrefix';
88
import Element from '../compile/nodes/Element';
99
import { Validator } from '../validate/index';
1010
import { Node, Ast, Warning } from '../interfaces';
1111

12+
const isKeyframesNode = (node: Node) => removeCSSPrefix(node.name) === 'keyframes'
13+
1214
class Rule {
1315
selectors: Selector[];
1416
declarations: Declaration[];
@@ -97,7 +99,7 @@ class Declaration {
9799
}
98100

99101
transform(code: MagicString, keyframes: Map<string, string>) {
100-
const property = this.node.property && this.node.property.toLowerCase();
102+
const property = this.node.property && removeCSSPrefix(this.node.property.toLowerCase());
101103
if (property === 'animation' || property === 'animation-name') {
102104
this.node.value.children.forEach((block: Node) => {
103105
if (block.type === 'Identifier') {

src/utils/isKeyframesNode.ts

-7
This file was deleted.

src/utils/removeCSSPrefix.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function(name: string): string {
2+
return name.replace(/^-((webkit)|(moz)|(o)|(ms))-/, '');
3+
}

test/css/samples/keyframes-autoprefixed/expected.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/css/samples/keyframes-autoprefixed/input.html

+2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
}
2424

2525
.animated {
26+
-webkit-animation: why 2s;
2627
animation: why 2s;
2728
}
2829

2930
.also-animated {
31+
-webkit-animation: not-defined-here 2s;
3032
animation: not-defined-here 2s;
3133
}
3234
</style>

0 commit comments

Comments
 (0)