Skip to content

Commit 40794c8

Browse files
authored
refactor(runtime-core): extract type SetRootFn (#3209)
1 parent e85e0a7 commit 40794c8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/runtime-core/src/componentRenderUtils.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export function markAttrsAccessed() {
3838
accessedAttrs = true
3939
}
4040

41+
type SetRootFn = ((root: VNode) => void) | undefined
42+
4143
export function renderComponentRoot(
4244
instance: ComponentInternalInstance
4345
): VNode {
@@ -121,7 +123,7 @@ export function renderComponentRoot(
121123
// in dev mode, comments are preserved, and it's possible for a template
122124
// to have comments along side the root element which makes it a fragment
123125
let root = result
124-
let setRoot: ((root: VNode) => void) | undefined = undefined
126+
let setRoot: SetRootFn = undefined
125127
if (
126128
__DEV__ &&
127129
result.patchFlag > 0 &&
@@ -246,9 +248,7 @@ export function renderComponentRoot(
246248
* template into a fragment root, but we need to locate the single element
247249
* root for attrs and scope id processing.
248250
*/
249-
const getChildRoot = (
250-
vnode: VNode
251-
): [VNode, ((root: VNode) => void) | undefined] => {
251+
const getChildRoot = (vnode: VNode): [VNode, SetRootFn] => {
252252
const rawChildren = vnode.children as VNodeArrayChildren
253253
const dynamicChildren = vnode.dynamicChildren
254254
const childRoot = filterSingleRoot(rawChildren)
@@ -257,7 +257,7 @@ const getChildRoot = (
257257
}
258258
const index = rawChildren.indexOf(childRoot)
259259
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1
260-
const setRoot = (updatedRoot: VNode) => {
260+
const setRoot: SetRootFn = (updatedRoot: VNode) => {
261261
rawChildren[index] = updatedRoot
262262
if (dynamicChildren) {
263263
if (dynamicIndex > -1) {

0 commit comments

Comments
 (0)