From 8f4bbde8a4412d628ab6ef38c510bf5e3242361a Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Fri, 25 Sep 2020 17:45:06 +0200 Subject: [PATCH] Support {#key} block Needed for Svelte >2.28 --- package-lock.json | 6 +++--- package.json | 2 +- src/print/index.ts | 16 ++++++++++++++-- src/print/nodes.ts | 7 +++++++ test/printer/samples/key-block.html | 10 ++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 test/printer/samples/key-block.html diff --git a/package-lock.json b/package-lock.json index 824e21a9..483011c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4366,9 +4366,9 @@ } }, "svelte": { - "version": "3.22.2", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.22.2.tgz", - "integrity": "sha512-DxumO0+vvHA6NSc2jtVty08I8lFI43q8P2zX6JxZL8J1kqK5NVjad6TRM/twhnWXC+QScnwkZ15O6X1aTsEKTA==", + "version": "3.28.0", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.28.0.tgz", + "integrity": "sha512-WJW8wD+aTmU5GUnTUjdhVF35mve2MjylubLgB6fGWoXHpYENdwcwWsWvjMQLayzMynqNH733h1Ck8wJzNR7gdQ==", "dev": true }, "symbol-observable": { diff --git a/package.json b/package.json index 2dbd27b6..bd857862 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "rollup-plugin-commonjs": "9.2.0", "rollup-plugin-node-resolve": "4.0.0", "rollup-plugin-typescript": "1.0.0", - "svelte": "^3.20.0", + "svelte": "^3.28.0", "ts-node": "^7.0.1", "tslib": "^1.9.3", "typescript": "3.2.4" diff --git a/src/print/index.ts b/src/print/index.ts index 8de00406..2a10f1fc 100644 --- a/src/print/index.ts +++ b/src/print/index.ts @@ -377,6 +377,18 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D return group(concat(block)); } + case 'KeyBlock': { + const def: Doc[] = [ + '{#key ', + printJS(path, print, 'expression'), + '}', + printIndentedWithNewlines(path, print), + ]; + + def.push('{/key}'); + + return concat([group(concat(def)), breakParent]); + } case 'ThenBlock': case 'PendingBlock': case 'CatchBlock': @@ -439,7 +451,7 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D case 'Comment': { /** * If there is no sibling node that starts right after us but the parent indicates - * that there used to be, that means that node was actually an embedded `