Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prefixed animation name replacement #1556

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ indent_size = 2
charset = utf-8
trim_trailing_whitespace = true

[test/**/expected.css]
insert_final_newline = false

[{package.json,.travis.yml,.eslintrc.json}]
indent_style = space
indent_size = 2
6 changes: 4 additions & 2 deletions src/css/Stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { getLocator } from 'locate-character';
import Selector from './Selector';
import getCodeFrame from '../utils/getCodeFrame';
import hash from '../utils/hash';
import isKeyframesNode from '../utils/isKeyframesNode';
import removeCSSPrefix from '../utils/removeCSSPrefix';
import Element from '../compile/nodes/Element';
import { Validator } from '../validate/index';
import { Node, Ast, Warning } from '../interfaces';

const isKeyframesNode = (node: Node) => removeCSSPrefix(node.name) === 'keyframes'

class Rule {
selectors: Selector[];
declarations: Declaration[];
Expand Down Expand Up @@ -97,7 +99,7 @@ class Declaration {
}

transform(code: MagicString, keyframes: Map<string, string>) {
const property = this.node.property && this.node.property.toLowerCase();
const property = this.node.property && removeCSSPrefix(this.node.property.toLowerCase());
if (property === 'animation' || property === 'animation-name') {
this.node.value.children.forEach((block: Node) => {
if (block.type === 'Identifier') {
Expand Down
7 changes: 0 additions & 7 deletions src/utils/isKeyframesNode.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/utils/removeCSSPrefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function(name: string): string {
return name.replace(/^-((webkit)|(moz)|(o)|(ms))-/, '');
}
2 changes: 1 addition & 1 deletion test/css/samples/keyframes-autoprefixed/expected.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/css/samples/keyframes-autoprefixed/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
}

.animated {
-webkit-animation: why 2s;
animation: why 2s;
}

.also-animated {
-webkit-animation: not-defined-here 2s;
animation: not-defined-here 2s;
}
</style>