Skip to content

Commit fe1c833

Browse files
authored
Merge branch 'vuejs:main' into types/capitalize
2 parents ec3e6fe + c74d2b2 commit fe1c833

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+964
-383
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
## [3.2.38](https://github.com/vuejs/core/compare/v3.2.37...v3.2.38) (2022-08-30)
2+
3+
4+
### Bug Fixes
5+
6+
* **compiler-sfc:** fix template usage check edge case for v-on statements ([769e555](https://github.com/vuejs/core/commit/769e5555f9d9004ce541613341652db859881570))
7+
* **compiler-sfc:** only add decorators-legacy parser plugin when new decorators plugin is not used ([3ff8369](https://github.com/vuejs/core/commit/3ff83694f523e3fe148d22a469ed742b46603bb4))
8+
* **compiler-sfc:** rewriteDefault for class with decorators ([#6320](https://github.com/vuejs/core/issues/6320)) ([81a7819](https://github.com/vuejs/core/commit/81a7819535c4382ba7817c817722bac6d41921d8)), closes [#6318](https://github.com/vuejs/core/issues/6318)
9+
* **custom-element:** fix event listeners with capital letter event names on custom elements ([0739f89](https://github.com/vuejs/core/commit/0739f8909a0e56ae0fa760f233dfb8c113c9bde2))
10+
* **hmr:** fix HMR for nested non-SFC components ([#4077](https://github.com/vuejs/core/issues/4077)) ([96eb745](https://github.com/vuejs/core/commit/96eb7452548293c343613ab778248a5da9619f45))
11+
* **reactivity:** fix shallow/readonly edge cases ([a95554d](https://github.com/vuejs/core/commit/a95554d35c65e5bfd0bf9d1c5b908ae789345a6d))
12+
* **runtime-core:** only set cache for object keys ([#6266](https://github.com/vuejs/core/issues/6266)) ([c3465c1](https://github.com/vuejs/core/commit/c3465c1e889651df925324ed2a10ac2d5f229110))
13+
* **slots:** ensure different branches of dynamic slots have different keys ([00036bb](https://github.com/vuejs/core/commit/00036bb52c4e641b2be7fa55c39ced9448163b0f)), closes [#6202](https://github.com/vuejs/core/issues/6202)
14+
* **ssr:** forward helpers provided by CSS `v-bind` ([#6489](https://github.com/vuejs/core/issues/6489)) ([2024d11](https://github.com/vuejs/core/commit/2024d11db03d9c6e49e20b3355f3df0ba04bb834)), closes [#6201](https://github.com/vuejs/core/issues/6201)
15+
* **types:** add types field for sub package exports ([c1ee6ca](https://github.com/vuejs/core/commit/c1ee6caa82da89b3a9c33e2253c07a681ebb2628))
16+
* **types:** fix on* props incorrect type for TS 4.7 ([#6216](https://github.com/vuejs/core/issues/6216)) ([8dcb6c7](https://github.com/vuejs/core/commit/8dcb6c7bbdd2905469e2bb11dfff27b58cc784b2)), closes [#6052](https://github.com/vuejs/core/issues/6052)
17+
* **watch:** flush:pre watchers should not fire if state change causes ([78c199d](https://github.com/vuejs/core/commit/78c199d6dbe8931520b75d8bfe0d49366a06922a)), closes [#2291](https://github.com/vuejs/core/issues/2291)
18+
19+
20+
### Features
21+
22+
* **custom-elements:** automatically respect custom elements when compiling in browser ([9f8f07e](https://github.com/vuejs/core/commit/9f8f07ed38b2e003f308875fe3a3e4c0d5477b32))
23+
24+
25+
### Performance Improvements
26+
27+
* **ssr:** improve isComment check ([#6078](https://github.com/vuejs/core/issues/6078)) ([25f7a16](https://github.com/vuejs/core/commit/25f7a16a6eccbfa8d857977dcf1f23fb36b830b5))
28+
29+
30+
131
## [3.2.37](https://github.com/vuejs/core/compare/v3.2.36...v3.2.37) (2022-06-06)
232

333

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "3.2.37",
3+
"version": "3.2.38",
44
"packageManager": "[email protected]",
55
"scripts": {
66
"dev": "node scripts/dev.js",
@@ -51,7 +51,7 @@
5151
"devDependencies": {
5252
"@babel/types": "^7.12.0",
5353
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
54-
"@microsoft/api-extractor": "^7.15.1",
54+
"@microsoft/api-extractor": "~7.20.0",
5555
"@rollup/plugin-commonjs": "^18.0.0",
5656
"@rollup/plugin-json": "^4.0.0",
5757
"@rollup/plugin-node-resolve": "^11.2.1",
@@ -93,8 +93,8 @@
9393
"todomvc-app-css": "^2.3.0",
9494
"ts-jest": "^27.0.5",
9595
"tslib": "^2.4.0",
96-
"typescript": "^4.6.4",
97-
"vite": "^2.9.8",
96+
"typescript": "^4.8.0",
97+
"vite": "^3.0.0",
9898
"vue": "workspace:*",
9999
"yorkie": "^2.0.0"
100100
}

packages/compiler-core/__tests__/__snapshots__/scopeId.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export function render(_ctx, _cache) {
4343
name: \\"foo\\",
4444
fn: _withCtx(() => [
4545
_createElementVNode(\\"div\\")
46-
])
46+
]),
47+
key: \\"0\\"
4748
}
4849
: undefined,
4950
_renderList(_ctx.list, (i) => {

packages/compiler-core/__tests__/transforms/__snapshots__/vSlot.spec.ts.snap

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ return function render(_ctx, _cache) {
5656
(_ctx.ok)
5757
? {
5858
name: \\"one\\",
59-
fn: _withCtx((props) => [_toDisplayString(props)])
59+
fn: _withCtx((props) => [_toDisplayString(props)]),
60+
key: \\"0\\"
6061
}
6162
: undefined
6263
]), 1024 /* DYNAMIC_SLOTS */))
@@ -76,16 +77,19 @@ return function render(_ctx, _cache) {
7677
ok
7778
? {
7879
name: \\"one\\",
79-
fn: _withCtx(() => [\\"foo\\"])
80+
fn: _withCtx(() => [\\"foo\\"]),
81+
key: \\"0\\"
8082
}
8183
: orNot
8284
? {
8385
name: \\"two\\",
84-
fn: _withCtx((props) => [\\"bar\\"])
86+
fn: _withCtx((props) => [\\"bar\\"]),
87+
key: \\"1\\"
8588
}
8689
: {
8790
name: \\"one\\",
88-
fn: _withCtx(() => [\\"baz\\"])
91+
fn: _withCtx(() => [\\"baz\\"]),
92+
key: \\"2\\"
8993
}
9094
]), 1024 /* DYNAMIC_SLOTS */))
9195
}
@@ -105,7 +109,8 @@ return function render(_ctx, _cache) {
105109
ok
106110
? {
107111
name: \\"one\\",
108-
fn: _withCtx(() => [\\"hello\\"])
112+
fn: _withCtx(() => [\\"hello\\"]),
113+
key: \\"0\\"
109114
}
110115
: undefined
111116
]), 1024 /* DYNAMIC_SLOTS */))

packages/compiler-core/__tests__/transforms/transformElement.spec.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,37 @@ describe('compiler: element transform', () => {
314314
)
315315
expect(root.helpers).toContain(MERGE_PROPS)
316316

317+
expect(node.props).toMatchObject({
318+
type: NodeTypes.JS_CALL_EXPRESSION,
319+
callee: MERGE_PROPS,
320+
arguments: [
321+
createObjectMatcher({
322+
id: 'foo'
323+
}),
324+
{
325+
type: NodeTypes.JS_CALL_EXPRESSION,
326+
callee: TO_HANDLERS,
327+
arguments: [
328+
{
329+
type: NodeTypes.SIMPLE_EXPRESSION,
330+
content: `obj`
331+
},
332+
`true`
333+
]
334+
},
335+
createObjectMatcher({
336+
class: 'bar'
337+
})
338+
]
339+
})
340+
})
341+
342+
test('v-on="obj" on component', () => {
343+
const { root, node } = parseWithElementTransform(
344+
`<Foo id="foo" v-on="obj" class="bar" />`
345+
)
346+
expect(root.helpers).toContain(MERGE_PROPS)
347+
317348
expect(node.props).toMatchObject({
318349
type: NodeTypes.JS_CALL_EXPRESSION,
319350
callee: MERGE_PROPS,
@@ -358,7 +389,8 @@ describe('compiler: element transform', () => {
358389
{
359390
type: NodeTypes.SIMPLE_EXPRESSION,
360391
content: `handlers`
361-
}
392+
},
393+
`true`
362394
]
363395
},
364396
{

packages/compiler-core/__tests__/transforms/vSlot.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ describe('compiler: transform component slots', () => {
568568
fn: {
569569
type: NodeTypes.JS_FUNCTION_EXPRESSION,
570570
returns: [{ type: NodeTypes.TEXT, content: `hello` }]
571-
}
571+
},
572+
key: `0`
572573
}),
573574
alternate: {
574575
content: `undefined`,
@@ -616,7 +617,8 @@ describe('compiler: transform component slots', () => {
616617
content: { content: `props` }
617618
}
618619
]
619-
}
620+
},
621+
key: `0`
620622
}),
621623
alternate: {
622624
content: `undefined`,
@@ -660,7 +662,8 @@ describe('compiler: transform component slots', () => {
660662
type: NodeTypes.JS_FUNCTION_EXPRESSION,
661663
params: undefined,
662664
returns: [{ type: NodeTypes.TEXT, content: `foo` }]
663-
}
665+
},
666+
key: `0`
664667
}),
665668
alternate: {
666669
type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
@@ -671,15 +674,17 @@ describe('compiler: transform component slots', () => {
671674
type: NodeTypes.JS_FUNCTION_EXPRESSION,
672675
params: { content: `props` },
673676
returns: [{ type: NodeTypes.TEXT, content: `bar` }]
674-
}
677+
},
678+
key: `1`
675679
}),
676680
alternate: createObjectMatcher({
677681
name: `one`,
678682
fn: {
679683
type: NodeTypes.JS_FUNCTION_EXPRESSION,
680684
params: undefined,
681685
returns: [{ type: NodeTypes.TEXT, content: `baz` }]
682-
}
686+
},
687+
key: `2`
683688
})
684689
}
685690
}

packages/compiler-core/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-core",
3-
"version": "3.2.37",
3+
"version": "3.2.38",
44
"description": "@vue/compiler-core",
55
"main": "index.js",
66
"module": "dist/compiler-core.esm-bundler.js",
@@ -32,7 +32,7 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
35-
"@vue/shared": "3.2.37",
35+
"@vue/shared": "3.2.38",
3636
"@babel/parser": "^7.16.4",
3737
"estree-walker": "^2.0.2",
3838
"source-map": "^0.6.1"

packages/compiler-core/src/transforms/transformElement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ export function buildProps(
647647
type: NodeTypes.JS_CALL_EXPRESSION,
648648
loc,
649649
callee: context.helper(TO_HANDLERS),
650-
arguments: [exp]
650+
arguments: isComponent ? [exp] : [exp, `true`]
651651
})
652652
}
653653
} else {

packages/compiler-core/src/transforms/vOn.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,17 @@ export const transformOn: DirectiveTransform = (
4747
if (rawName.startsWith('vue:')) {
4848
rawName = `vnode-${rawName.slice(4)}`
4949
}
50-
// for all event listeners, auto convert it to camelCase. See issue #2249
51-
eventName = createSimpleExpression(
52-
toHandlerKey(camelize(rawName)),
53-
true,
54-
arg.loc
55-
)
50+
const eventString =
51+
node.tagType === ElementTypes.COMPONENT ||
52+
rawName.startsWith('vnode') ||
53+
!/[A-Z]/.test(rawName)
54+
? // for component and vnode lifecycle event listeners, auto convert
55+
// it to camelCase. See issue #2249
56+
toHandlerKey(camelize(rawName))
57+
// preserve case for plain element listeners that have uppercase
58+
// letters, as these may be custom elements' custom events
59+
: `on:${rawName}`
60+
eventName = createSimpleExpression(eventString, true, arg.loc)
5661
} else {
5762
// #2388
5863
eventName = createCompoundExpression([

packages/compiler-core/src/transforms/vSlot.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export function buildSlots(
160160
let hasNamedDefaultSlot = false
161161
const implicitDefaultChildren: TemplateChildNode[] = []
162162
const seenSlotNames = new Set<string>()
163+
let conditionalBranchIndex = 0
163164

164165
for (let i = 0; i < children.length; i++) {
165166
const slotElement = children[i]
@@ -210,7 +211,7 @@ export function buildSlots(
210211
dynamicSlots.push(
211212
createConditionalExpression(
212213
vIf.exp!,
213-
buildDynamicSlot(slotName, slotFunction),
214+
buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
214215
defaultFallback
215216
)
216217
)
@@ -243,10 +244,14 @@ export function buildSlots(
243244
conditional.alternate = vElse.exp
244245
? createConditionalExpression(
245246
vElse.exp,
246-
buildDynamicSlot(slotName, slotFunction),
247+
buildDynamicSlot(
248+
slotName,
249+
slotFunction,
250+
conditionalBranchIndex++
251+
),
247252
defaultFallback
248253
)
249-
: buildDynamicSlot(slotName, slotFunction)
254+
: buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++)
250255
} else {
251256
context.onError(
252257
createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, vElse.loc)
@@ -369,12 +374,19 @@ export function buildSlots(
369374

370375
function buildDynamicSlot(
371376
name: ExpressionNode,
372-
fn: FunctionExpression
377+
fn: FunctionExpression,
378+
index?: number
373379
): ObjectExpression {
374-
return createObjectExpression([
380+
const props = [
375381
createObjectProperty(`name`, name),
376382
createObjectProperty(`fn`, fn)
377-
])
383+
]
384+
if (index != null) {
385+
props.push(
386+
createObjectProperty(`key`, createSimpleExpression(String(index), true))
387+
)
388+
}
389+
return createObjectExpression(props)
378390
}
379391

380392
function hasForwardedSlots(children: TemplateChildNode[]): boolean {

packages/compiler-dom/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/compiler-dom",
3-
"version": "3.2.37",
3+
"version": "3.2.38",
44
"description": "@vue/compiler-dom",
55
"main": "index.js",
66
"module": "dist/compiler-dom.esm-bundler.js",
@@ -37,7 +37,7 @@
3737
},
3838
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
3939
"dependencies": {
40-
"@vue/shared": "3.2.37",
41-
"@vue/compiler-core": "3.2.37"
40+
"@vue/shared": "3.2.38",
41+
"@vue/compiler-core": "3.2.38"
4242
}
4343
}

packages/compiler-sfc/__tests__/compileScript.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,19 @@ defineExpose({ foo: 123 })
461461
expect(content).toMatch(`return { a, b, Baz }`)
462462
assertCode(content)
463463
})
464+
465+
// vuejs/vue#12591
466+
test('v-on inline statement', () => {
467+
// should not error
468+
compile(`
469+
<script setup lang="ts">
470+
import { foo } from './foo'
471+
</script>
472+
<template>
473+
<div @click="$emit('update:a');"></div>
474+
</tempalte>
475+
`)
476+
})
464477
})
465478

466479
describe('inlineTemplate mode', () => {

0 commit comments

Comments
 (0)