Ver Fonte

fix(hmr): handle reload for template-only components switching between vapor and vdom

daiwei há 4 meses atrás
pai
commit
bfd4f1887a
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      packages/runtime-core/src/hmr.ts

+ 2 - 1
packages/runtime-core/src/hmr.ts

@@ -117,13 +117,14 @@ function reload(id: string, newComp: HMRComponent): void {
   if (!record) return
   if (!record) return
 
 
   newComp = normalizeClassComponent(newComp)
   newComp = normalizeClassComponent(newComp)
+  const isVapor = record.initialDef.__vapor
   // update initial def (for not-yet-rendered components)
   // update initial def (for not-yet-rendered components)
   updateComponentDef(record.initialDef, newComp)
   updateComponentDef(record.initialDef, newComp)
 
 
   // create a snapshot which avoids the set being mutated during updates
   // create a snapshot which avoids the set being mutated during updates
   const instances = [...record.instances]
   const instances = [...record.instances]
 
 
-  if (newComp.__vapor && !instances.some(i => i.ceReload)) {
+  if (isVapor && newComp.__vapor && !instances.some(i => i.ceReload)) {
     // For multiple instances with the same __hmrId, remove styles first before reload
     // For multiple instances with the same __hmrId, remove styles first before reload
     // to avoid the second instance's style removal deleting the first instance's
     // to avoid the second instance's style removal deleting the first instance's
     // newly added styles (since hmrReload is synchronous)
     // newly added styles (since hmrReload is synchronous)