From: Evan You Date: Tue, 2 Jan 2024 02:55:10 +0000 (+0800) Subject: fix(compiler-sfc): use compilerOptions when re-parsing consumed AST X-Git-Tag: v3.4.4~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d94d8d4bffd1daf171a655b292745ffc3e63052d;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): use compilerOptions when re-parsing consumed AST fixes hydration error for custom elements --- diff --git a/packages/compiler-sfc/src/compileTemplate.ts b/packages/compiler-sfc/src/compileTemplate.ts index 019aa5b0d6..5b7fe26836 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 de6c24dded..e8aeeeaef5 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', + }, }, }