Skip to content

Commit 7a85f92

Browse files
authored
Merge branch 'minor' into setup-render
2 parents 3e6130e + 918b50f commit 7a85f92

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ export class EffectScope implements ReactiveNode {
7373
return
7474
}
7575
this.flags = EffectFlags.STOP
76+
this.reset()
77+
const sub = this.subs
78+
if (sub !== undefined) {
79+
unlink(sub)
80+
}
81+
}
82+
83+
/**
84+
* @internal
85+
*/
86+
reset(): void {
7687
let dep = this.deps
7788
while (dep !== undefined) {
7889
const node = dep.dep
@@ -83,10 +94,6 @@ export class EffectScope implements ReactiveNode {
8394
dep = unlink(dep, this)
8495
}
8596
}
86-
const sub = this.subs
87-
if (sub !== undefined) {
88-
unlink(sub)
89-
}
9097
cleanup(this)
9198
}
9299
}

packages/runtime-core/src/hmr.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ function reload(id: string, newComp: HMRComponent): void {
117117
if (!record) return
118118

119119
newComp = normalizeClassComponent(newComp)
120+
const isVapor = record.initialDef.__vapor
120121
// update initial def (for not-yet-rendered components)
121122
updateComponentDef(record.initialDef, newComp)
122123

123124
// create a snapshot which avoids the set being mutated during updates
124125
const instances = [...record.instances]
125126

126-
if (newComp.__vapor && !instances.some(i => i.ceReload)) {
127+
if (isVapor && newComp.__vapor && !instances.some(i => i.ceReload)) {
127128
// For multiple instances with the same __hmrId, remove styles first before reload
128129
// to avoid the second instance's style removal deleting the first instance's
129130
// newly added styles (since hmrReload is synchronous)

packages/runtime-vapor/src/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,7 @@ export class VaporComponentInstance<
592592
asyncDep: Promise<any> | null
593593
asyncResolved: boolean
594594

595-
// for HMR and vapor custom element
596-
// all render effects associated with this instance
595+
// for vapor custom element
597596
renderEffects?: RenderEffect[]
598597

599598
hasFallthrough: boolean

packages/runtime-vapor/src/hmr.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ export function hmrRerender(instance: VaporComponentInstance): void {
1919
const normalized = normalizeBlock(instance.block)
2020
const parent = normalized[0].parentNode!
2121
const anchor = normalized[normalized.length - 1].nextSibling
22+
// reset scope to avoid stale effects
23+
instance.scope.reset()
2224
remove(instance.block, parent)
2325
const prev = setCurrentInstance(instance)
24-
if (instance.renderEffects) {
25-
instance.renderEffects.forEach(e => e.stop())
26-
instance.renderEffects = []
27-
}
2826
pushWarningContext(instance)
2927
devRender(instance)
3028
popWarningContext()

packages/runtime-vapor/src/renderEffect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export class RenderEffect extends ReactiveEffect {
4444
: void 0
4545
}
4646

47-
if (__DEV__ || instance.type.ce) {
48-
// register effect for stopping them during HMR rerender
47+
// register effect for vapor custom element update
48+
if (instance.type.ce) {
4949
;(instance.renderEffects || (instance.renderEffects = [])).push(this)
5050
}
5151
job.i = instance

0 commit comments

Comments
 (0)