From 36903c83f81ec2f8b1f0bd6edf2ff5e09b3a465d Mon Sep 17 00:00:00 2001 From: pynnl Date: Fri, 12 Jul 2019 06:36:34 -0400 Subject: [PATCH] fix global keyframes with no elements --- src/compiler/compile/css/Stylesheet.ts | 5 +++++ .../samples/global-keyframes-with-no-elements/expected.css | 1 + .../samples/global-keyframes-with-no-elements/input.svelte | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 test/css/samples/global-keyframes-with-no-elements/expected.css create mode 100644 test/css/samples/global-keyframes-with-no-elements/input.svelte diff --git a/src/compiler/compile/css/Stylesheet.ts b/src/compiler/compile/css/Stylesheet.ts index 49f11bc1f2..d448cda58e 100644 --- a/src/compiler/compile/css/Stylesheet.ts +++ b/src/compiler/compile/css/Stylesheet.ts @@ -217,6 +217,11 @@ class Atrule { if (type === 'Identifier') { if (name.startsWith('-global-')) { code.remove(start, start + 8); + this.children.forEach((rule: Rule) => { + rule.selectors.forEach(selector => { + selector.used = true; + }); + }); } else { code.overwrite(start, end, keyframes.get(name)); } diff --git a/test/css/samples/global-keyframes-with-no-elements/expected.css b/test/css/samples/global-keyframes-with-no-elements/expected.css new file mode 100644 index 0000000000..50a57ac471 --- /dev/null +++ b/test/css/samples/global-keyframes-with-no-elements/expected.css @@ -0,0 +1 @@ +@keyframes why{0%{color:red}100%{color:blue}} \ No newline at end of file diff --git a/test/css/samples/global-keyframes-with-no-elements/input.svelte b/test/css/samples/global-keyframes-with-no-elements/input.svelte new file mode 100644 index 0000000000..09499df7ee --- /dev/null +++ b/test/css/samples/global-keyframes-with-no-elements/input.svelte @@ -0,0 +1,6 @@ + \ No newline at end of file