mirror of https://github.com/vuejs/core.git
refactor(runtime-vapor): clean up
This commit is contained in:
parent
6eaf4b651b
commit
9dda97e736
|
@ -4,13 +4,11 @@ import {
|
|||
effect,
|
||||
setText,
|
||||
render,
|
||||
getCurrentInstance,
|
||||
ref,
|
||||
unmountComponent,
|
||||
} from '../src'
|
||||
import type { ComponentInternalInstance } from '../src'
|
||||
import { afterEach, beforeEach, describe, expect } from 'vitest'
|
||||
import { defineComponent, nextTick } from '@vue/runtime-core'
|
||||
import { defineComponent } from '@vue/runtime-core'
|
||||
|
||||
let host: HTMLElement
|
||||
|
||||
|
@ -42,7 +40,6 @@ describe('component', () => {
|
|||
},
|
||||
})
|
||||
const instance = render(Comp as any, {}, '#host')
|
||||
await nextTick()
|
||||
expect(host.innerHTML).toBe('<div>0</div>')
|
||||
unmountComponent(instance)
|
||||
expect(host.innerHTML).toBe('')
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
/**
|
||||
* @vitest-environment jsdom
|
||||
*/
|
||||
|
||||
import { template, fragment } from '../src'
|
||||
|
||||
describe('api: template', () => {
|
||||
|
|
|
@ -24,26 +24,14 @@ describe('directive: v-show', () => {
|
|||
function handleClick() {
|
||||
visible.value = !visible.value
|
||||
}
|
||||
const __returned__ = { visible, handleClick }
|
||||
Object.defineProperty(__returned__, '__isScriptSetup', {
|
||||
enumerable: false,
|
||||
value: true,
|
||||
})
|
||||
return __returned__
|
||||
},
|
||||
render(_ctx: any) {
|
||||
const t0 = template('<button>toggle</button><h1>hello world</h1>')
|
||||
const n0 = t0()
|
||||
const {
|
||||
0: [n1],
|
||||
1: [n2],
|
||||
} = children(n0 as ChildNode)
|
||||
withDirectives(n2, [[vShow, () => _ctx.visible]])
|
||||
on(
|
||||
n1 as HTMLElement,
|
||||
'click',
|
||||
(...args) => _ctx.handleClick && _ctx.handleClick(...args),
|
||||
)
|
||||
} = children(n0)
|
||||
withDirectives(n2, [[vShow, () => visible.value]])
|
||||
on(n1 as HTMLElement, 'click', (...args) => handleClick(...args))
|
||||
return n0
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { markRaw, proxyRefs } from '@vue/reactivity'
|
||||
import { type Data } from '@vue/shared'
|
||||
|
||||
import {
|
||||
type Component,
|
||||
type ComponentInternalInstance,
|
||||
|
@ -8,11 +7,8 @@ import {
|
|||
setCurrentInstance,
|
||||
unsetCurrentInstance,
|
||||
} from './component'
|
||||
|
||||
import { initProps } from './componentProps'
|
||||
|
||||
import { invokeDirectiveHook } from './directive'
|
||||
|
||||
import { insert, remove } from './dom'
|
||||
import { PublicInstanceProxyHandlers } from './componentPublicInstance'
|
||||
|
||||
|
@ -61,7 +57,9 @@ export function mountComponent(
|
|||
} else {
|
||||
block = state as Block
|
||||
}
|
||||
if (block instanceof DocumentFragment) block = Array.from(block.childNodes)
|
||||
if (block instanceof DocumentFragment) {
|
||||
block = Array.from(block.childNodes)
|
||||
}
|
||||
return (instance.block = block)
|
||||
})!
|
||||
invokeDirectiveHook(instance, 'beforeMount')
|
||||
|
|
|
@ -20,7 +20,7 @@ function flush() {
|
|||
queued = undefined
|
||||
}
|
||||
|
||||
export const nextTick = (fn: any) => p.then(fn)
|
||||
export const nextTick = (fn?: any) => (fn ? p.then(fn) : p)
|
||||
|
||||
export function effect(fn: any) {
|
||||
let run: () => void
|
||||
|
|
Loading…
Reference in New Issue