Fix prefixed animation name replacement

pull/1556/head
Christian Kaisermann 7 years ago
parent 17000e38f6
commit fe9a68d071

@ -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

@ -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[];
@ -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') {

@ -1,7 +0,0 @@
import { Node } from '../interfaces';
export default function isKeyframesNode(node: Node): boolean {
return ['', '-webkit-', '-moz-', '-o-'].some(
prefix => node.name === `${prefix}keyframes`
);
}

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

@ -1 +1 @@
@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-webkit-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-moz-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-o-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{animation:not-defined-here 2s}
@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-webkit-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-moz-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}@-o-keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{-webkit-animation:svelte-xyz-why 2s;animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{-webkit-animation:not-defined-here 2s;animation:not-defined-here 2s}

@ -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>

Loading…
Cancel
Save