Skip to content

Commit

Permalink
Merge pull request #150 from vuejs/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Tomxuetao committed May 7, 2024
2 parents bad20ca + 4619461 commit 44f40c7
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 598 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
## [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.4.26](https://github.com/vuejs/core/compare/v3.4.25...v3.4.26) (2024-04-29)


Expand Down
14 changes: 7 additions & 7 deletions package.json
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.4.26",
"packageManager": "pnpm@9.0.6",
"version": "3.4.27",
"packageManager": "pnpm@9.1.0",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -70,7 +70,7 @@
"@rollup/plugin-terser": "^0.4.4",
"@types/hash-sum": "^1.0.2",
"@types/minimist": "^1.2.5",
"@types/node": "^20.12.7",
"@types/node": "^20.12.10",
"@types/semver": "^7.5.8",
"@vitest/coverage-istanbul": "^1.5.2",
"@vue/consolidate": "1.0.0",
Expand All @@ -97,20 +97,20 @@
"pug": "^3.0.2",
"puppeteer": "~22.7.1",
"rimraf": "^5.0.5",
"rollup": "^4.17.1",
"rollup": "^4.17.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"semver": "^7.6.0",
"serve": "^14.2.3",
"simple-git-hooks": "^2.11.1",
"terser": "^5.30.4",
"terser": "^5.31.0",
"todomvc-app-css": "^2.4.3",
"tslib": "^2.6.2",
"tsx": "^4.7.3",
"tsx": "^4.9.3",
"typescript": "~5.4.5",
"typescript-eslint": "^7.7.1",
"vite": "^5.2.10",
"vite": "^5.2.11",
"vitest": "^1.5.2"
},
"pnpm": {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-dom/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
Expand Down
36 changes: 36 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
Expand Up @@ -447,6 +447,42 @@ describe('resolveType', () => {
})
})

test('keyof', () => {
const files = {
'/foo.ts': `export type IMP = { ${1}: 1 };`,
}

const { props } = resolve(
`
import { IMP } from './foo'
interface Foo { foo: 1, ${1}: 1 }
type Bar = { bar: 1 }
declare const obj: Bar
declare const set: Set<any>
declare const arr: Array<any>
defineProps<{
imp: keyof IMP,
foo: keyof Foo,
bar: keyof Bar,
obj: keyof typeof obj,
set: keyof typeof set,
arr: keyof typeof arr
}>()
`,
files,
)

expect(props).toStrictEqual({
imp: ['Number'],
foo: ['String', 'Number'],
bar: ['String'],
obj: ['String'],
set: ['String'],
arr: ['String', 'Number'],
})
})

