Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.4.6
Choose a base ref
...
head repository: vuejs/core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.4.7
Choose a head ref
  • 9 commits
  • 27 files changed
  • 5 contributors

Commits on Jan 8, 2024

  1. Copy the full SHA
    7976f70 View commit details

Commits on Jan 9, 2024

  1. Copy the full SHA
    923d560 View commit details
  2. Copy the full SHA
    9c54dac View commit details
  3. Copy the full SHA
    64e9c96 View commit details
  4. Copy the full SHA
    03b5496 View commit details
  5. Copy the full SHA
    3135fcb View commit details
  6. revert: "dx(computed): warn incorrect use of getCurrentInstance insid…

    …e computed"
    
    This reverts commit 324e817.
    yyx990803 committed Jan 9, 2024
    2
    Copy the full SHA
    2fd3905 View commit details
  7. fix(types): fix functional component for h (#9991)

    - stricter children/slots type
    - fix emits/`EE` type argument of `FunctionalComponent`
    sxzz authored Jan 9, 2024
    Copy the full SHA
    438a74a View commit details
  8. release: v3.4.7

    yyx990803 committed Jan 9, 2024
    Copy the full SHA
    a3725a7 View commit details
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [3.4.7](https://github.com/vuejs/core/compare/v3.4.6...v3.4.7) (2024-01-09)


### Bug Fixes

* **parser:** skip compat mode check for SFC root `<template>` tags ([#10034](https://github.com/vuejs/core/issues/10034)) ([923d560](https://github.com/vuejs/core/commit/923d560d0b6713144671809b6dfeb1e2da503b1f))
* **types:** fix functional component for `h` ([#9991](https://github.com/vuejs/core/issues/9991)) ([438a74a](https://github.com/vuejs/core/commit/438a74aad840183286fbdb488178510f37218a73))


### Reverts

* "dx(computed): warn incorrect use of getCurrentInstance inside computed" ([2fd3905](https://github.com/vuejs/core/commit/2fd39057386644c8bfee426c60a51f2b07a79b09))



## [3.4.6](https://github.com/vuejs/core/compare/v3.4.5...v3.4.6) (2024-01-08)


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "3.4.6",
"version": "3.4.7",
"packageManager": "pnpm@8.14.0",
"type": "module",
"scripts": {
2 changes: 1 addition & 1 deletion packages/compiler-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
1 change: 1 addition & 0 deletions packages/compiler-core/src/parser.ts
Original file line number Diff line number Diff line change
@@ -692,6 +692,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
}

if (
!tokenizer.inSFCRoot &&
isCompatEnabled(
CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE,
currentOptions,
2 changes: 1 addition & 1 deletion packages/compiler-core/src/transform.ts
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ export function createTransformContext(
}
context.parent!.children.splice(removalIndex, 1)
},
onNodeRemoved: () => {},
onNodeRemoved: NOOP,
addIdentifiers(exp) {
// identifier tracking only happens in non-browser builds.
if (!__BROWSER__) {
2 changes: 1 addition & 1 deletion packages/compiler-dom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
2 changes: 1 addition & 1 deletion packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-sfc",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
2 changes: 1 addition & 1 deletion packages/compiler-ssr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/compiler-ssr",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/compiler-ssr",
"main": "dist/compiler-ssr.cjs.js",
"types": "dist/compiler-ssr.d.ts",
24 changes: 24 additions & 0 deletions packages/dts-test/h.test-d.ts
Original file line number Diff line number Diff line change
@@ -2,8 +2,10 @@ import {
type Component,
type DefineComponent,
Fragment,
type FunctionalComponent,
Suspense,
Teleport,
type VNode,
defineComponent,
h,
ref,
@@ -77,6 +79,19 @@ describe('h inference w/ Suspense', () => {
h(Suspense, { onResolve: 1 })
})

declare const fc: FunctionalComponent<
{
foo: string
bar?: number
onClick: (evt: MouseEvent) => void
},
['click'],
{
default: () => VNode
title: (scope: { id: number }) => VNode
}
>
declare const vnode: VNode
describe('h inference w/ functional component', () => {
const Func = (_props: { foo: string; bar?: number }) => ''
h(Func, { foo: 'hello' })
@@ -87,6 +102,15 @@ describe('h inference w/ functional component', () => {
h(Func, {})
// @ts-expect-error
h(Func, { bar: 123 })

h(
fc,
{ foo: 'hello', onClick: () => {} },
{
default: () => vnode,
title: ({ id }: { id: number }) => vnode,
},
)
})

describe('h support w/ plain object component', () => {
2 changes: 1 addition & 1 deletion packages/reactivity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/reactivity",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/reactivity",
"main": "index.js",
"module": "dist/reactivity.esm-bundler.js",
2 changes: 1 addition & 1 deletion packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
@@ -281,7 +281,7 @@ export function trackEffect(
}
}

const queueEffectSchedulers: (() => void)[] = []
const queueEffectSchedulers: EffectScheduler[] = []

export function triggerEffects(
dep: Dep,
44 changes: 0 additions & 44 deletions packages/runtime-core/__tests__/apiComputed.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/runtime-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/runtime-core",
"version": "3.4.6",
"version": "3.4.7",
"description": "@vue/runtime-core",
"main": "index.js",
"module": "dist/runtime-core.esm-bundler.js",
38 changes: 3 additions & 35 deletions packages/runtime-core/src/apiComputed.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
import {
type ComputedGetter,
type WritableComputedOptions,
computed as _computed,
} from '@vue/reactivity'
import { computed as _computed } from '@vue/reactivity'
import { isInSSRComponentSetup } from './component'
import { isFunction } from '@vue/shared'

/**
* For dev warning only.
* Context: https://github.com/vuejs/core/discussions/9974
*/
export let isInComputedGetter = false

function wrapComputedGetter(
getter: ComputedGetter<unknown>,
): ComputedGetter<unknown> {
return () => {
isInComputedGetter = true
try {
return getter()
} finally {
isInComputedGetter = false
}
}
}

export const computed: typeof _computed = (
getterOrOptions: ComputedGetter<unknown> | WritableComputedOptions<unknown>,
getterOrOptions: any,
debugOptions?: any,
) => {
if (__DEV__) {
if (isFunction(getterOrOptions)) {
getterOrOptions = wrapComputedGetter(getterOrOptions)
} else {
getterOrOptions.get = wrapComputedGetter(getterOrOptions.get)
}
}

// @ts-expect-error the 3rd argument is hidden from public types
// @ts-expect-error
return _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
}
5 changes: 2 additions & 3 deletions packages/runtime-core/src/apiLifecycle.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ import {
currentInstance,
isInSSRComponentSetup,
setCurrentInstance,
unsetCurrentInstance,
} from './component'
import type { ComponentPublicInstance } from './componentPublicInstance'
import { ErrorTypeStrings, callWithAsyncErrorHandling } from './errorHandling'
@@ -41,9 +40,9 @@ export function injectHook(
// Set currentInstance during hook invocation.
// This assumes the hook does not synchronously trigger other hooks, which
// can only be false when the user does something really funky.
setCurrentInstance(target)
const reset = setCurrentInstance(target)
const res = callWithAsyncErrorHandling(hook, target, type, args)
unsetCurrentInstance()
reset()
resetTracking()
return res
})
10 changes: 2 additions & 8 deletions packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ import {
currentInstance,
isInSSRComponentSetup,
setCurrentInstance,
unsetCurrentInstance,
} from './component'
import {
ErrorCodes,
@@ -448,14 +447,9 @@ export function instanceWatch(
cb = value.handler as Function
options = value
}
const cur = currentInstance
setCurrentInstance(this)
const reset = setCurrentInstance(this)
const res = doWatch(getter, cb.bind(publicThis), options)
if (cur) {
setCurrentInstance(cur)
} else {
unsetCurrentInstance()
}
reset()
return res
}

28 changes: 11 additions & 17 deletions packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
@@ -85,7 +85,6 @@ import {
} from './compat/compatConfig'
import type { SchedulerJob } from './scheduler'
import type { LifecycleHooks } from './enums'
import { isInComputedGetter } from './apiComputed'

export type Data = Record<string, unknown>

@@ -632,18 +631,8 @@ export function createComponentInstance(

export let currentInstance: ComponentInternalInstance | null = null

export const getCurrentInstance: () => ComponentInternalInstance | null =
() => {
if (__DEV__ && isInComputedGetter) {
warn(
`getCurrentInstance() called inside a computed getter. ` +
`This is incorrect usage as computed getters are not guaranteed ` +
`to be executed with an active component instance. If you are using ` +
`a composable inside a computed getter, move it ouside to the setup scope.`,
)
}
return currentInstance || currentRenderingInstance
}
export const getCurrentInstance: () => ComponentInternalInstance | null = () =>
currentInstance || currentRenderingInstance

let internalSetCurrentInstance: (
instance: ComponentInternalInstance | null,
@@ -696,8 +685,13 @@ if (__SSR__) {
}

export const setCurrentInstance = (instance: ComponentInternalInstance) => {
const prev = currentInstance
internalSetCurrentInstance(instance)
instance.scope.on()
return () => {
instance.scope.off()
internalSetCurrentInstance(prev)
}
}

export const unsetCurrentInstance = () => {
@@ -785,7 +779,7 @@ function setupStatefulComponent(
const setupContext = (instance.setupContext =
setup.length > 1 ? createSetupContext(instance) : null)

setCurrentInstance(instance)
const reset = setCurrentInstance(instance)
pauseTracking()
const setupResult = callWithErrorHandling(
setup,
@@ -797,7 +791,7 @@ function setupStatefulComponent(
],
)
resetTracking()
unsetCurrentInstance()
reset()

if (isPromise(setupResult)) {
setupResult.then(unsetCurrentInstance, unsetCurrentInstance)
@@ -972,13 +966,13 @@ export function finishComponentSetup(

// support for 2.x options
if (__FEATURE_OPTIONS_API__ && !(__COMPAT__ && skipOptions)) {
setCurrentInstance(instance)
const reset = setCurrentInstance(instance)
pauseTracking()
try {
applyOptions(instance)
} finally {
resetTracking()
unsetCurrentInstance()
reset()
}
}

5 changes: 2 additions & 3 deletions packages/runtime-core/src/componentProps.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ import {
type ConcreteComponent,
type Data,
setCurrentInstance,
unsetCurrentInstance,
} from './component'
import { isEmitListener } from './componentEmits'
import { InternalObjectKey } from './vnode'
@@ -470,15 +469,15 @@ function resolvePropValue(
if (key in propsDefaults) {
value = propsDefaults[key]
} else {
setCurrentInstance(instance)
const reset = setCurrentInstance(instance)
value = propsDefaults[key] = defaultValue.call(
__COMPAT__ &&
isCompatEnabled(DeprecationTypes.PROPS_DEFAULT_THIS, instance)
? createPropsDefaultThis(instance, props, key)
: null,
props,
)
unsetCurrentInstance()
reset()
}
} else {
value = defaultValue
Loading