app.unmount()
expect(host.innerHTML).toBe('')
- expect(i.scope.effects.length).toBe(0)
+ expect(getEffectsCount(i.scope)).toBe(0)
})
+ it('work with v-once + props', () => {
+ const Child = defineVaporComponent({
+ props: {
+ count: Number,
+ },
+ setup(props) {
+ const n0 = template(' ')() as any
+ renderEffect(() => setText(n0, props.count))
+ return n0
+ },
+ })
+
+ const count = ref(0)
+ const { html } = define({
+ setup() {
+ return createComponent(
+ Child,
+ { count: () => count.value },
+ null,
+ true,
+ true, // v-once
+ )
+ },
+ }).render()
+
+ expect(html()).toBe('0')
+
+ count.value++
+ expect(html()).toBe('0')
+ })
+
+ it('work with v-once + attrs', () => {
+ const Child = defineVaporComponent({
+ setup() {
+ const attrs = useAttrs()
+ const n0 = template(' ')() as any
+ renderEffect(() => setText(n0, attrs.count as string))
+ return n0
+ },
+ })
+
+ const count = ref(0)
+ const { html } = define({
+ setup() {
+ return createComponent(
+ Child,
+ { count: () => count.value },
+ null,
+ true,
+ true, // v-once
+ )
+ },
+ }).render()
+
+ expect(html()).toBe('0')
+
+ count.value++
+ expect(html()).toBe('0')
+ })
+
test('should mount component only with template in production mode', () => {
__DEV__ = false
const { component: Child } = define({
rawProps as RawProps,
rawSlots as RawSlots,
appContext,
+ once,
)
+ // HMR
+ if (__DEV__ && component.__hmrId) {
+ registerHMR(instance)
+ instance.isSingleRoot = isSingleRoot
+ instance.hmrRerender = hmrRerender.bind(null, instance)
+ instance.hmrReload = hmrReload.bind(null, instance)
+ }
+
if (__DEV__) {
pushWarningContext(instance)
startMeasure(instance, `init`)
import { ReactiveFlags } from '@vue/reactivity'
import { normalizeEmitsOptions } from './componentEmits'
import { renderEffect } from './renderEffect'
+import { pauseTracking, resetTracking } from '@vue/reactivity'
+ import type { interopKey } from './vdomInterop'
export type RawProps = Record<string, () => unknown> & {
// generated by compiler for :[key]="x" or v-bind="x"