Skip to content

Commit 5d3f2fd

Browse files
committed
wip: save
1 parent 82f0e46 commit 5d3f2fd

File tree

6 files changed

+11
-31
lines changed

6 files changed

+11
-31
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export class EffectScope implements ReactiveNode {
8787
if (sub !== undefined) {
8888
unlink(sub)
8989
}
90-
this.cleanup()
91-
}
92-
93-
cleanup(): void {
9490
cleanup(this)
9591
}
9692
}

packages/runtime-vapor/__tests__/components/Teleport.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ describe('renderer: VaporTeleport', () => {
195195
expect(target.innerHTML).toBe('<div>teleported 2</div>')
196196
})
197197

198-
test('parent rerender + toggle disabled', async () => {
198+
test.todo('parent rerender + toggle disabled', async () => {
199199
const target = document.createElement('div')
200200
const root = document.createElement('div')
201201
const parentId = 'test3-parent-rerender'

packages/runtime-vapor/src/block.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
isFragment,
2121
} from './fragment'
2222
import { child } from './dom/node'
23+
import { TeleportFragment } from './components/Teleport'
2324

2425
export interface TransitionOptions {
2526
$key?: any
@@ -182,12 +183,12 @@ export function normalizeBlock(block: Block): Node[] {
182183
} else if (isVaporComponent(block)) {
183184
nodes.push(...normalizeBlock(block.block!))
184185
} else {
185-
if (block.getNodes) {
186-
nodes.push(...normalizeBlock(block.getNodes()))
186+
if (block instanceof TeleportFragment) {
187+
nodes.push(block.placeholder!, block.anchor!)
187188
} else {
188189
nodes.push(...normalizeBlock(block.nodes))
190+
block.anchor && nodes.push(block.anchor)
189191
}
190-
block.anchor && nodes.push(block.anchor)
191192
}
192193
return nodes
193194
}

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

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
type TeleportTargetElement,
44
isTeleportDeferred,
55
isTeleportDisabled,
6-
onScopeDispose,
76
queuePostFlushCb,
87
resolveTeleportTarget,
98
warn,
@@ -61,14 +60,6 @@ export class TeleportFragment extends VaporFragment {
6160
? createComment('teleport end')
6261
: createTextNode()
6362

64-
this.init()
65-
}
66-
67-
get parent(): ParentNode | null {
68-
return this.anchor ? this.anchor.parentNode : null
69-
}
70-
71-
private init(): void {
7263
renderEffect(() => {
7364
// access the props to trigger tracking
7465
this.resolvedProps = extend(
@@ -84,23 +75,18 @@ export class TeleportFragment extends VaporFragment {
8475
if (!isHydrating) {
8576
this.initChildren()
8677
}
78+
}
8779

88-
if (__DEV__) {
89-
onScopeDispose(this.remove)
90-
// used in `normalizeBlock` to get nodes of TeleportFragment during
91-
// HMR updates. returns empty array if content is mounted in target
92-
// container to prevent incorrect parent node lookup.
93-
this.getNodes = () =>
94-
this.parent !== this.mountContainer! ? [] : this.nodes
95-
}
80+
get parent(): ParentNode | null {
81+
return this.anchor ? this.anchor.parentNode : null
9682
}
9783

9884
private initChildren(): void {
99-
renderEffect(() =>
85+
renderEffect(() => {
10086
this.handleChildrenUpdate(
10187
this.rawSlots!.default && (this.rawSlots!.default as BlockFn)(),
102-
),
103-
)
88+
)
89+
})
10490

10591
if (__DEV__) {
10692
const nodes = this.nodes

packages/runtime-vapor/src/fragment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class VaporFragment<T extends Block = Block>
4141
remove?: (parent?: ParentNode, transitionHooks?: TransitionHooks) => void
4242
fallback?: BlockFn
4343

44-
getNodes?: () => Block
4544
setRef?: (comp: VaporComponentInstance) => void
4645

4746
constructor(nodes: T) {

packages/runtime-vapor/src/hmr.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function hmrRerender(instance: VaporComponentInstance): void {
1919
const parent = normalized[0].parentNode!
2020
const anchor = normalized[normalized.length - 1].nextSibling
2121
remove(instance.block, parent)
22-
instance.scope!.cleanup()
2322
const prev = setCurrentInstance(instance)
2423
pushWarningContext(instance)
2524
devRender(instance)
@@ -46,7 +45,6 @@ export function hmrReload(
4645
)
4746
setCurrentInstance(...prev)
4847
mountComponent(newInstance, parent, anchor)
49-
5048
updateParentBlockOnHmrReload(parentInstance, instance, newInstance)
5149
updateParentTeleportOnHmrReload(instance, newInstance)
5250
}

0 commit comments

Comments
 (0)