From ca8365ef06def887139a72f58454460ffcce3627 Mon Sep 17 00:00:00 2001 From: Bryan Terce Date: Sat, 29 Jun 2019 15:20:26 -0700 Subject: [PATCH 1/2] Restore correct current_atrule --- src/compiler/compile/css/Stylesheet.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/compile/css/Stylesheet.ts b/src/compiler/compile/css/Stylesheet.ts index 2aead635b2..6267d0afb8 100644 --- a/src/compiler/compile/css/Stylesheet.ts +++ b/src/compiler/compile/css/Stylesheet.ts @@ -315,7 +315,14 @@ export default class Stylesheet { leave: (node: Node) => { if (node.type === 'Rule' || node.type === 'Atrule') stack.pop(); - if (node.type === 'Atrule') current_atrule = stack[stack.length - 1] as Atrule; + if (node.type === 'Atrule') { + current_atrule = null; + for (let i = stack.length - 1; i >= 0; i--) { + if (stack[i] instanceof Atrule) { + current_atrule = stack[i] as Atrule; + } + } + } } }); } else { From f654dd0ae4e2c764b5a24baab47928d5a47b2496 Mon Sep 17 00:00:00 2001 From: Bryan Terce Date: Sat, 29 Jun 2019 15:22:31 -0700 Subject: [PATCH 2/2] Add tests --- .../unknown-at-rule-with-following-rules/expected.css | 1 + .../unknown-at-rule-with-following-rules/input.svelte | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/css/samples/unknown-at-rule-with-following-rules/expected.css create mode 100644 test/css/samples/unknown-at-rule-with-following-rules/input.svelte diff --git a/test/css/samples/unknown-at-rule-with-following-rules/expected.css b/test/css/samples/unknown-at-rule-with-following-rules/expected.css new file mode 100644 index 0000000000..31c3bf9c6f --- /dev/null +++ b/test/css/samples/unknown-at-rule-with-following-rules/expected.css @@ -0,0 +1 @@ +div.svelte-xyz{@apply --funky-div;} \ No newline at end of file diff --git a/test/css/samples/unknown-at-rule-with-following-rules/input.svelte b/test/css/samples/unknown-at-rule-with-following-rules/input.svelte new file mode 100644 index 0000000000..b8947d3545 --- /dev/null +++ b/test/css/samples/unknown-at-rule-with-following-rules/input.svelte @@ -0,0 +1,11 @@ +
+ + \ No newline at end of file