Browse Source

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

daiwei 4 months ago
parent
commit
bfd4f1887a
1 changed files with 2 additions and 1 deletions
  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
 
   newComp = normalizeClassComponent(newComp)
+  const isVapor = record.initialDef.__vapor
   // update initial def (for not-yet-rendered components)
   updateComponentDef(record.initialDef, newComp)
 
   // create a snapshot which avoids the set being mutated during updates
   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
     // to avoid the second instance's style removal deleting the first instance's
     // newly added styles (since hmrReload is synchronous)