From: Evan You Date: Thu, 30 May 2024 03:21:12 +0000 (+0800) Subject: chore: Merge branch 'main' into minor X-Git-Tag: v3.5.0-alpha.3~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d8727ec971543d5830b107a4322ea6e1d50a873;p=thirdparty%2Fvuejs%2Fcore.git chore: Merge branch 'main' into minor --- 1d8727ec971543d5830b107a4322ea6e1d50a873 diff --cc CHANGELOG.md index 4684072180,a390f9b0c1..086da812a7 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -1,19 -1,16 +1,32 @@@ + ## [3.4.27](https://github.com/vuejs/core/compare/v3.4.26...v3.4.27) (2024-05-06) + + + ### Bug Fixes + + * **compat:** include legacy scoped slots ([#10868](https://github.com/vuejs/core/issues/10868)) ([8366126](https://github.com/vuejs/core/commit/83661264a4ced3cb2ff6800904a86dd9e82bbfe2)), closes [#8869](https://github.com/vuejs/core/issues/8869) + * **compiler-core:** add support for arrow aysnc function with unbracketed ([#5789](https://github.com/vuejs/core/issues/5789)) ([ca7d421](https://github.com/vuejs/core/commit/ca7d421e8775f6813f8943d32ab485e0c542f98b)), closes [#5788](https://github.com/vuejs/core/issues/5788) + * **compiler-dom:** restrict createStaticVNode usage with option elements ([#10846](https://github.com/vuejs/core/issues/10846)) ([0e3d617](https://github.com/vuejs/core/commit/0e3d6178b02d0386d779720ae2cc4eac1d1ec990)), closes [#6568](https://github.com/vuejs/core/issues/6568) [#7434](https://github.com/vuejs/core/issues/7434) + * **compiler-sfc:** handle keyof operator ([#10874](https://github.com/vuejs/core/issues/10874)) ([10d34a5](https://github.com/vuejs/core/commit/10d34a5624775f20437ccad074a97270ef74c3fb)), closes [#10871](https://github.com/vuejs/core/issues/10871) + * **hydration:** handle edge case of style mismatch without style attribute ([f2c1412](https://github.com/vuejs/core/commit/f2c1412e46a8fad3e13403bfa78335c4f704f21c)), closes [#10786](https://github.com/vuejs/core/issues/10786) + + + +# [3.5.0-alpha.2](https://github.com/vuejs/core/compare/v3.4.26...v3.5.0-alpha.2) (2024-05-04) + + +### Bug Fixes + +* **types:** fix app.component() typing with inline defineComponent ([908f70a](https://github.com/vuejs/core/commit/908f70adc06038d1ea253d96f4024367f4a7545d)), closes [#10843](https://github.com/vuejs/core/issues/10843) +* **types:** fix compat with generated types that rely on CreateComponentPublicInstance ([c146186](https://github.com/vuejs/core/commit/c146186396d0c1a65423b8c9a21251c5a6467336)), closes [#10842](https://github.com/vuejs/core/issues/10842) +* **types:** props in defineOptions type should be optional ([124c4ca](https://github.com/vuejs/core/commit/124c4cac833a28ae9bc8edc576c1d0c7c41f5985)), closes [#10841](https://github.com/vuejs/core/issues/10841) + + +### Features + +* **runtime-core:** add app.onUnmount() for registering cleanup functions ([#4619](https://github.com/vuejs/core/issues/4619)) ([582a3a3](https://github.com/vuejs/core/commit/582a3a382b1adda565bac576b913a88d9e8d7a9e)), closes [#4516](https://github.com/vuejs/core/issues/4516) + + + ## [3.4.26](https://github.com/vuejs/core/compare/v3.4.25...v3.4.26) (2024-04-29) diff --cc package.json index 23282e991b,cb211ed4b6..d454391c70 --- a/package.json +++ b/package.json @@@ -1,7 -1,7 +1,7 @@@ { "private": true, - "version": "3.4.27", + "version": "3.5.0-alpha.2", - "packageManager": "pnpm@9.0.6", + "packageManager": "pnpm@9.1.2", "type": "module", "scripts": { "dev": "node scripts/dev.js", diff --cc packages/reactivity/__tests__/ref.spec.ts index ed917dbdd9,f42281edd3..a3f56ab05c --- a/packages/reactivity/__tests__/ref.spec.ts +++ b/packages/reactivity/__tests__/ref.spec.ts @@@ -443,14 -456,15 +456,26 @@@ describe('reactivity/ref', () => expect(a.value).not.toBe(r) }) + test('should not trigger when setting the same raw object', () => { + const obj = {} + const r = ref(obj) + const spy = vi.fn() + effect(() => spy(r.value)) + expect(spy).toHaveBeenCalledTimes(1) + + r.value = obj + expect(spy).toHaveBeenCalledTimes(1) + }) ++ + test('toValue', () => { + const a = ref(1) + const b = computed(() => a.value + 1) + const c = () => a.value + 2 + const d = 4 + + expect(toValue(a)).toBe(1) + expect(toValue(b)).toBe(2) + expect(toValue(c)).toBe(3) + expect(toValue(d)).toBe(4) + }) }) diff --cc packages/runtime-core/__tests__/apiWatch.spec.ts index 991419d8ef,265bc0a0d4..c0726cddd7 --- a/packages/runtime-core/__tests__/apiWatch.spec.ts +++ b/packages/runtime-core/__tests__/apiWatch.spec.ts @@@ -1476,45 -1563,19 +1564,61 @@@ describe('api: watch', () => expect(scope.effects.length).toBe(0) }) + // simplified case of VueUse syncRef + test('sync watcher should not be batched', () => { + const a = ref(0) + const b = ref(0) + let pauseB = false + watch( + a, + () => { + pauseB = true + b.value = a.value + 1 + pauseB = false + }, + { flush: 'sync' }, + ) + watch( + b, + () => { + if (!pauseB) { + throw new Error('should not be called') + } + }, + { flush: 'sync' }, + ) + + a.value = 1 + expect(b.value).toBe(2) + }) + + test('watchEffect should not fire on computed deps that did not change', async () => { + const a = ref(0) + const c = computed(() => a.value % 2) + const spy = vi.fn() + watchEffect(() => { + spy() + c.value + }) + expect(spy).toHaveBeenCalledTimes(1) + a.value += 2 + await nextTick() + expect(spy).toHaveBeenCalledTimes(1) + }) ++ + test('circular reference', async () => { + const obj = { a: 1 } + // @ts-expect-error + obj.b = obj + const foo = ref(obj) + const spy = vi.fn() + + watch(foo, spy, { deep: true }) + + // @ts-expect-error + foo.value.b.a = 2 + await nextTick() + expect(spy).toHaveBeenCalledTimes(1) + expect(foo.value.a).toBe(2) + }) }) diff --cc packages/runtime-core/src/componentPublicInstance.ts index 91a7ae8d6d,52801e172a..8f244ac1d9 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@@ -317,20 -230,17 +318,20 @@@ export type ComponentPublicInstance $watch any)>( source: T, cb: T extends (...args: any) => infer R - ? (...args: [R, R]) => any - : (...args: any) => any, + ? (...args: [R, R, OnCleanup]) => any + : (...args: [any, any, OnCleanup]) => any, options?: WatchOptions, ): WatchStopHandle -} & IfAny>> & - ShallowUnwrapRef & - UnwrapNestedRefs & - ExtractComputedReturns & - M & - ComponentCustomProperties & - InjectToObject +} & ExposedKeys< + IfAny>> & + ShallowUnwrapRef & + UnwrapNestedRefs & + ExtractComputedReturns & + M & + ComponentCustomProperties & + InjectToObject, + Exposed +> export type PublicPropertiesMap = Record< string,