From 2923e08a3ea8ecb2b2f2c68da75be1b20ec13557 Mon Sep 17 00:00:00 2001 From: ktsn Date: Sat, 13 Apr 2019 22:44:00 +0800 Subject: [PATCH] Skip v-slot check to avoid false-positive error --- server/src/modes/script/transformTemplate.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/modes/script/transformTemplate.ts b/server/src/modes/script/transformTemplate.ts index 4737384629..df05de7032 100644 --- a/server/src/modes/script/transformTemplate.ts +++ b/server/src/modes/script/transformTemplate.ts @@ -143,11 +143,16 @@ export function getTemplateTransformFunctions(ts: T_TypeScript) { return; } - // Skip v-for directive + // Skip v-for directive (handled in `transformElement`) if (isVFor(attr)) { return; } + // Skip v-slot and scope-slot for now + if (isVSlot(attr)) { + return; + } + // Other directives const exp = transformDirective(attr, code, scope); if (exp) { @@ -523,6 +528,10 @@ export function getTemplateTransformFunctions(ts: T_TypeScript) { return node.directive && node.key.name.name === 'for'; } + function isVSlot(node: AST.VAttribute | AST.VDirective): node is AST.VDirective { + return node.directive && (node.key.name.name === 'slot' || node.key.name.name === 'slot-scope'); + } + function flatMap(list: ReadonlyArray, fn: (value: T) => R[]): R[] { return list.reduce((acc, item) => { return acc.concat(fn(item));