]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
Merge branch 'minor' into edison/fix/vaporOnce edison/fix/vaporOnce 13459/head
authoredison <daiwei521@126.com>
Wed, 16 Jul 2025 12:51:00 +0000 (20:51 +0800)
committerGitHub <noreply@github.com>
Wed, 16 Jul 2025 12:51:00 +0000 (20:51 +0800)
1  2 
packages/runtime-vapor/__tests__/component.spec.ts
packages/runtime-vapor/src/apiCreateApp.ts
packages/runtime-vapor/src/component.ts
packages/runtime-vapor/src/componentProps.ts

index b8a0180762a2de4f57f684e51bdb1acff3fcd387,b96a932a2f38913e1abef9b846de5a37dfe36565..ce901e19931b8ac7ebf81515dee81ca250f4ba74
@@@ -312,69 -312,9 +314,69 @@@ describe('component', () => 
  
      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({
index da65f24d55f8f93f4ff23169b34d0333c753f70d,da57882c49de648cd4abdda7c133af7cc390b262..83656aa55bfc5083cde3899b1506abd4bbcaad31
@@@ -187,9 -185,16 +186,17 @@@ export function createComponent
      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`)
index 6d1c686c94fff3b05bceedc3abdf132e522af494,55eadb980468083789a5871efeee7e20220d2dc0..6832bd9103c6348021933c83ff9abe079d8f7bd8
@@@ -24,7 -23,7 +23,8 @@@ import 
  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"