Browse Source

fix(compiler-sfc): use compilerOptions when re-parsing consumed AST

fixes hydration error for custom elements
Evan You 2 years ago
parent
commit
d94d8d4bff

+ 1 - 0
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
     // 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.
     // the AST location info to be relative to the entire SFC.
     const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, {
     const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, {
+      ...compilerOptions,
       parseMode: 'sfc',
       parseMode: 'sfc',
       onError: e => errors.push(e),
       onError: e => errors.push(e),
     })
     })

+ 2 - 2
packages/sfc-playground/src/App.vue

@@ -70,8 +70,8 @@ const sfcOptions: SFCOptions = {
   template: {
   template: {
     isProd: useProdMode.value,
     isProd: useProdMode.value,
     compilerOptions: {
     compilerOptions: {
-      isCustomElement: (tag: string) => tag === 'mjx-container'
-    }
+      isCustomElement: (tag: string) => tag === 'mjx-container',
+    },
   },
   },
 }
 }