Skip to content

Commit cc9e5f4

Browse files
authored
Merge branch 'main' into format-component-name
2 parents a7b1344 + 8c3fdd1 commit cc9e5f4

File tree

36 files changed

+1463
-720
lines changed

36 files changed

+1463
-720
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# [3.5.0-beta.3](https://github.com/vuejs/core/compare/v3.5.0-beta.2...v3.5.0-beta.3) (2024-08-20)
2+
3+
4+
### Bug Fixes
5+
6+
* **reactivity:** extended methods respect reactive ([#11629](https://github.com/vuejs/core/issues/11629)) ([9de1d10](https://github.com/vuejs/core/commit/9de1d101f98bf6081f41038f6974826f190330a0)), closes [#11628](https://github.com/vuejs/core/issues/11628)
7+
* **runtime-core:** correct type inference for PascalCase emits ([#11579](https://github.com/vuejs/core/issues/11579)) ([d7d0371](https://github.com/vuejs/core/commit/d7d0371e74707ee601020f67de88e091cdae2673)), closes [vuejs/language-tools#4269](https://github.com/vuejs/language-tools/issues/4269)
8+
* **runtime-core:** ensure suspense content inherit scopeId ([#10652](https://github.com/vuejs/core/issues/10652)) ([ac2a410](https://github.com/vuejs/core/commit/ac2a410e46392db63ca4ed2db3c0fa71ebe1e855)), closes [#5148](https://github.com/vuejs/core/issues/5148)
9+
* **runtime-core:** pre jobs without an id should run first ([#7746](https://github.com/vuejs/core/issues/7746)) ([b332f80](https://github.com/vuejs/core/commit/b332f80f0edb018229a23b43b93bb402b6368a3c))
10+
* **ssr:** apply ssr props to the the fallback vnode-based branch in ssr ([#7247](https://github.com/vuejs/core/issues/7247)) ([98b83e8](https://github.com/vuejs/core/commit/98b83e86d16c635547a1e735e5fb675aea2f0f1b)), closes [#6123](https://github.com/vuejs/core/issues/6123)
11+
* **types/custom-element:** `defineCustomElement` with required props ([#11578](https://github.com/vuejs/core/issues/11578)) ([5e0f6d5](https://github.com/vuejs/core/commit/5e0f6d5f8fe7c4eb8f247357c3e2e281726f36db))
12+
* **types:** strip non-prop default values from return type of withDefaults ([#9998](https://github.com/vuejs/core/issues/9998)) ([44973bb](https://github.com/vuejs/core/commit/44973bb3e790db7d8aa7af4eda21c80cac73a8de)), closes [#9899](https://github.com/vuejs/core/issues/9899)
13+
* **watch:** handle errors in computed used as watch source ([#11626](https://github.com/vuejs/core/issues/11626)) ([8bcaad4](https://github.com/vuejs/core/commit/8bcaad4a32cf0f1f89e0259f6a53036620b7fe9f)), closes [#11624](https://github.com/vuejs/core/issues/11624)
14+
15+
16+
### Features
17+
18+
* **reactivity:** base `watch`, `getCurrentWatcher`, and `onWatcherCleanup` ([#9927](https://github.com/vuejs/core/issues/9927)) ([205e5b5](https://github.com/vuejs/core/commit/205e5b5e277243c3af2c937d9bd46cf671296b72))
19+
20+
21+
### Performance Improvements
22+
23+
* ** runtime-core:** use `apply` to avoid spreading. ([#5985](https://github.com/vuejs/core/issues/5985)) ([bb6babc](https://github.com/vuejs/core/commit/bb6babca8f206615d4e246457cd54d21bb3bc5a4))
24+
25+
26+
127
# [3.5.0-beta.2](https://github.com/vuejs/core/compare/v3.5.0-beta.1...v3.5.0-beta.2) (2024-08-15)
228

329

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
3-
"version": "3.5.0-beta.2",
4-
"packageManager": "[email protected].0",
3+
"version": "3.5.0-beta.3",
4+
"packageManager": "[email protected].1",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -66,23 +66,23 @@
6666
"@rollup/plugin-json": "^6.1.0",
6767
"@rollup/plugin-node-resolve": "^15.2.3",
6868
"@rollup/plugin-replace": "5.0.4",
69-
"@swc/core": "^1.7.10",
69+
"@swc/core": "^1.7.11",
7070
"@types/hash-sum": "^1.0.2",
71-
"@types/node": "^20.14.15",
71+
"@types/node": "^20.16.0",
7272
"@types/semver": "^7.5.8",
7373
"@types/serve-handler": "^6.1.4",
7474
"@vitest/coverage-istanbul": "^2.0.5",
7575
"@vue/consolidate": "1.0.0",
7676
"conventional-changelog-cli": "^5.0.0",
7777
"enquirer": "^2.4.1",
78-
"esbuild": "^0.23.0",
78+
"esbuild": "^0.23.1",
7979
"esbuild-plugin-polyfill-node": "^0.3.0",
8080
"eslint": "^9.9.0",
8181
"eslint-plugin-import-x": "^3.1.0",
8282
"eslint-plugin-vitest": "^0.5.4",
8383
"estree-walker": "catalog:",
8484
"jsdom": "^24.1.1",
85-
"lint-staged": "^15.2.8",
85+
"lint-staged": "^15.2.9",
8686
"lodash": "^4.17.21",
8787
"magic-string": "^0.30.11",
8888
"markdown-table": "^3.0.3",
@@ -94,7 +94,7 @@
9494
"pug": "^3.0.3",
9595
"puppeteer": "~23.0.2",
9696
"rimraf": "^6.0.1",
97-
"rollup": "^4.20.0",
97+
"rollup": "^4.21.0",
9898
"rollup-plugin-dts": "^6.1.1",
9999
"rollup-plugin-esbuild": "^6.1.1",
100100
"rollup-plugin-polyfill-node": "^0.13.0",
@@ -106,7 +106,7 @@
106106
"tslib": "^2.6.3",
107107
"tsx": "^4.17.0",
108108
"typescript": "~5.5.4",
109-
"typescript-eslint": "^8.0.1",
109+
"typescript-eslint": "^8.1.0",
110110
"vite": "catalog:",
111111
"vitest": "^2.0.5"
112112
},

packages-private/dts-test/setupHelpers.test-d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ describe('withDefaults w/ boolean type', () => {
227227
expectType<boolean | undefined>(res2.bool)
228228
})
229229

230+
describe('withDefaults w/ defineProp type is different from the defaults type', () => {
231+
const res1 = withDefaults(
232+
defineProps<{
233+
bool?: boolean
234+
}>(),
235+
{ bool: false, value: false },
236+
)
237+
expectType<boolean>(res1.bool)
238+
239+
// @ts-expect-error
240+
res1.value
241+
})
242+
230243
describe('defineProps w/ runtime declaration', () => {
231244
// runtime declaration
232245
const props = defineProps({

packages-private/sfc-playground/src/download/template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
},
1313
"devDependencies": {
1414
"@vitejs/plugin-vue": "^5.1.2",
15-
"vite": "^5.4.0"
15+
"vite": "^5.4.1"
1616
}
1717
}

packages/compiler-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-core",
3-
"version": "3.5.0-beta.2",
3+
"version": "3.5.0-beta.3",
44
"description": "@vue/compiler-core",
55
"main": "index.js",
66
"module": "dist/compiler-core.esm-bundler.js",

packages/compiler-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-dom",
3-
"version": "3.5.0-beta.2",
3+
"version": "3.5.0-beta.3",
44
"description": "@vue/compiler-dom",
55
"main": "index.js",
66
"module": "dist/compiler-dom.esm-bundler.js",

packages/compiler-sfc/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-sfc",
3-
"version": "3.5.0-beta.2",
3+
"version": "3.5.0-beta.3",
44
"description": "@vue/compiler-sfc",
55
"main": "dist/compiler-sfc.cjs.js",
66
"module": "dist/compiler-sfc.esm-browser.js",
@@ -60,7 +60,7 @@
6060
"merge-source-map": "^1.1.0",
6161
"minimatch": "~9.0.5",
6262
"postcss-modules": "^6.0.0",
63-
"postcss-selector-parser": "^6.1.1",
63+
"postcss-selector-parser": "^6.1.2",
6464
"pug": "^3.0.3",
6565
"sass": "^1.77.8"
6666
}

packages/compiler-ssr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-ssr",
3-
"version": "3.5.0-beta.2",
3+
"version": "3.5.0-beta.3",
44
"description": "@vue/compiler-ssr",
55
"main": "dist/compiler-ssr.cjs.js",
66
"types": "dist/compiler-ssr.d.ts",
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
import {
2+
EffectScope,
3+
type Ref,
4+
WatchErrorCodes,
5+
type WatchOptions,
6+
type WatchScheduler,
7+
onWatcherCleanup,
8+
ref,
9+
watch,
10+
} from '../src'
11+
12+
const queue: (() => void)[] = []
13+
14+
// a simple scheduler for testing purposes
15+
let isFlushPending = false
16+
const resolvedPromise = /*#__PURE__*/ Promise.resolve() as Promise<any>
17+
const nextTick = (fn?: () => any) =>
18+
fn ? resolvedPromise.then(fn) : resolvedPromise
19+
20+
const scheduler: WatchScheduler = (job, isFirstRun) => {
21+
if (isFirstRun) {
22+
job()
23+
} else {
24+
queue.push(job)
25+
flushJobs()
26+
}
27+
}
28+
29+
const flushJobs = () => {
30+
if (isFlushPending) return
31+
isFlushPending = true
32+
resolvedPromise.then(() => {
33+
queue.forEach(job => job())
34+
queue.length = 0
35+
isFlushPending = false
36+
})
37+
}
38+
39+
describe('watch', () => {
40+
test('effect', () => {
41+
let dummy: any
42+
const source = ref(0)
43+
watch(() => {
44+
dummy = source.value
45+
})
46+
expect(dummy).toBe(0)
47+
source.value++
48+
expect(dummy).toBe(1)
49+
})
50+
51+
test('with callback', () => {
52+
let dummy: any
53+
const source = ref(0)
54+
watch(source, () => {
55+
dummy = source.value
56+
})
57+
expect(dummy).toBe(undefined)
58+
source.value++
59+
expect(dummy).toBe(1)
60+
})
61+
62+
test('call option with error handling', () => {
63+
const onError = vi.fn()
64+
const call: WatchOptions['call'] = function call(fn, type, args) {
65+
if (Array.isArray(fn)) {
66+
fn.forEach(f => call(f, type, args))
67+
return
68+
}
69+
try {
70+
fn.apply(null, args)
71+
} catch (e) {
72+
onError(e, type)
73+
}
74+
}
75+
76+
watch(
77+
() => {
78+
throw 'oops in effect'
79+
},
80+
null,
81+
{ call },
82+
)
83+
84+
const source = ref(0)
85+
const effect = watch(
86+
source,
87+
() => {
88+
onWatcherCleanup(() => {
89+
throw 'oops in cleanup'
90+
})
91+
throw 'oops in watch'
92+
},
93+
{ call },
94+
)
95+
96+
expect(onError.mock.calls.length).toBe(1)
97+
expect(onError.mock.calls[0]).toMatchObject([
98+
'oops in effect',
99+
WatchErrorCodes.WATCH_CALLBACK,
100+
])
101+
102+
source.value++
103+
expect(onError.mock.calls.length).toBe(2)
104+
expect(onError.mock.calls[1]).toMatchObject([
105+
'oops in watch',
106+
WatchErrorCodes.WATCH_CALLBACK,
107+
])
108+
109+
effect!.stop()
110+
source.value++
111+
expect(onError.mock.calls.length).toBe(3)
112+
expect(onError.mock.calls[2]).toMatchObject([
113+
'oops in cleanup',
114+
WatchErrorCodes.WATCH_CLEANUP,
115+
])
116+
})
117+
118+
test('watch with onWatcherCleanup', async () => {
119+
let dummy = 0
120+
let source: Ref<number>
121+
const scope = new EffectScope()
122+
123+
scope.run(() => {
124+
source = ref(0)
125+
watch(onCleanup => {
126+
source.value
127+
128+
onCleanup(() => (dummy += 2))
129+
onWatcherCleanup(() => (dummy += 3))
130+
onWatcherCleanup(() => (dummy += 5))
131+
})
132+
})
133+
expect(dummy).toBe(0)
134+
135+
scope.run(() => {
136+
source.value++
137+
})
138+
expect(dummy).toBe(10)
139+
140+
scope.run(() => {
141+
source.value++
142+
})
143+
expect(dummy).toBe(20)
144+
145+
scope.stop()
146+
expect(dummy).toBe(30)
147+
})
148+
149+
test('nested calls to baseWatch and onWatcherCleanup', async () => {
150+
let calls: string[] = []
151+
let source: Ref<number>
152+
let copyist: Ref<number>
153+
const scope = new EffectScope()
154+
155+
scope.run(() => {
156+
source = ref(0)
157+
copyist = ref(0)
158+
// sync by default
159+
watch(
160+
() => {
161+
const current = (copyist.value = source.value)
162+
onWatcherCleanup(() => calls.push(`sync ${current}`))
163+
},
164+
null,
165+
{},
166+
)
167+
// with scheduler
168+
watch(
169+
() => {
170+
const current = copyist.value
171+
onWatcherCleanup(() => calls.push(`post ${current}`))
172+
},
173+
null,
174+
{ scheduler },
175+
)
176+
})
177+
178+
await nextTick()
179+
expect(calls).toEqual([])
180+
181+
scope.run(() => source.value++)
182+
expect(calls).toEqual(['sync 0'])
183+
await nextTick()
184+
expect(calls).toEqual(['sync 0', 'post 0'])
185+
calls.length = 0
186+
187+
scope.run(() => source.value++)
188+
expect(calls).toEqual(['sync 1'])
189+
await nextTick()
190+
expect(calls).toEqual(['sync 1', 'post 1'])
191+
calls.length = 0
192+
193+
scope.stop()
194+
expect(calls).toEqual(['sync 2', 'post 2'])
195+
})
196+
})

packages/reactivity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/reactivity",
3-
"version": "3.5.0-beta.2",
3+
"version": "3.5.0-beta.3",
44
"description": "@vue/reactivity",
55
"main": "index.js",
66
"module": "dist/reactivity.esm-bundler.js",

0 commit comments

Comments
 (0)