Skip to content

Commit 6e50040

Browse files
chore: merge conflicts
2 parents 36e7d41 + f18a174 commit 6e50040

File tree

71 files changed

+1185
-291
lines changed

Some content is hidden

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

71 files changed

+1185
-291
lines changed

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"version": "3.3.8",
4-
"packageManager": "[email protected].2",
4+
"packageManager": "[email protected].3",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -27,9 +27,9 @@
2727
"dev-esm": "node scripts/dev.js -if esm-bundler-runtime",
2828
"dev-compiler": "run-p \"dev template-explorer\" serve",
2929
"dev-sfc": "run-s dev-sfc-prepare dev-sfc-run",
30-
"dev-sfc-prepare": "node scripts/pre-dev-sfc.js || npm run build-compiler-cjs",
30+
"dev-sfc-prepare": "node scripts/pre-dev-sfc.js || npm run build-all-cjs",
3131
"dev-sfc-serve": "vite packages/sfc-playground --host",
32-
"dev-sfc-run": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev server-renderer -if esm-bundler\" dev-sfc-serve",
32+
"dev-sfc-run": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev vue -ipf esm-browser-runtime\" \"dev server-renderer -if esm-bundler\" dev-sfc-serve",
3333
"serve": "serve",
3434
"open": "open http://localhost:3000/packages/template-explorer/local.html",
3535
"build-sfc-playground": "run-s build-all-cjs build-runtime-esm build-ssr-esm build-sfc-playground-self",
@@ -57,24 +57,24 @@
5757
"node": ">=18.12.0"
5858
},
5959
"devDependencies": {
60-
"@babel/parser": "^7.23.0",
61-
"@babel/types": "^7.23.0",
60+
"@babel/parser": "^7.23.3",
61+
"@babel/types": "^7.23.3",
6262
"@rollup/plugin-alias": "^5.0.1",
6363
"@rollup/plugin-commonjs": "^25.0.7",
6464
"@rollup/plugin-json": "^6.0.1",
6565
"@rollup/plugin-node-resolve": "^15.2.3",
6666
"@rollup/plugin-replace": "^5.0.4",
6767
"@rollup/plugin-terser": "^0.4.4",
68-
"@types/hash-sum": "^1.0.1",
69-
"@types/node": "^20.8.10",
70-
"@typescript-eslint/parser": "^6.9.1",
68+
"@types/hash-sum": "^1.0.2",
69+
"@types/node": "^20.9.0",
70+
"@typescript-eslint/parser": "^6.10.0",
7171
"@vitest/coverage-istanbul": "^0.34.6",
7272
"@vue/consolidate": "0.17.3",
7373
"conventional-changelog-cli": "^4.1.0",
7474
"enquirer": "^2.4.1",
7575
"esbuild": "^0.19.5",
7676
"esbuild-plugin-polyfill-node": "^0.3.0",
77-
"eslint": "^8.52.0",
77+
"eslint": "^8.53.0",
7878
"eslint-plugin-jest": "^27.6.0",
7979
"estree-walker": "^2.0.2",
8080
"execa": "^8.0.1",
@@ -83,14 +83,14 @@
8383
"lodash": "^4.17.21",
8484
"magic-string": "^0.30.5",
8585
"markdown-table": "^3.0.3",
86-
"marked": "^9.1.4",
86+
"marked": "^9.1.6",
8787
"minimist": "^1.2.8",
8888
"npm-run-all": "^4.1.5",
8989
"picocolors": "^1.0.0",
9090
"prettier": "^3.0.3",
9191
"pretty-bytes": "^6.1.1",
9292
"pug": "^3.0.2",
93-
"puppeteer": "~21.4.1",
93+
"puppeteer": "~21.5.1",
9494
"rimraf": "^5.0.5",
9595
"rollup": "^4.1.4",
9696
"rollup-plugin-dts": "^6.1.0",

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,45 @@ return function render(_ctx, _cache, $props, $setup, $data, $options) {
1313
return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options) + \\" \\" + _toDisplayString($setup.isNaN), 1 /* TEXT */))
1414
}"
1515
`;
16+
17+
exports[`compiler: expression transform > bindingMetadata > should not prefix temp variable of for loop 1`] = `
18+
"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
19+
20+
return function render(_ctx, _cache, $props, $setup, $data, $options) {
21+
return (_openBlock(), _createElementBlock(\\"div\\", {
22+
onClick: () => {
23+
for (let i = 0; i < _ctx.list.length; i++) {
24+
_ctx.log(i)
25+
}
26+
}
27+
}, null, 8 /* PROPS */, [\\"onClick\\"]))
28+
}"
29+
`;
30+
31+
exports[`compiler: expression transform > bindingMetadata > should not prefix temp variable of for...in 1`] = `
32+
"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
33+
34+
return function render(_ctx, _cache, $props, $setup, $data, $options) {
35+
return (_openBlock(), _createElementBlock(\\"div\\", {
36+
onClick: () => {
37+
for (const x in _ctx.list) {
38+
_ctx.log(x)
39+
}
40+
}
41+
}, null, 8 /* PROPS */, [\\"onClick\\"]))
42+
}"
43+
`;
44+
45+
exports[`compiler: expression transform > bindingMetadata > should not prefix temp variable of for...of 1`] = `
46+
"const { openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue
47+
48+
return function render(_ctx, _cache, $props, $setup, $data, $options) {
49+
return (_openBlock(), _createElementBlock(\\"div\\", {
50+
onClick: () => {
51+
for (const x of _ctx.list) {
52+
_ctx.log(x)
53+
}
54+
}
55+
}, null, 8 /* PROPS */, [\\"onClick\\"]))
56+
}"
57+
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ return function render(_ctx, _cache) {
8585
return (_openBlock(), _createElementBlock(\\"input\\", {
8686
\\"foo-value\\": model,
8787
\\"onUpdate:fooValue\\": $event => ((model) = $event)
88-
}, null, 40 /* PROPS, HYDRATE_EVENTS */, [\\"foo-value\\", \\"onUpdate:fooValue\\"]))
88+
}, null, 40 /* PROPS, NEED_HYDRATION */, [\\"foo-value\\", \\"onUpdate:fooValue\\"]))
8989
}
9090
}"
9191
`;

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ describe('compiler: element transform', () => {
10891089
})
10901090
})
10911091

1092-
test('HYDRATE_EVENTS', () => {
1092+
test('NEED_HYDRATION for v-on', () => {
10931093
// ignore click events (has dedicated fast path)
10941094
const { node } = parseWithElementTransform(`<div @click="foo" />`, {
10951095
directiveTransforms: {
@@ -1108,12 +1108,24 @@ describe('compiler: element transform', () => {
11081108
}
11091109
)
11101110
expect(node2.patchFlag).toBe(
1111-
genFlagText([PatchFlags.PROPS, PatchFlags.HYDRATE_EVENTS])
1111+
genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
1112+
)
1113+
})
1114+
1115+
test('NEED_HYDRATION for v-bind.prop', () => {
1116+
const { node } = parseWithBind(`<div v-bind:id.prop="id" />`)
1117+
expect(node.patchFlag).toBe(
1118+
genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
1119+
)
1120+
1121+
const { node: node2 } = parseWithBind(`<div .id="id" />`)
1122+
expect(node2.patchFlag).toBe(
1123+
genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
11121124
)
11131125
})
11141126

11151127
// #5870
1116-
test('HYDRATE_EVENTS on dynamic component', () => {
1128+
test('NEED_HYDRATION on dynamic component', () => {
11171129
const { node } = parseWithElementTransform(
11181130
`<component :is="foo" @input="foo" />`,
11191131
{
@@ -1123,7 +1135,7 @@ describe('compiler: element transform', () => {
11231135
}
11241136
)
11251137
expect(node.patchFlag).toBe(
1126-
genFlagText([PatchFlags.PROPS, PatchFlags.HYDRATE_EVENTS])
1138+
genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
11271139
)
11281140
})
11291141
})

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,42 @@ describe('compiler: expression transform', () => {
534534
expect(code).toMatchSnapshot()
535535
})
536536

537+
test('should not prefix temp variable of for...in', () => {
538+
const { code } = compileWithBindingMetadata(
539+
`<div @click="() => {
540+
for (const x in list) {
541+
log(x)
542+
}
543+
}"/>`
544+
)
545+
expect(code).not.toMatch(`_ctx.x`)
546+
expect(code).toMatchSnapshot()
547+
})
548+
549+
test('should not prefix temp variable of for...of', () => {
550+
const { code } = compileWithBindingMetadata(
551+
`<div @click="() => {
552+
for (const x of list) {
553+
log(x)
554+
}
555+
}"/>`
556+
)
557+
expect(code).not.toMatch(`_ctx.x`)
558+
expect(code).toMatchSnapshot()
559+
})
560+
561+
test('should not prefix temp variable of for loop', () => {
562+
const { code } = compileWithBindingMetadata(
563+
`<div @click="() => {
564+
for (let i = 0; i < list.length; i++) {
565+
log(i)
566+
}
567+
}"/>`
568+
)
569+
expect(code).not.toMatch(`_ctx.i`)
570+
expect(code).toMatchSnapshot()
571+
})
572+
537573
test('inline mode', () => {
538574
const { code } = compileWithBindingMetadata(
539575
`<div>{{ props }} {{ setup }} {{ setupConst }} {{ data }} {{ options }} {{ isNaN }}</div>`,

packages/compiler-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
},
3333
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
3434
"dependencies": {
35-
"@babel/parser": "^7.23.0",
35+
"@babel/parser": "^7.23.3",
3636
"@vue/shared": "3.3.8",
3737
"estree-walker": "^2.0.2",
3838
"source-map-js": "^1.0.2"
3939
},
4040
"devDependencies": {
41-
"@babel/types": "^7.23.0"
41+
"@babel/types": "^7.23.3"
4242
}
4343
}

packages/compiler-core/src/babelUtils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ export function walkBlockDeclarations(
165165
) {
166166
if (stmt.declare || !stmt.id) continue
167167
onIdent(stmt.id)
168+
} else if (
169+
stmt.type === 'ForOfStatement' ||
170+
stmt.type === 'ForInStatement' ||
171+
stmt.type === 'ForStatement'
172+
) {
173+
const variable = stmt.type === 'ForStatement' ? stmt.init : stmt.left
174+
if (variable && variable.type === 'VariableDeclaration') {
175+
for (const decl of variable.declarations) {
176+
for (const id of extractIdentifiers(decl.id)) {
177+
onIdent(id)
178+
}
179+
}
180+
}
168181
}
169182
}
170183
}

