From d94d8d4bffd1daf171a655b292745ffc3e63052d Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 2 Jan 2024 10:55:10 +0800 Subject: [PATCH] fix(compiler-sfc): use compilerOptions when re-parsing consumed AST fixes hydration error for custom elements --- packages/compiler-sfc/src/compileTemplate.ts | 1 + packages/sfc-playground/src/App.vue | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/compiler-sfc/src/compileTemplate.ts b/packages/compiler-sfc/src/compileTemplate.ts index 019aa5b0d65..5b7fe268366 100644 --- a/packages/compiler-sfc/src/compileTemplate.ts +++ b/packages/compiler-sfc/src/compileTemplate.ts @@ -219,6 +219,7 @@ function doCompileTemplate({ // We need to parse a fresh one. Can't just use `source` here since we need // the AST location info to be relative to the entire SFC. const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, { + ...compilerOptions, parseMode: 'sfc', onError: e => errors.push(e), }) diff --git a/packages/sfc-playground/src/App.vue b/packages/sfc-playground/src/App.vue index de6c24dded0..e8aeeeaef56 100644 --- a/packages/sfc-playground/src/App.vue +++ b/packages/sfc-playground/src/App.vue @@ -70,8 +70,8 @@ const sfcOptions: SFCOptions = { template: { isProd: useProdMode.value, compilerOptions: { - isCustomElement: (tag: string) => tag === 'mjx-container' - } + isCustomElement: (tag: string) => tag === 'mjx-container', + }, }, }