Skip to content

Commit ea34a9e

Browse files
committed
refactor: rename internal fragment hook properties and private render method for consistency.
1 parent 8b56f2d commit ea34a9e

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

packages/runtime-vapor/src/apiCreateFor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export const createFor = (
396396
oldBlocks = []
397397
}
398398

399-
if (isMounted && frag.$updated) frag.$updated.forEach(m => m())
399+
if (isMounted && frag.onUpdated) frag.onUpdated.forEach(m => m())
400400
setActiveSub(prevSub)
401401
}
402402

packages/runtime-vapor/src/components/KeepAlive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ export const VaporKeepAliveImpl: ObjectVaporComponent = defineVaporComponent({
237237

238238
// inject hooks to DynamicFragment to cache components during updates
239239
const injectKeepAliveHooks = (frag: DynamicFragment) => {
240-
;(frag.beforeTeardown || (frag.beforeTeardown = [])).push(
240+
;(frag.onBeforeTeardown || (frag.onBeforeTeardown = [])).push(
241241
(oldKey, nodes, scope) => {
242242
processFragment(frag)
243243
keptAliveScopes.set(oldKey, scope)
244244
return true
245245
},
246246
)
247-
;(frag.$beforeMount || (frag.$beforeMount = [])).push(() =>
247+
;(frag.onBeforeMount || (frag.onBeforeMount = [])).push(() =>
248248
cacheFragment(frag),
249249
)
250250
frag.getScope = key => {

packages/runtime-vapor/src/components/Teleport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ export class TeleportFragment extends VaporFragment {
103103
// it will be called when root fragment changed
104104
if (this.parentComponent && this.parentComponent.ut) {
105105
if (isFragment(nodes)) {
106-
;(nodes.$updated || (nodes.$updated = [])).push(() =>
106+
;(nodes.onUpdated || (nodes.onUpdated = [])).push(() =>
107107
updateCssVars(this),
108108
)
109109
} else if (isArray(nodes)) {
110110
nodes.forEach(node => {
111111
if (isFragment(node)) {
112-
;(node.$updated || (node.$updated = [])).push(() =>
112+
;(node.onUpdated || (node.onUpdated = [])).push(() =>
113113
updateCssVars(this),
114114
)
115115
}

packages/runtime-vapor/src/fragment.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class VaporFragment<T extends Block = Block>
6060
) => void
6161

6262
// hooks
63-
$updated?: ((nodes?: Block) => void)[]
63+
onUpdated?: ((nodes?: Block) => void)[]
6464

6565
constructor(nodes: T) {
6666
this.nodes = nodes
@@ -90,12 +90,12 @@ export class DynamicFragment extends VaporFragment {
9090
getScope?: (key: any) => EffectScope | undefined
9191

9292
// hooks
93-
beforeTeardown?: ((
93+
onBeforeTeardown?: ((
9494
oldKey: any,
9595
nodes: Block,
9696
scope: EffectScope,
9797
) => boolean)[]
98-
$beforeMount?: ((newKey: any, nodes: Block, scope: EffectScope) => void)[]
98+
onBeforeMount?: ((newKey: any, nodes: Block, scope: EffectScope) => void)[]
9999

100100
constructor(anchorLabel?: string) {
101101
super([])
@@ -125,8 +125,8 @@ export class DynamicFragment extends VaporFragment {
125125
let preserveScope = false
126126
// if any of the hooks returns true the scope will be preserved
127127
// for kept-alive component
128-
if (this.beforeTeardown) {
129-
preserveScope = this.beforeTeardown.some(hook =>
128+
if (this.onBeforeTeardown) {
129+
preserveScope = this.onBeforeTeardown.some(hook =>
130130
hook(this.current, this.nodes, this.scope!),
131131
)
132132
}
@@ -136,7 +136,7 @@ export class DynamicFragment extends VaporFragment {
136136
const mode = transition && transition.mode
137137
if (mode) {
138138
applyTransitionLeaveHooks(this.nodes, transition, () =>
139-
this.$render(render, transition, parent, instance),
139+
this.renderBranch(render, transition, parent, instance),
140140
)
141141
parent && remove(this.nodes, parent)
142142
if (mode === 'out-in') {
@@ -148,7 +148,7 @@ export class DynamicFragment extends VaporFragment {
148148
}
149149
}
150150

151-
this.$render(render, transition, parent, instance)
151+
this.renderBranch(render, transition, parent, instance)
152152

153153
if (this.fallback) {
154154
// Find the deepest invalid fragment
@@ -189,7 +189,7 @@ export class DynamicFragment extends VaporFragment {
189189
if (isHydrating) this.hydrate()
190190
}
191191

192-
private $render(
192+
private renderBranch(
193193
render: BlockFn | undefined,
194194
transition: VaporTransitionHooks | undefined,
195195
parent: ParentNode | null,
@@ -215,8 +215,8 @@ export class DynamicFragment extends VaporFragment {
215215
this.$transition = applyTransitionHooks(this.nodes, transition)
216216
}
217217

218-
if (this.$beforeMount) {
219-
this.$beforeMount.forEach(hook =>
218+
if (this.onBeforeMount) {
219+
this.onBeforeMount.forEach(hook =>
220220
hook(this.current, this.nodes, this.scope!),
221221
)
222222
}
@@ -240,8 +240,8 @@ export class DynamicFragment extends VaporFragment {
240240
}
241241

242242
insert(this.nodes, parent, this.anchor)
243-
if (this.$updated) {
244-
this.$updated.forEach(hook => hook(this.nodes))
243+
if (this.onUpdated) {
244+
this.onUpdated.forEach(hook => hook(this.nodes))
245245
}
246246
}
247247
} else {

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function createVDOMComponent(
402402
}
403403

404404
frag.nodes = vnode.el as any
405-
if (isMounted && frag.$updated) frag.$updated.forEach(m => m())
405+
if (isMounted && frag.onUpdated) frag.onUpdated.forEach(m => m())
406406
}
407407

408408
frag.remove = unmount
@@ -469,7 +469,7 @@ function renderVDOMSlot(
469469
}
470470
}
471471

472-
if (isMounted && frag.$updated) frag.$updated.forEach(m => m())
472+
if (isMounted && frag.onUpdated) frag.onUpdated.forEach(m => m())
473473
}
474474

475475
const render = (parentNode?: ParentNode, anchor?: Node | null) => {

0 commit comments

Comments
 (0)