packages/compiler-core/src/parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ function parseTextData(
10631063
) {
10641064
return rawText
10651065
} else {
1066-
// DATA or RCDATA containing "&"". Entity decoding required.
1066+
// DATA or RCDATA containing "&". Entity decoding is required.
10671067
return context.options.decodeEntities(
10681068
rawText,
10691069
mode === TextModes.ATTRIBUTE_VALUE

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export function buildProps(
550550
)
551551
} else {
552552
// directives
553-
const { name, arg, exp, loc } = prop
553+
const { name, arg, exp, loc, modifiers } = prop
554554
const isVBind = name === 'bind'
555555
const isVOn = name === 'on'
556556

@@ -678,6 +678,11 @@ export function buildProps(
678678
continue
679679
}
680680

681+
// force hydration for v-bind with .prop modifier
682+
if (isVBind && modifiers.includes('prop')) {
683+
patchFlag |= PatchFlags.NEED_HYDRATION
684+
}
685+
681686
const directiveTransform = context.directiveTransforms[name]
682687
if (directiveTransform) {
683688
// has built-in directive transform.
@@ -743,12 +748,12 @@ export function buildProps(
743748
patchFlag |= PatchFlags.PROPS
744749
}
745750
if (hasHydrationEventBinding) {
746-
patchFlag |= PatchFlags.HYDRATE_EVENTS
751+
patchFlag |= PatchFlags.NEED_HYDRATION
747752
}
748753
}
749754
if (
750755
!shouldUseBlock &&
751-
(patchFlag === 0 || patchFlag === PatchFlags.HYDRATE_EVENTS) &&
756+
(patchFlag === 0 || patchFlag === PatchFlags.NEED_HYDRATION) &&
752757
(hasRef || hasVnodeHook || runtimeDirectives.length > 0)
753758
) {
754759
patchFlag |= PatchFlags.NEED_PATCH

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
isTemplateNode,
3838
isSlotOutlet,
3939
injectProp,
40-
findDir
40+
findDir,
41+
forAliasRE
4142
} from '../utils'
4243
import {
4344
RENDER_LIST,
@@ -308,7 +309,6 @@ export function processFor(
308309
}
309310
}
310311

311-
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/
312312
// This regex doesn't cover the case if key or index aliases have destructuring,
313313
// but those do not make sense in the first place, so this works in practice.
314314
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/

packages/compiler-core/src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,5 @@ export function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression) {
519519
return node
520520
}
521521
}
522+
523+
export const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/

packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ describe('stringify static html', () => {
2020
}
2121

2222
function repeat(code: string, n: number): string {
23-
return new Array(n)
24-
.fill(0)
25-
.map(() => code)
26-
.join('')
23+
return code.repeat(n)
2724
}
2825

2926
test('should bail on non-eligible static trees', () => {

packages/compiler-dom/__tests__/transforms/vOn.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('compiler-dom: transform v-on', () => {
272272
// should not treat cached handler as dynamicProp, so it should have no
273273
// dynamicProps flags and only the hydration flag
274274
expect((root as any).children[0].codegenNode.patchFlag).toBe(
275-
genFlagText(PatchFlags.HYDRATE_EVENTS)
275+
genFlagText(PatchFlags.NEED_HYDRATION)
276276
)
277277
expect(prop).toMatchObject({
278278
key: {

packages/compiler-sfc/__tests__/compileScript/__snapshots__/defineEmits.spec.ts.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ return { emit }
8181
})"
8282
`;
8383

84+
exports[`defineEmits > w/ type (interface w/ extends) 1`] = `
85+
"import { defineComponent as _defineComponent } from 'vue'
86+
interface Base { (e: 'foo'): void }
87+
interface Emits extends Base { (e: 'bar'): void }
88+
89+
export default /*#__PURE__*/_defineComponent({
90+
emits: [\\"bar\\", \\"foo\\"],
91+
setup(__props, { expose: __expose, emit: __emit }) {
92+
__expose();
93+
94+
const emit = __emit
95+
96+
return { emit }
97+
}
98+
99+
})"
100+
`;
101+
84102
exports[`defineEmits > w/ type (interface) 1`] = `
85103
"import { defineComponent as _defineComponent } from 'vue'
86104
interface Emits { (e: 'foo' | 'bar'): void }

0 commit comments

Comments
 (0)