From e80cd09fff570df57d608f8f5aaccee6d7f31917 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Oct 2022 21:22:26 +0800 Subject: [PATCH 01/70] Revert "fix(setup): setup hook should be called before beforeCreate" This reverts commit e1342df7847a51c75192fec74e94378178e046b0. reopen #12802 close #12821 close #12822 --- src/core/instance/init.ts | 9 ++------- src/core/instance/state.ts | 9 +++++++-- test/unit/features/v3/apiSetup.spec.ts | 28 +------------------------- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/core/instance/init.ts b/src/core/instance/init.ts index 3fdfcf4f0cf..91456c21920 100644 --- a/src/core/instance/init.ts +++ b/src/core/instance/init.ts @@ -1,6 +1,6 @@ import config from '../config' import { initProxy } from './proxy' -import { initProps, initState } from './state' +import { initState } from './state' import { initRender } from './render' import { initEvents } from './events' import { mark, measure } from '../util/perf' @@ -10,7 +10,6 @@ import { extend, mergeOptions, formatComponentName } from '../util/index' import type { Component } from 'types/component' import type { InternalComponentOptions } from 'types/options' import { EffectScope } from 'v3/reactivity/effectScope' -import { initSetup } from '../../v3/apiSetup' let uid = 0 @@ -60,12 +59,8 @@ export function initMixin(Vue: typeof Component) { initLifecycle(vm) initEvents(vm) initRender(vm) - - const opts = vm.$options - initInjections(vm) // resolve injections before data/props - initProps(vm, opts.props) - initSetup(vm) callHook(vm, 'beforeCreate', undefined, false /* setContext */) + initInjections(vm) // resolve injections before data/props initState(vm) initProvide(vm) // resolve provide after data/props callHook(vm, 'created') diff --git a/src/core/instance/state.ts b/src/core/instance/state.ts index 52b23cfd430..aedb72555c9 100644 --- a/src/core/instance/state.ts +++ b/src/core/instance/state.ts @@ -2,6 +2,7 @@ import config from '../config' import Watcher from '../observer/watcher' import Dep, { pushTarget, popTarget } from '../observer/dep' import { isUpdatingChildComponent } from './lifecycle' +import { initSetup } from 'v3/apiSetup' import { set, @@ -50,6 +51,11 @@ export function proxy(target: Object, sourceKey: string, key: string) { export function initState(vm: Component) { const opts = vm.$options + if (opts.props) initProps(vm, opts.props) + + // Composition API + initSetup(vm) + if (opts.methods) initMethods(vm, opts.methods) if (opts.data) { initData(vm) @@ -63,8 +69,7 @@ export function initState(vm: Component) { } } -export function initProps(vm: Component, propsOptions: Object | undefined) { - if (!propsOptions) return +function initProps(vm: Component, propsOptions: Object) { const propsData = vm.$options.propsData || {} const props = (vm._props = shallowReactive({})) // cache prop keys so that future props updates can iterate using Array diff --git a/test/unit/features/v3/apiSetup.spec.ts b/test/unit/features/v3/apiSetup.spec.ts index 21b83769402..11757878e9c 100644 --- a/test/unit/features/v3/apiSetup.spec.ts +++ b/test/unit/features/v3/apiSetup.spec.ts @@ -263,7 +263,7 @@ describe('api: setup context', () => { }).$mount() expect(spy).toHaveBeenCalled() }) - + // #12561 it('setup props should be reactive', () => { const msg = ref('hi') @@ -333,30 +333,4 @@ describe('api: setup context', () => { await nextTick() expect(_listeners.foo()).toBe(2) }) - - // #12802 - it('should be called before all lifecycle hooks', () => { - const calls: string[] = [] - - Vue.mixin({ - beforeCreate() { - calls.push('global beforeCreate') - } - }) - - new Vue({ - beforeCreate() { - calls.push('component beforeCreate') - }, - setup() { - calls.push('setup') - } - }) - - expect(calls).toEqual([ - 'setup', - 'global beforeCreate', - 'component beforeCreate' - ]) - }) }) From 4cad41007174a7eeebf4472ddbd7b3b693db03f1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Oct 2022 21:41:36 +0800 Subject: [PATCH 02/70] release: v2.7.12 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- packages/compiler-sfc/package.json | 2 +- packages/server-renderer/package.json | 2 +- packages/template-compiler/package.json | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb79445878..4d831fa047c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [2.7.12](https://github.com/vuejs/vue/compare/v2.7.11...v2.7.12) (2022-10-12) + + +### Reverts + +* Revert "fix(setup): setup hook should be called before beforeCreate" ([e80cd09](https://github.com/vuejs/vue/commit/e80cd09fff570df57d608f8f5aaccee6d7f31917)), closes [#12802](https://github.com/vuejs/vue/issues/12802) [#12821](https://github.com/vuejs/vue/issues/12821) [#12822](https://github.com/vuejs/vue/issues/12822) + + + ## [2.7.11](https://github.com/vuejs/vue/compare/v2.7.10...v2.7.11) (2022-10-11) diff --git a/package.json b/package.json index d2210465745..2bb114433f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue", - "version": "2.7.11", + "version": "2.7.12", "packageManager": "pnpm@7.1.0", "description": "Reactive, component-oriented view layer for modern web interfaces.", "main": "dist/vue.runtime.common.js", diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index 89cabf64059..e8ee4ecf382 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-sfc", - "version": "2.7.11", + "version": "2.7.12", "description": "compiler-sfc for Vue 2", "main": "dist/compiler-sfc.js", "types": "dist/compiler-sfc.d.ts", diff --git a/packages/server-renderer/package.json b/packages/server-renderer/package.json index ea9d4326d3d..cfda873a1c8 100644 --- a/packages/server-renderer/package.json +++ b/packages/server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "vue-server-renderer", - "version": "2.7.11", + "version": "2.7.12", "description": "server renderer for Vue 2.0", "main": "index.js", "types": "types/index.d.ts", diff --git a/packages/template-compiler/package.json b/packages/template-compiler/package.json index 3f612871fc1..fd22b64d90b 100644 --- a/packages/template-compiler/package.json +++ b/packages/template-compiler/package.json @@ -1,6 +1,6 @@ { "name": "vue-template-compiler", - "version": "2.7.11", + "version": "2.7.12", "description": "template compiler for Vue 2.0", "main": "index.js", "unpkg": "browser.js", From 8e262618cdc3251ca9630b17de4a000567ffb007 Mon Sep 17 00:00:00 2001 From: Blake Newman Date: Wed, 12 Oct 2022 14:24:26 +0100 Subject: [PATCH 03/70] fix(types): style attribute svg (#12800) Set style attribute on svg to use `StyleValue` --- types/jsx.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jsx.d.ts b/types/jsx.d.ts index 85c9c1df23d..4924f4c643c 100644 --- a/types/jsx.d.ts +++ b/types/jsx.d.ts @@ -731,7 +731,7 @@ export interface SVGAttributes extends AriaAttributes, EventHandlers { * @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling */ class?: any - style?: string | CSSProperties + style?: StyleValue color?: string height?: Numberish From 5960f05c69099c174062b6672c7a21d717a3bccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E8=A7=81=E6=9C=88?= <61452855+nooooooom@users.noreply.github.com> Date: Wed, 12 Oct 2022 21:25:26 +0800 Subject: [PATCH 04/70] fix(watch): avoid traversing objects that are marked non-reactive (#12806) --- src/core/observer/traverse.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/observer/traverse.ts b/src/core/observer/traverse.ts index 5f4e378b194..c681e0c9285 100644 --- a/src/core/observer/traverse.ts +++ b/src/core/observer/traverse.ts @@ -21,6 +21,7 @@ function _traverse(val: any, seen: SimpleSet) { const isA = isArray(val) if ( (!isA && !isObject(val)) || + val.__v_skip /* ReactiveFlags.SKIP */ || Object.isFrozen(val) || val instanceof VNode ) { From 800207c473c7d6dfcdc883100a3d443fc5ad2e39 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 14 Oct 2022 10:51:07 +0800 Subject: [PATCH 05/70] fix(effectScope): calling off() of a detached scope should not break currentScope fix #12825 --- src/v3/reactivity/effectScope.ts | 9 ++++----- test/unit/features/v3/reactivity/effectScope.spec.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/v3/reactivity/effectScope.ts b/src/v3/reactivity/effectScope.ts index 2ba50cd9ca8..f60e5fccf23 100644 --- a/src/v3/reactivity/effectScope.ts +++ b/src/v3/reactivity/effectScope.ts @@ -16,9 +16,7 @@ export class EffectScope { * @internal */ cleanups: (() => void)[] = [] - /** - * only assigned by undetached scope * @internal */ parent: EffectScope | undefined @@ -38,9 +36,9 @@ export class EffectScope { */ private index: number | undefined - constructor(detached = false) { + constructor(public detached = false) { + this.parent = activeEffectScope if (!detached && activeEffectScope) { - this.parent = activeEffectScope this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push( this @@ -93,7 +91,7 @@ export class EffectScope { } } // nested scope, dereference from parent to avoid memory leaks - if (this.parent && !fromParent) { + if (!this.detached && this.parent && !fromParent) { // optimized O(1) removal const last = this.parent.scopes!.pop() if (last && last !== this) { @@ -101,6 +99,7 @@ export class EffectScope { last.index = this.index! } } + this.parent = undefined this.active = false } } diff --git a/test/unit/features/v3/reactivity/effectScope.spec.ts b/test/unit/features/v3/reactivity/effectScope.spec.ts index b82127cdc76..6b837e67cdc 100644 --- a/test/unit/features/v3/reactivity/effectScope.spec.ts +++ b/test/unit/features/v3/reactivity/effectScope.spec.ts @@ -279,4 +279,15 @@ describe('reactivity/effectScope', () => { expect(getCurrentScope()).toBe(currentScope) }) }) + + it('calling .off() of a detached scope inside an active scope should not break currentScope', () => { + const parentScope = new EffectScope() + + parentScope.run(() => { + const childScope = new EffectScope(true) + childScope.on() + childScope.off() + expect(getCurrentScope()).toBe(parentScope) + }) + }) }) From df281b0e4c400be18df8bcf4e83df8b25a81e21b Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 14 Oct 2022 11:41:56 +0800 Subject: [PATCH 06/70] release: v2.7.13 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- packages/compiler-sfc/package.json | 2 +- packages/server-renderer/package.json | 2 +- packages/template-compiler/package.json | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d831fa047c..4c75474b8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [2.7.13](https://github.com/vuejs/vue/compare/v2.7.12...v2.7.13) (2022-10-14) + + +### Bug Fixes + +* **effectScope:** calling off() of a detached scope should not break currentScope ([800207c](https://github.com/vuejs/vue/commit/800207c473c7d6dfcdc883100a3d443fc5ad2e39)), closes [#12825](https://github.com/vuejs/vue/issues/12825) +* **types:** style attribute svg ([#12800](https://github.com/vuejs/vue/issues/12800)) ([8e26261](https://github.com/vuejs/vue/commit/8e262618cdc3251ca9630b17de4a000567ffb007)) +* **watch:** avoid traversing objects that are marked non-reactive ([#12806](https://github.com/vuejs/vue/issues/12806)) ([5960f05](https://github.com/vuejs/vue/commit/5960f05c69099c174062b6672c7a21d717a3bccf)) + + + ## [2.7.12](https://github.com/vuejs/vue/compare/v2.7.11...v2.7.12) (2022-10-12) diff --git a/package.json b/package.json index 2bb114433f4..33eff56cac0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue", - "version": "2.7.12", + "version": "2.7.13", "packageManager": "pnpm@7.1.0", "description": "Reactive, component-oriented view layer for modern web interfaces.", "main": "dist/vue.runtime.common.js", diff --git a/packages/compiler-sfc/package.json b/packages/compiler-sfc/package.json index e8ee4ecf382..5159c5cce04 100644 --- a/packages/compiler-sfc/package.json +++ b/packages/compiler-sfc/package.json @@ -1,6 +1,6 @@ { "name": "@vue/compiler-sfc", - "version": "2.7.12", + "version": "2.7.13", "description": "compiler-sfc for Vue 2", "main": "dist/compiler-sfc.js", "types": "dist/compiler-sfc.d.ts", diff --git a/packages/server-renderer/package.json b/packages/server-renderer/package.json index cfda873a1c8..194d6e9f765 100644 --- a/packages/server-renderer/package.json +++ b/packages/server-renderer/package.json @@ -1,6 +1,6 @@ { "name": "vue-server-renderer", - "version": "2.7.12", + "version": "2.7.13", "description": "server renderer for Vue 2.0", "main": "index.js", "types": "types/index.d.ts", diff --git a/packages/template-compiler/package.json b/packages/template-compiler/package.json index fd22b64d90b..79515498d03 100644 --- a/packages/template-compiler/package.json +++ b/packages/template-compiler/package.json @@ -1,6 +1,6 @@ { "name": "vue-template-compiler", - "version": "2.7.12", + "version": "2.7.13", "description": "template compiler for Vue 2.0", "main": "index.js", "unpkg": "browser.js", From 259c7060da72ea3040fc8c3de4ecb823ad5059f4 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 15 Oct 2022 17:39:04 +0800 Subject: [PATCH 07/70] chore: fix changelog rendering [ci skip] --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c75474b8d6..a2432812ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -888,7 +888,7 @@ In addition: - **compiler:** wrap scoped slots v-if conditions in parens ([#9119](https://github.com/vuejs/vue/issues/9119)) ([ef8524a](https://github.com/vuejs/vue/commit/ef8524ab7db8d64ac449ce74f5858aa9d91357ad)), closes [#9114](https://github.com/vuejs/vue/issues/9114) - **compiler:** maybeComponent should return true when "is" attribute exists ([#8114](https://github.com/vuejs/vue/issues/8114)) ([aef2a5f](https://github.com/vuejs/vue/commit/aef2a5f3dbd5e52ec9d5ce026d7b858539057186)), closes [#8101](https://github.com/vuejs/vue/issues/8101) - **compiler:** normalize potential functional component children in v-for ([#8558](https://github.com/vuejs/vue/issues/8558)) ([d483a49](https://github.com/vuejs/vue/commit/d483a49c86874b2e75863b661f81feecd46ae721)), closes [#8468](https://github.com/vuejs/vue/issues/8468) -- **compiler:** should keep newline after unary tags in
 ([#8965](https://github.com/vuejs/vue/issues/8965)) ([05001e6](https://github.com/vuejs/vue/commit/05001e695ebd0b0504d664197a4771463a0f5328)), closes [#8950](https://github.com/vuejs/vue/issues/8950)
+- **compiler:** should keep newline after unary tags in `
`  ([#8965](https://github.com/vuejs/vue/issues/8965)) ([05001e6](https://github.com/vuejs/vue/commit/05001e695ebd0b0504d664197a4771463a0f5328)), closes [#8950](https://github.com/vuejs/vue/issues/8950)
 - **compiler:** templates inside v-pre should be rendered to HTML ([#8146](https://github.com/vuejs/vue/issues/8146)) ([ecac831](https://github.com/vuejs/vue/commit/ecac831691d27cf7a10ec73a004d3fbad7623d1a)), closes [#8041](https://github.com/vuejs/vue/issues/8041)
 - **component:** clean up memory leak after loading async component completes (fix [#8740](https://github.com/vuejs/vue/issues/8740)) ([#8755](https://github.com/vuejs/vue/issues/8755)) ([2e472c5](https://github.com/vuejs/vue/commit/2e472c5e5e559a7a4083b4164ffe0c3911ce0651))
 - **core:** avoid mutating original children when cloning vnode ([097f622](https://github.com/vuejs/vue/commit/097f6229dffc34af452b106ad2a3b58845588807)), closes [#7975](https://github.com/vuejs/vue/issues/7975)
@@ -1176,7 +1176,7 @@ In addition:
 - properly mark slot rendered flag in production mode ([4fe1a95](https://github.com/vuejs/vue/commit/4fe1a95d2953ecf765e27677fa70ebadb176d4c3)), closes [#6997](https://github.com/vuejs/vue/issues/6997)
 - **slots:** properly handle nested named slot passing ([5a9da95](https://github.com/vuejs/vue/commit/5a9da95b8a865416f082952a48416ffc091e4078)), closes [#6996](https://github.com/vuejs/vue/issues/6996)
 - special case for static muted attribute in firefox ([f2e00f7](https://github.com/vuejs/vue/commit/f2e00f756fb540fb09ce3414289c652ce172d85c)), closes [#6887](https://github.com/vuejs/vue/issues/6887)
-- **ssr:** properly render ` initial state ([e1657fd](https://github.com/vuejs/vue/commit/e1657fd7ce49bff3c3ecad3c56ae527347505c34)), closes [#6986](https://github.com/vuejs/vue/issues/6986)
 - **ssr:** properly render textarea value ([79c0d7b](https://github.com/vuejs/vue/commit/79c0d7bcfbcd1ac492e7ceb77f5024d09efdc6b3)), closes [#6986](https://github.com/vuejs/vue/issues/6986)
 - **ssr:** should not optimize root if conditions ([4ad9a56](https://github.com/vuejs/vue/commit/4ad9a56b229b156e633f3d575cd0e99ba5e474d9)), closes [#6907](https://github.com/vuejs/vue/issues/6907)
 - **types:** improve typing for better completion ([#6886](https://github.com/vuejs/vue/issues/6886)) ([98ea0a3](https://github.com/vuejs/vue/commit/98ea0a3b48e37719f278c10a8ee5fb94d7d5db4e))
@@ -1213,14 +1213,14 @@ In addition:
 - fallback to Promise in non-DOM environments ([6d1f4cb](https://github.com/vuejs/vue/commit/6d1f4cb89a156bf5f84942b1031354aa93916cb7))
 - fix scoped CSS for nested nodes in functional components ([4216588](https://github.com/vuejs/vue/commit/421658884f7ca786747abf9b89e00925fdfdfba8))
 - handle errors in errorHandler ([2b5c83a](https://github.com/vuejs/vue/commit/2b5c83af6d8b15510424af4877d58c261ea02e16)), closes [#6714](https://github.com/vuejs/vue/issues/6714)
-- perperly handle v-if on