mirror of https://github.com/vuejs/core.git
chore: Merge branch 'main' into minor
This commit is contained in:
commit
0c3a920012
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,3 +1,14 @@
|
||||||
|
## [3.4.25](https://github.com/vuejs/core/compare/v3.4.24...v3.4.25) (2024-04-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **defineModel:** align prod mode runtime type generation with defineProps ([4253a57](https://github.com/vuejs/core/commit/4253a57f1703a7f1ac701d77e0a235689203461d)), closes [#10769](https://github.com/vuejs/core/issues/10769)
|
||||||
|
* **runtime-core:** properly get keepAlive child ([#10772](https://github.com/vuejs/core/issues/10772)) ([3724693](https://github.com/vuejs/core/commit/3724693a25c3f2dd13d70a8a1af760b03a4fb783)), closes [#10771](https://github.com/vuejs/core/issues/10771)
|
||||||
|
* **runtime-core:** use normal object as internal prototype for attrs and slots ([064e82f](https://github.com/vuejs/core/commit/064e82f5855f30fe0b77fe9b5e4dd22700fd634d)), closes [/github.com/vuejs/core/commit/6df53d85a207986128159d88565e6e7045db2add#r141304923](https://github.com//github.com/vuejs/core/commit/6df53d85a207986128159d88565e6e7045db2add/issues/r141304923)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [3.4.24](https://github.com/vuejs/core/compare/v3.4.23...v3.4.24) (2024-04-22)
|
## [3.4.24](https://github.com/vuejs/core/compare/v3.4.23...v3.4.24) (2024-04-22)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"packageManager": "pnpm@9.0.5",
|
"packageManager": "pnpm@9.0.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/compiler-core",
|
"name": "@vue/compiler-core",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/compiler-core",
|
"description": "@vue/compiler-core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/compiler-core.esm-bundler.js",
|
"module": "dist/compiler-core.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/compiler-dom",
|
"name": "@vue/compiler-dom",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/compiler-dom",
|
"description": "@vue/compiler-dom",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/compiler-dom.esm-bundler.js",
|
"module": "dist/compiler-dom.esm-bundler.js",
|
||||||
|
|
|
@ -226,3 +226,43 @@ return { modelValue, fn, fnWithDefault, str, optional }
|
||||||
|
|
||||||
})"
|
})"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`defineModel() > w/ types, production mode, boolean + multiple types 1`] = `
|
||||||
|
"import { useModel as _useModel, defineComponent as _defineComponent } from 'vue'
|
||||||
|
|
||||||
|
export default /*#__PURE__*/_defineComponent({
|
||||||
|
props: {
|
||||||
|
"modelValue": { type: [Boolean, String, Object] },
|
||||||
|
"modelModifiers": {},
|
||||||
|
},
|
||||||
|
emits: ["update:modelValue"],
|
||||||
|
setup(__props, { expose: __expose }) {
|
||||||
|
__expose();
|
||||||
|
|
||||||
|
const modelValue = _useModel<boolean | string | {}>(__props, "modelValue")
|
||||||
|
|
||||||
|
return { modelValue }
|
||||||
|
}
|
||||||
|
|
||||||
|
})"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`defineModel() > w/ types, production mode, function + runtime opts + multiple types 1`] = `
|
||||||
|
"import { useModel as _useModel, defineComponent as _defineComponent } from 'vue'
|
||||||
|
|
||||||
|
export default /*#__PURE__*/_defineComponent({
|
||||||
|
props: {
|
||||||
|
"modelValue": { type: [Number, Function], ...{ default: () => 1 } },
|
||||||
|
"modelModifiers": {},
|
||||||
|
},
|
||||||
|
emits: ["update:modelValue"],
|
||||||
|
setup(__props, { expose: __expose }) {
|
||||||
|
__expose();
|
||||||
|
|
||||||
|
const modelValue = _useModel<number | (() => number)>(__props, "modelValue")
|
||||||
|
|
||||||
|
return { modelValue }
|
||||||
|
}
|
||||||
|
|
||||||
|
})"
|
||||||
|
`;
|
||||||
|
|
|
@ -161,6 +161,34 @@ describe('defineModel()', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('w/ types, production mode, boolean + multiple types', () => {
|
||||||
|
const { content } = compile(
|
||||||
|
`
|
||||||
|
<script setup lang="ts">
|
||||||
|
const modelValue = defineModel<boolean | string | {}>()
|
||||||
|
</script>
|
||||||
|
`,
|
||||||
|
{ isProd: true },
|
||||||
|
)
|
||||||
|
assertCode(content)
|
||||||
|
expect(content).toMatch('"modelValue": { type: [Boolean, String, Object] }')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('w/ types, production mode, function + runtime opts + multiple types', () => {
|
||||||
|
const { content } = compile(
|
||||||
|
`
|
||||||
|
<script setup lang="ts">
|
||||||
|
const modelValue = defineModel<number | (() => number)>({ default: () => 1 })
|
||||||
|
</script>
|
||||||
|
`,
|
||||||
|
{ isProd: true },
|
||||||
|
)
|
||||||
|
assertCode(content)
|
||||||
|
expect(content).toMatch(
|
||||||
|
'"modelValue": { type: [Number, Function], ...{ default: () => 1 } }',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test('get / set transformers', () => {
|
test('get / set transformers', () => {
|
||||||
const { content } = compile(
|
const { content } = compile(
|
||||||
`
|
`
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/compiler-sfc",
|
"name": "@vue/compiler-sfc",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/compiler-sfc",
|
"description": "@vue/compiler-sfc",
|
||||||
"main": "dist/compiler-sfc.cjs.js",
|
"main": "dist/compiler-sfc.cjs.js",
|
||||||
"module": "dist/compiler-sfc.esm-browser.js",
|
"module": "dist/compiler-sfc.esm-browser.js",
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import type { LVal, Node, TSType } from '@babel/types'
|
import type { LVal, Node, TSType } from '@babel/types'
|
||||||
import type { ScriptCompileContext } from './context'
|
import type { ScriptCompileContext } from './context'
|
||||||
import { inferRuntimeType } from './resolveType'
|
import { inferRuntimeType } from './resolveType'
|
||||||
import {
|
import { UNKNOWN_TYPE, isCallOf, toRuntimeTypeString } from './utils'
|
||||||
UNKNOWN_TYPE,
|
|
||||||
concatStrings,
|
|
||||||
isCallOf,
|
|
||||||
toRuntimeTypeString,
|
|
||||||
} from './utils'
|
|
||||||
import { BindingTypes, unwrapTSNode } from '@vue/compiler-dom'
|
import { BindingTypes, unwrapTSNode } from '@vue/compiler-dom'
|
||||||
|
|
||||||
export const DEFINE_MODEL = 'defineModel'
|
export const DEFINE_MODEL = 'defineModel'
|
||||||
|
@ -124,44 +119,50 @@ export function genModelProps(ctx: ScriptCompileContext) {
|
||||||
|
|
||||||
const isProd = !!ctx.options.isProd
|
const isProd = !!ctx.options.isProd
|
||||||
let modelPropsDecl = ''
|
let modelPropsDecl = ''
|
||||||
for (const [name, { type, options }] of Object.entries(ctx.modelDecls)) {
|
for (const [name, { type, options: runtimeOptions }] of Object.entries(
|
||||||
|
ctx.modelDecls,
|
||||||
|
)) {
|
||||||
let skipCheck = false
|
let skipCheck = false
|
||||||
|
let codegenOptions = ``
|
||||||
let runtimeTypes = type && inferRuntimeType(ctx, type)
|
let runtimeTypes = type && inferRuntimeType(ctx, type)
|
||||||
if (runtimeTypes) {
|
if (runtimeTypes) {
|
||||||
const hasBoolean = runtimeTypes.includes('Boolean')
|
const hasBoolean = runtimeTypes.includes('Boolean')
|
||||||
|
const hasFunction = runtimeTypes.includes('Function')
|
||||||
const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE)
|
const hasUnknownType = runtimeTypes.includes(UNKNOWN_TYPE)
|
||||||
|
|
||||||
if (isProd || hasUnknownType) {
|
if (hasUnknownType) {
|
||||||
runtimeTypes = runtimeTypes.filter(
|
if (hasBoolean || hasFunction) {
|
||||||
t =>
|
runtimeTypes = runtimeTypes.filter(t => t !== UNKNOWN_TYPE)
|
||||||
t === 'Boolean' ||
|
skipCheck = true
|
||||||
(hasBoolean && t === 'String') ||
|
} else {
|
||||||
(t === 'Function' && options),
|
runtimeTypes = ['null']
|
||||||
)
|
|
||||||
|
|
||||||
skipCheck = !isProd && hasUnknownType && runtimeTypes.length > 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let runtimeType =
|
if (!isProd) {
|
||||||
(runtimeTypes &&
|
codegenOptions =
|
||||||
runtimeTypes.length > 0 &&
|
`type: ${toRuntimeTypeString(runtimeTypes)}` +
|
||||||
toRuntimeTypeString(runtimeTypes)) ||
|
(skipCheck ? ', skipCheck: true' : '')
|
||||||
undefined
|
} else if (hasBoolean || (runtimeOptions && hasFunction)) {
|
||||||
|
// preserve types if contains boolean, or
|
||||||
const codegenOptions = concatStrings([
|
// function w/ runtime options that may contain default
|
||||||
runtimeType && `type: ${runtimeType}`,
|
codegenOptions = `type: ${toRuntimeTypeString(runtimeTypes)}`
|
||||||
skipCheck && 'skipCheck: true',
|
} else {
|
||||||
])
|
// able to drop types in production
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let decl: string
|
let decl: string
|
||||||
if (runtimeType && options) {
|
if (codegenOptions && runtimeOptions) {
|
||||||
decl = ctx.isTS
|
decl = ctx.isTS
|
||||||
? `{ ${codegenOptions}, ...${options} }`
|
? `{ ${codegenOptions}, ...${runtimeOptions} }`
|
||||||
: `Object.assign({ ${codegenOptions} }, ${options})`
|
: `Object.assign({ ${codegenOptions} }, ${runtimeOptions})`
|
||||||
|
} else if (codegenOptions) {
|
||||||
|
decl = `{ ${codegenOptions} }`
|
||||||
|
} else if (runtimeOptions) {
|
||||||
|
decl = runtimeOptions
|
||||||
} else {
|
} else {
|
||||||
decl = options || (runtimeType ? `{ ${codegenOptions} }` : '{}')
|
decl = `{}`
|
||||||
}
|
}
|
||||||
modelPropsDecl += `\n ${JSON.stringify(name)}: ${decl},`
|
modelPropsDecl += `\n ${JSON.stringify(name)}: ${decl},`
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/compiler-ssr",
|
"name": "@vue/compiler-ssr",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/compiler-ssr",
|
"description": "@vue/compiler-ssr",
|
||||||
"main": "dist/compiler-ssr.cjs.js",
|
"main": "dist/compiler-ssr.cjs.js",
|
||||||
"types": "dist/compiler-ssr.d.ts",
|
"types": "dist/compiler-ssr.d.ts",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/reactivity",
|
"name": "@vue/reactivity",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/reactivity",
|
"description": "@vue/reactivity",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/reactivity.esm-bundler.js",
|
"module": "dist/reactivity.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/runtime-core",
|
"name": "@vue/runtime-core",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/runtime-core",
|
"description": "@vue/runtime-core",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/runtime-core.esm-bundler.js",
|
"module": "dist/runtime-core.esm-bundler.js",
|
||||||
|
|
|
@ -470,6 +470,7 @@ function getKeepAliveChild(vnode: VNode): VNode | undefined {
|
||||||
|
|
||||||
const { shapeFlag, children } = vnode
|
const { shapeFlag, children } = vnode
|
||||||
|
|
||||||
|
if (children) {
|
||||||
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
|
||||||
return (children as VNodeArrayChildren)[0] as VNode
|
return (children as VNodeArrayChildren)[0] as VNode
|
||||||
}
|
}
|
||||||
|
@ -481,6 +482,7 @@ function getKeepAliveChild(vnode: VNode): VNode | undefined {
|
||||||
return (children as any).default()
|
return (children as any).default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function setTransitionHooks(vnode: VNode, hooks: TransitionHooks) {
|
export function setTransitionHooks(vnode: VNode, hooks: TransitionHooks) {
|
||||||
if (vnode.shapeFlag & ShapeFlags.COMPONENT && vnode.component) {
|
if (vnode.shapeFlag & ShapeFlags.COMPONENT && vnode.component) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* `Object.getPrototypeOf`. This is more performant than defining a
|
* `Object.getPrototypeOf`. This is more performant than defining a
|
||||||
* non-enumerable property. (one of the optimizations done for ssr-benchmark)
|
* non-enumerable property. (one of the optimizations done for ssr-benchmark)
|
||||||
*/
|
*/
|
||||||
const internalObjectProto = Object.create(null)
|
const internalObjectProto = {}
|
||||||
|
|
||||||
export const createInternalObject = () => Object.create(internalObjectProto)
|
export const createInternalObject = () => Object.create(internalObjectProto)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/runtime-dom",
|
"name": "@vue/runtime-dom",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/runtime-dom",
|
"description": "@vue/runtime-dom",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/runtime-dom.esm-bundler.js",
|
"module": "dist/runtime-dom.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/server-renderer",
|
"name": "@vue/server-renderer",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "@vue/server-renderer",
|
"description": "@vue/server-renderer",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/server-renderer.esm-bundler.js",
|
"module": "dist/server-renderer.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/shared",
|
"name": "@vue/shared",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "internal utils shared across @vue packages",
|
"description": "internal utils shared across @vue packages",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/shared.esm-bundler.js",
|
"module": "dist/shared.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@vue/compat",
|
"name": "@vue/compat",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "Vue 3 compatibility build for Vue 2",
|
"description": "Vue 3 compatibility build for Vue 2",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/vue.runtime.esm-bundler.js",
|
"module": "dist/vue.runtime.esm-bundler.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "vue",
|
"name": "vue",
|
||||||
"version": "3.4.24",
|
"version": "3.4.25",
|
||||||
"description": "The progressive JavaScript framework for building modern web UI.",
|
"description": "The progressive JavaScript framework for building modern web UI.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"module": "dist/vue.runtime.esm-bundler.js",
|
"module": "dist/vue.runtime.esm-bundler.js",
|
||||||
|
|
|
@ -3,6 +3,11 @@ import config from './vitest.config'
|
||||||
|
|
||||||
export default mergeConfig(config, {
|
export default mergeConfig(config, {
|
||||||
test: {
|
test: {
|
||||||
|
poolOptions: {
|
||||||
|
threads: {
|
||||||
|
singleThread: !!process.env.CI,
|
||||||
|
},
|
||||||
|
},
|
||||||
include: ['packages/vue/__tests__/e2e/*.spec.ts'],
|
include: ['packages/vue/__tests__/e2e/*.spec.ts'],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue