Skip to content

Commit 10e3558

Browse files
committed
Merge remote-tracking branch 'upstream/main' into computed-ondemand
2 parents 57407c1 + 439377b commit 10e3558

File tree

97 files changed

+1863
-613
lines changed

Some content is hidden

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

97 files changed

+1863
-613
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ body:
1717
Also try to search for your issue - it may have already been answered or even fixed in the development branch.
1818
However, if you find that an old, closed issue still persists in the latest version,
1919
you should open a new issue using the form below instead of commenting on the old issue.
20+
- type: input
21+
id: version
22+
attributes:
23+
label: Vue version
24+
validations:
25+
required: true
2026
- type: input
2127
id: reproduction-link
2228
attributes:

.github/contributing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Hi! I'm really excited that you are interested in contributing to Vue.js. Before
1919

2020
- Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch.
2121

22+
- [Make sure to tick the "Allow edits from maintainers" box](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This allows us to directly make minor edits / refactors and saves a lot of time.
23+
2224
- If adding a new feature:
2325

2426
- Add accompanying test case.

.github/workflows/ci.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ jobs:
1313
- uses: actions/checkout@v2
1414

1515
- name: Install pnpm
16-
uses: pnpm/[email protected]
17-
with:
18-
version: 7.0.1
16+
uses: pnpm/action-setup@v2
1917

2018
- name: Set node version to 16
2119
uses: actions/setup-node@v2
@@ -34,9 +32,7 @@ jobs:
3432
- uses: actions/checkout@v2
3533

3634
- name: Install pnpm
37-
uses: pnpm/[email protected]
38-
with:
39-
version: 7.0.1
35+
uses: pnpm/action-setup@v2
4036

4137
- name: Set node version to 16
4238
uses: actions/setup-node@v2
@@ -55,9 +51,7 @@ jobs:
5551
- uses: actions/checkout@v2
5652

5753
- name: Install pnpm
58-
uses: pnpm/[email protected]
59-
with:
60-
version: 7.0.1
54+
uses: pnpm/action-setup@v2
6155

6256
- name: Set node version to 16
6357
uses: actions/setup-node@v2
@@ -81,9 +75,7 @@ jobs:
8175
- uses: actions/checkout@v2
8276

8377
- name: Install pnpm
84-
uses: pnpm/[email protected]
85-
with:
86-
version: 7.0.1
78+
uses: pnpm/action-setup@v2
8779

8880
- name: Set node version to 16
8981
uses: actions/setup-node@v2

CHANGELOG.md

Lines changed: 122 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"private": true,
3-
"version": "3.2.33",
3+
"version": "3.2.36",
4+
"packageManager": "[email protected]",
45
"scripts": {
56
"dev": "node scripts/dev.js",
67
"build": "node scripts/build.js",
@@ -17,13 +18,14 @@
1718
"test-coverage": "node scripts/build.js vue -f global -d && jest --runInBand --coverage --bail",
1819
"release": "node scripts/release.js",
1920
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
21+
"dev-esm": "node scripts/dev.js -if esm-bundler-runtime",
2022
"dev-compiler": "run-p \"dev template-explorer\" serve",
21-
"dev-sfc": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime \" serve-sfc-playground",
23+
"dev-sfc": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev server-renderer -if esm-bundler\" serve-sfc-playground",
2224
"serve-sfc-playground": "vite packages/sfc-playground --host",
2325
"serve": "serve",
2426
"open": "open http://localhost:5000/packages/template-explorer/local.html",
2527
"preinstall": "node ./scripts/preinstall.js",
26-
"prebuild-sfc-playground": "node scripts/build.js compiler reactivity-transform shared -af cjs && node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime && node scripts/build.js compiler-sfc -f esm-browser",
28+
"prebuild-sfc-playground": "node scripts/build.js compiler reactivity-transform shared -af cjs && node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime && node scripts/build.js compiler-sfc server-renderer -f esm-browser",
2729
"build-sfc-playground": "cd packages/sfc-playground && npm run build"
2830
},
2931
"types": "test-dts/index.d.ts",

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@ return function render(_ctx, _cache) {
211211
}"
212212
`;
213213
214+
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist SVG with directives 1`] = `
215+
"const _Vue = Vue
216+
const { createElementVNode: _createElementVNode } = _Vue
217+
218+
const _hoisted_1 = /*#__PURE__*/_createElementVNode(\\"path\\", { d: \\"M2,3H5.5L12\\" }, null, -1 /* HOISTED */)
219+
const _hoisted_2 = [
220+
_hoisted_1
221+
]
222+
223+
return function render(_ctx, _cache) {
224+
with (_ctx) {
225+
const { createElementVNode: _createElementVNode, resolveDirective: _resolveDirective, openBlock: _openBlock, createElementBlock: _createElementBlock, withDirectives: _withDirectives } = _Vue
226+
227+
const _directive_foo = _resolveDirective(\\"foo\\")
228+
229+
return (_openBlock(), _createElementBlock(\\"div\\", null, [
230+
_withDirectives((_openBlock(), _createElementBlock(\\"svg\\", null, _hoisted_2)), [
231+
[_directive_foo]
232+
])
233+
]))
234+
}
235+
}"
236+
`;
237+
214238
exports[`compiler: hoistStatic transform prefixIdentifiers should NOT hoist elements with cached handlers + other bindings 1`] = `
215239
"import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
216240

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,5 +616,11 @@ describe('compiler: hoistStatic transform', () => {
616616
expect(root.hoists.length).toBe(0)
617617
expect(generate(root).code).toMatchSnapshot()
618618
})
619+
620+
test('should NOT hoist SVG with directives', () => {
621+
const root = transformWithHoist(`<div><svg v-foo><path d="M2,3H5.5L12"/></svg></div>`)
622+
expect(root.hoists.length).toBe(2)
623+
expect(generate(root).code).toMatchSnapshot()
624+
})
619625
})
620626
})

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,21 @@ describe('compiler: element transform', () => {
10531053
genFlagText([PatchFlags.PROPS, PatchFlags.HYDRATE_EVENTS])
10541054
)
10551055
})
1056+
1057+
// #5870
1058+
test('HYDRATE_EVENTS on dynamic component', () => {
1059+
const { node } = parseWithElementTransform(
1060+
`<component :is="foo" @input="foo" />`,
1061+
{
1062+
directiveTransforms: {
1063+
on: transformOn
1064+
}
1065+
}
1066+
)
1067+
expect(node.patchFlag).toBe(
1068+
genFlagText([PatchFlags.PROPS, PatchFlags.HYDRATE_EVENTS])
1069+
)
1070+
})
10561071
})
10571072

10581073
describe('dynamic component', () => {

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.33",
3+
"version": "3.2.36",
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.33",
35+
"@vue/shared": "3.2.36",
3636
"@babel/parser": "^7.16.4",
3737
"estree-walker": "^2.0.2",
3838
"source-map": "^0.6.1"

packages/compiler-core/src/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface DirectiveTransformResult {
6868
ssrTagParts?: TemplateLiteral['elements']
6969
}
7070

71-
// A structural directive transform is a technically a NodeTransform;
71+
// A structural directive transform is technically also a NodeTransform;
7272
// Only v-if and v-for fall into this category.
7373
export type StructuralDirectiveTransform = (
7474
node: ElementNode,

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ export function getConstantType(
230230
// static then they don't need to be blocks since there will be no
231231
// nested updates.
232232
if (codegenNode.isBlock) {
233+
// except set custom directives.
234+
for (let i = 0; i < node.props.length; i++) {
235+
const p = node.props[i]
236+
if (p.type === NodeTypes.DIRECTIVE) {
237+
constantCache.set(node, ConstantTypes.NOT_CONSTANT)
238+
return ConstantTypes.NOT_CONSTANT
239+
}
240+
}
241+
233242
context.removeHelper(OPEN_BLOCK)
234243
context.removeHelper(
235244
getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ export const transformElement: NodeTransform = (node, context) => {
121121

122122
// props
123123
if (props.length > 0) {
124-
const propsBuildResult = buildProps(node, context)
124+
const propsBuildResult = buildProps(
125+
node,
126+
context,
127+
undefined,
128+
isComponent,
129+
isDynamicComponent
130+
)
125131
vnodeProps = propsBuildResult.props
126132
patchFlag = propsBuildResult.patchFlag
127133
dynamicPropNames = propsBuildResult.dynamicPropNames
@@ -380,6 +386,8 @@ export function buildProps(
380386
node: ElementNode,
381387
context: TransformContext,
382388
props: ElementNode['props'] = node.props,
389+
isComponent: boolean,
390+
isDynamicComponent: boolean,
383391
ssr = false
384392
): {
385393
props: PropsExpression | undefined
@@ -389,7 +397,6 @@ export function buildProps(
389397
shouldUseBlock: boolean
390398
} {
391399
const { tag, loc: elementLoc, children } = node
392-
const isComponent = node.tagType === ElementTypes.COMPONENT
393400
let properties: ObjectExpression['properties'] = []
394401
const mergeArgs: PropsExpression[] = []
395402
const runtimeDirectives: DirectiveNode[] = []
@@ -411,8 +418,8 @@ export function buildProps(
411418
const name = key.content
412419
const isEventHandler = isOn(name)
413420
if (
414-
!isComponent &&
415421
isEventHandler &&
422+
(!isComponent || isDynamicComponent) &&
416423
// omit the flag for click handlers because hydration gives click
417424
// dedicated fast path.
418425
name.toLowerCase() !== 'onclick' &&

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export function processSlotOutlet(
8787
}
8888

8989
if (nonNameProps.length > 0) {
90-
const { props, directives } = buildProps(node, context, nonNameProps)
90+
const { props, directives } = buildProps(
91+
node,
92+
context,
93+
nonNameProps,
94+
false,
95+
false
96+
)
9197
slotProps = props
9298

9399
if (directives.length) {

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.33",
3+
"version": "3.2.36",
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.33",
41-
"@vue/compiler-core": "3.2.33"
40+
"@vue/shared": "3.2.36",
41+
"@vue/compiler-core": "3.2.36"
4242
}
4343
}

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default {
205205
expose();
206206

207207
let __temp, __restore
208-
if (ok) {
208+
if (ok) {
209209
for (let a of [1,2,3]) {
210210
(
211211
([__temp,__restore] = _withAsyncContext(() => a)),
@@ -240,7 +240,7 @@ export default {
240240
expose();
241241

242242
let __temp, __restore
243-
if (ok) {
243+
if (ok) {
244244
while (d) {
245245
(
246246
([__temp,__restore] = _withAsyncContext(() => 5)),
@@ -295,7 +295,7 @@ export default {
295295
expose();
296296

297297
let __temp, __restore
298-
if (ok) {
298+
if (ok) {
299299
let a = 'foo'
300300
;(
301301
([__temp,__restore] = _withAsyncContext(() => 0)),
@@ -351,7 +351,7 @@ if (ok) {
351351
__restore()
352352
)
353353
}
354-
} else {
354+
} else {
355355
(
356356
([__temp,__restore] = _withAsyncContext(() => 5)),
357357
await __temp,
@@ -722,7 +722,7 @@ return { props, a, emit }
722722

723723
exports[`SFC compile <script setup> dev mode import usage check TS annotations 1`] = `
724724
"import { defineComponent as _defineComponent } from 'vue'
725-
import { Foo, Bar, Baz } from './x'
725+
import { Foo, Bar, Baz, Qux, Fred } from './x'
726726

727727
export default /*#__PURE__*/_defineComponent({
728728
setup(__props, { expose }) {
@@ -1039,24 +1039,19 @@ return (_ctx, _cache) => {
10391039
`;
10401040

10411041
exports[`SFC compile <script setup> inlineTemplate mode ssr codegen 1`] = `
1042-
"import { useCssVars as _useCssVars, unref as _unref } from 'vue'
1043-
import { ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
1042+
"import { ssrRenderAttrs as _ssrRenderAttrs, ssrInterpolate as _ssrInterpolate } from \\"vue/server-renderer\\"
10441043

10451044
import { ref } from 'vue'
10461045

10471046
export default {
10481047
__ssrInlineRender: true,
10491048
setup(__props) {
10501049

1051-
_useCssVars(_ctx => ({
1052-
\\"xxxxxxxx-count\\": (count.value)
1053-
}))
1054-
10551050
const count = ref(0)
10561051

10571052
return (_ctx, _push, _parent, _attrs) => {
10581053
const _cssVars = { style: {
1059-
\\"xxxxxxxx-count\\": (count.value)
1054+
\\"--xxxxxxxx-count\\": (count.value)
10601055
}}
10611056
_push(\`<!--[--><div\${
10621057
_ssrRenderAttrs(_cssVars)

0 commit comments

Comments
 (0)