test('ExtractPropTypes (element-plus)', () => {
const { props, raw } = resolve(
`
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-sfc/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-sfc",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
Expand Down Expand Up @@ -62,6 +62,6 @@
"postcss-modules": "^6.0.0",
"postcss-selector-parser": "^6.0.16",
"pug": "^3.0.2",
"sass": "^1.75.0"
"sass": "^1.76.0"
}
}
38 changes: 34 additions & 4 deletions packages/compiler-sfc/src/script/resolveType.ts
Expand Up @@ -1448,6 +1448,7 @@ export function inferRuntimeType(
ctx: TypeResolveContext,
node: Node & MaybeWithScope,
scope = node._ownerScope || ctxToScope(ctx),
isKeyOf = false,
): string[] {
try {
switch (node.type) {
Expand All @@ -1467,8 +1468,18 @@ export function inferRuntimeType(
const types = new Set<string>()
const members =
node.type === 'TSTypeLiteral' ? node.members : node.body.body

for (const m of members) {
if (
if (isKeyOf) {
if (
m.type === 'TSPropertySignature' &&
m.key.type === 'NumericLiteral'
) {
types.add('Number')
} else {
types.add('String')
}
} else if (
m.type === 'TSCallSignatureDeclaration' ||
m.type === 'TSConstructSignatureDeclaration'
) {
Expand All @@ -1477,6 +1488,7 @@ export function inferRuntimeType(
types.add('Object')
}
}

return types.size ? Array.from(types) : ['Object']
}
case 'TSPropertySignature':
Expand Down Expand Up @@ -1512,9 +1524,22 @@ export function inferRuntimeType(
case 'TSTypeReference': {
const resolved = resolveTypeReference(ctx, node, scope)
if (resolved) {
return inferRuntimeType(ctx, resolved, resolved._ownerScope)
return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf)
}

if (node.typeName.type === 'Identifier') {
if (isKeyOf) {
switch (node.typeName.name) {
case 'String':
case 'Array':
case 'ArrayLike':
case 'ReadonlyArray':
return ['String', 'Number']
default:
return ['String']
}
}

switch (node.typeName.name) {
case 'Array':
case 'Function':
Expand Down Expand Up @@ -1634,15 +1659,20 @@ export function inferRuntimeType(
// typeof only support identifier in local scope
const matched = scope.declares[id.name]
if (matched) {
return inferRuntimeType(ctx, matched, matched._ownerScope)
return inferRuntimeType(ctx, matched, matched._ownerScope, isKeyOf)
}
}
break
}

// e.g. readonly
case 'TSTypeOperator': {
return inferRuntimeType(ctx, node.typeAnnotation, scope)
return inferRuntimeType(
ctx,
node.typeAnnotation,
scope,
node.operator === 'keyof',
)
}
}
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-ssr/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-ssr",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/compiler-ssr",
"main": "dist/compiler-ssr.cjs.js",
"types": "dist/compiler-ssr.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/dts-test/defineComponent.test-d.tsx
Expand Up @@ -1501,7 +1501,7 @@ describe('should work when props type is incompatible with setup returned type '

describe('withKeys and withModifiers as pro', () => {
const onKeydown = withKeys(e => {}, [''])
const onClick = withModifiers(e => {}, [''])
const onClick = withModifiers(e => {}, [])
;<input onKeydown={onKeydown} onClick={onClick} />
})

Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/reactivity",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/reactivity",
"main": "index.js",
"module": "dist/reactivity.esm-bundler.js",
Expand Down
7 changes: 7 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Expand Up @@ -1527,6 +1527,13 @@ describe('SSR hydration', () => {
expect(`Hydration style mismatch`).toHaveBeenWarnedTimes(1)
})

test('style mismatch when no style attribute is present', () => {
mountWithHydration(`<div></div>`, () =>
h('div', { style: { color: 'red' } }),
)
expect(`Hydration style mismatch`).toHaveBeenWarnedTimes(1)
})

test('style mismatch w/ v-show', () => {
mountWithHydration(`<div style="color:red;display:none"></div>`, () =>
withDirectives(createVNode('div', { style: 'color: red' }, ''), [
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/runtime-core",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/runtime-core",
"main": "index.js",
"module": "dist/runtime-core.esm-bundler.js",
Expand Down
12 changes: 2 additions & 10 deletions packages/runtime-core/src/compat/instance.ts
Expand Up @@ -36,8 +36,7 @@ import {
legacyresolveScopedSlots,
} from './renderHelpers'
import { resolveFilter } from '../helpers/resolveAssets'
import type { InternalSlots, Slots } from '../componentSlots'
import type { ContextualRenderFn } from '../componentRenderContext'
import type { Slots } from '../componentSlots'
import { resolveMergedOptions } from '../componentOptions'

export type LegacyPublicInstance = ComponentPublicInstance &
Expand Down Expand Up @@ -106,14 +105,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {

$scopedSlots: i => {
assertCompatEnabled(DeprecationTypes.INSTANCE_SCOPED_SLOTS, i)
const res: InternalSlots = {}
for (const key in i.slots) {
const fn = i.slots[key]!
if (!(fn as ContextualRenderFn)._ns /* non-scoped slot */) {
res[key] = fn
}
}
return res
return __DEV__ ? shallowReadonly(i.slots) : i.slots
},

$on: i => on.bind(null, i),
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-core/src/hydration.ts
Expand Up @@ -727,8 +727,8 @@ function propHasMismatch(
): boolean {
let mismatchType: string | undefined
let mismatchKey: string | undefined
let actual: any
let expected: any
let actual: string | boolean | null | undefined
let expected: string | boolean | null | undefined
if (key === 'class') {
// classes might be in different order, but that doesn't affect cascade
// so we just need to check if the class lists contain the same classes.
Expand All @@ -739,7 +739,7 @@ function propHasMismatch(
}
} else if (key === 'style') {
// style might be in different order, but that doesn't affect cascade
actual = el.getAttribute('style')
actual = el.getAttribute('style') || ''
expected = isString(clientValue)
? clientValue
: stringifyStyle(normalizeStyle(clientValue))
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/__tests__/directives/vOn.spec.ts
Expand Up @@ -43,7 +43,7 @@ describe('runtime-dom: v-on directive', () => {
})

test('it should support key modifiers and system modifiers', () => {
const keyNames = ['ctrl', 'shift', 'meta', 'alt']
const keyNames = ['ctrl', 'shift', 'meta', 'alt'] as const

keyNames.forEach(keyName => {
const el = document.createElement('div')
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/runtime-dom",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/runtime-dom",
"main": "index.js",
"module": "dist/runtime-dom.esm-bundler.js",
Expand Down
16 changes: 14 additions & 2 deletions packages/runtime-dom/src/directives/vOn.ts
Expand Up @@ -10,9 +10,21 @@ import { hyphenate, isArray } from '@vue/shared'
const systemModifiers = ['ctrl', 'shift', 'alt', 'meta']

type KeyedEvent = KeyboardEvent | MouseEvent | TouchEvent
type ModifierGuardsKeys =
| 'stop'
| 'prevent'
| 'self'
| 'ctrl'
| 'shift'
| 'alt'
| 'meta'
| 'left'
| 'middle'
| 'right'
| 'exact'

const modifierGuards: Record<
string,
ModifierGuardsKeys,
(e: Event, modifiers: string[]) => void | boolean
> = {
stop: e => e.stopPropagation(),
Expand All @@ -36,7 +48,7 @@ export const withModifiers = <
T extends (event: Event, ...args: unknown[]) => any,
>(
fn: T & { _withMods?: { [key: string]: T } },
modifiers: string[],
modifiers: ModifierGuardsKeys[],
) => {
const cache = fn._withMods || (fn._withMods = {})
const cacheKey = modifiers.join('.')
Expand Down
2 changes: 1 addition & 1 deletion packages/server-renderer/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/server-renderer",
"version": "3.4.26",
"version": "3.4.27",
"description": "@vue/server-renderer",
"main": "index.js",
"module": "dist/server-renderer.esm-bundler.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/sfc-playground/package.json
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"vite": "^5.2.10"
"vite": "^5.2.11"
},
"dependencies": {
"@vue/repl": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/sfc-playground/src/download/template/package.json
Expand Up @@ -12,6 +12,6 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"vite": "^5.2.10"
"vite": "^5.2.11"
}
}
2 changes: 1 addition & 1 deletion packages/shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@vue/shared",
"version": "3.4.26",
"version": "3.4.27",
"description": "internal utils shared across @vue packages",
"main": "index.js",
"module": "dist/shared.esm-bundler.js",
Expand Down

0 comments on commit 44f40c7

Please sign in to comment.