-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cleanup code, fix keepAlive and extract createH to h.ts
- Loading branch information
1 parent
18a7c4f
commit 9c55835
Showing
6 changed files
with
69 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Ref, VNode } from 'vue' | ||
import { ref, shallowReactive } from 'vue' | ||
|
||
export type H = { | ||
vNodes: VNode[] | ||
containers: Ref<symbol[]> | ||
push: (vNode: VNode) => void | ||
remove: (vNode: VNode) => void | ||
} | ||
|
||
export function createH(): H { | ||
const vNodes: VNode[] = shallowReactive([]) | ||
const containers = ref<symbol[]>([]) | ||
|
||
function push(vNode: VNode) { | ||
if (!vNodes.includes(vNode)) | ||
vNodes.push(vNode) | ||
} | ||
|
||
function remove(vNode: VNode): void { | ||
const index = vNodes.indexOf(vNode) | ||
if (index !== undefined && index !== -1) | ||
vNodes.splice(index, 1) | ||
} | ||
|
||
const _h: H = { | ||
vNodes, | ||
containers, | ||
push, | ||
remove, | ||
} | ||
return _h | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters