Merge remote-tracking branch 'upstream/main'

This commit is contained in:
三咲智子 Kevin Deng 2024-02-14 14:46:29 +08:00
commit 7fd7742639
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
23 changed files with 142 additions and 81 deletions

View File

@ -46,5 +46,9 @@
// ESM only
'estree-walker',
// pinned
// https://github.com/vuejs/core/issues/10300#issuecomment-1940855364
'lru-cache',
],
}

View File

@ -1,3 +1,26 @@
## [3.4.19](https://github.com/vuejs/core/compare/v3.4.18...v3.4.19) (2024-02-13)
### Bug Fixes
* **deps:** pin lru-cache to avoid hashing error ([b8be990](https://github.com/vuejs/core/commit/b8be99018ceae92d1732dfb414df12b36b90b31f)), closes [#10300](https://github.com/vuejs/core/issues/10300)
* **hydration:** fix css vars hydration mismatch false positive on non-root nodes ([995d2fd](https://github.com/vuejs/core/commit/995d2fdcca485c24849c99f498c1edc163722e04)), closes [#10317](https://github.com/vuejs/core/issues/10317) [#10325](https://github.com/vuejs/core/issues/10325)
* **runtime-dom:** should not trigger transition when v-show value is falsy ([#10311](https://github.com/vuejs/core/issues/10311)) ([e509639](https://github.com/vuejs/core/commit/e50963903d93a7f24003b6e2c03647fdf7454b1e))
### Features
> Note: this warning is categorized as a feature but released in a patch because it does not affect public APIs.
* **dx:** warn users when computed is self-triggering ([#10299](https://github.com/vuejs/core/issues/10299)) ([f7ba97f](https://github.com/vuejs/core/commit/f7ba97f9754a9882c1f6b1c07ca1a4040479dd13))
### Performance Improvements
* **runtime:** improve `getType()` GC and speed ([#10327](https://github.com/vuejs/core/issues/10327)) ([603a1e1](https://github.com/vuejs/core/commit/603a1e1f5ad587c077f0d974c1bbe856be22ebe9))
## [3.4.18](https://github.com/vuejs/core/compare/v3.4.17...v3.4.18) (2024-02-09)

View File

@ -94,7 +94,7 @@
"markdown-table": "^3.0.3",
"marked": "^11.2.0",
"minimist": "^1.2.8",
"npm-run-all2": "^5.0.2",
"npm-run-all2": "^6.1.2",
"picocolors": "^1.0.0",
"prettier": "^3.2.2",
"pretty-bytes": "^6.1.1",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/compiler-core",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/compiler-dom",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/compiler-sfc",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
@ -55,9 +55,9 @@
},
"devDependencies": {
"@babel/types": "^7.23.9",
"@vue/consolidate": "^0.17.3",
"@vue/consolidate": "^1.0.0",
"hash-sum": "^2.0.0",
"lru-cache": "^10.2.0",
"lru-cache": "10.1.0",
"merge-source-map": "^1.1.0",
"minimatch": "^9.0.3",
"postcss-modules": "^6.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/compiler-ssr",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/compiler-ssr",
"main": "dist/compiler-ssr.cjs.js",
"types": "dist/compiler-ssr.d.ts",

View File

@ -14,6 +14,7 @@ import {
toRaw,
} from '../src'
import { DirtyLevels } from '../src/constants'
import { COMPUTED_SIDE_EFFECT_WARN } from '../src/computed'
describe('reactivity/computed', () => {
it('should return updated value', () => {
@ -488,6 +489,7 @@ describe('reactivity/computed', () => {
expect(c3.effect._dirtyLevel).toBe(
DirtyLevels.MaybeDirty_ComputedSideEffect,
)
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
it('should work when chained(ref+computed)', () => {
@ -502,6 +504,7 @@ describe('reactivity/computed', () => {
expect(c2.value).toBe('0foo')
expect(c2.effect._dirtyLevel).toBe(DirtyLevels.Dirty)
expect(c2.value).toBe('1foo')
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
it('should trigger effect even computed already dirty', () => {
@ -524,6 +527,7 @@ describe('reactivity/computed', () => {
expect(c2.effect._dirtyLevel).toBe(DirtyLevels.Dirty)
v.value = 2
expect(fnSpy).toBeCalledTimes(2)
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
// #10185
@ -567,6 +571,7 @@ describe('reactivity/computed', () => {
expect(c3.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty)
expect(c3.value).toBe('yes')
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
it('should be not dirty after deps mutate (mutate deps in computed)', async () => {
@ -588,6 +593,7 @@ describe('reactivity/computed', () => {
await nextTick()
await nextTick()
expect(serializeInner(root)).toBe(`2`)
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
it('should not trigger effect scheduler by recurse computed effect', async () => {
@ -610,5 +616,6 @@ describe('reactivity/computed', () => {
v.value += ' World'
await nextTick()
expect(serializeInner(root)).toBe('Hello World World World World')
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})
})

View File

@ -1,6 +1,6 @@
{
"name": "@vue/reactivity",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/reactivity",
"main": "index.js",
"module": "dist/reactivity.esm-bundler.js",

View File

@ -4,6 +4,7 @@ import { NOOP, hasChanged, isFunction } from '@vue/shared'
import { toRaw } from './reactive'
import type { Dep } from './dep'
import { DirtyLevels, ReactiveFlags } from './constants'
import { warn } from './warning'
declare const ComputedRefSymbol: unique symbol
@ -24,6 +25,12 @@ export interface WritableComputedOptions<T> {
set: ComputedSetter<T>
}
export const COMPUTED_SIDE_EFFECT_WARN =
`Computed is still dirty after getter evaluation,` +
` likely because a computed is mutating its own dependency in its getter.` +
` State mutations in computed getters should be avoided. ` +
` Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`
export class ComputedRefImpl<T> {
public dep?: Dep = undefined
@ -67,6 +74,7 @@ export class ComputedRefImpl<T> {
}
trackRefValue(self)
if (self.effect._dirtyLevel >= DirtyLevels.MaybeDirty_ComputedSideEffect) {
__DEV__ && warn(COMPUTED_SIDE_EFFECT_WARN)
triggerRefValue(self, DirtyLevels.MaybeDirty_ComputedSideEffect)
}
return self._value
@ -141,7 +149,7 @@ export function computed<T>(
getter = getterOrOptions
setter = __DEV__
? () => {
console.warn('Write operation failed: computed value is readonly')
warn('Write operation failed: computed value is readonly')
}
: NOOP
} else {

View File

@ -1554,5 +1554,22 @@ describe('SSR hydration', () => {
app.mount(container)
expect(`Hydration style mismatch`).not.toHaveBeenWarned()
})
// #10317 - test case from #10325
test('css vars should only be added to expected on component root dom', () => {
const container = document.createElement('div')
container.innerHTML = `<div style="--foo:red;"><div style="color:var(--foo);" /></div>`
const app = createSSRApp({
setup() {
useCssVars(() => ({
foo: 'red',
}))
return () =>
h('div', null, [h('div', { style: { color: 'var(--foo)' } })])
},
})
app.mount(container)
expect(`Hydration style mismatch`).not.toHaveBeenWarned()
})
})
})

View File

@ -1,6 +1,6 @@
{
"name": "@vue/runtime-core",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/runtime-core",
"main": "index.js",
"module": "dist/runtime-core.esm-bundler.js",

View File

@ -597,8 +597,23 @@ function validatePropName(key: string) {
// use function string name to check type constructors
// so that it works across vms / iframes.
function getType(ctor: Prop<any>): string {
const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/)
return match ? match[2] : ctor === null ? 'null' : ''
// Early return for null to avoid unnecessary computations
if (ctor === null) {
return 'null'
}
// Avoid using regex for common cases by checking the type directly
if (typeof ctor === 'function') {
// Using name property to avoid converting function to string
return ctor.name || ''
} else if (typeof ctor === 'object') {
// Attempting to directly access constructor name if possible
const name = ctor.constructor && ctor.constructor.name
return name || ''
}
// Fallback for other types (though they're less likely to have meaningful names here)
return ''
}
function isSameType(a: Prop<any>, b: Prop<any>): boolean {

View File

@ -70,13 +70,11 @@ export function callWithErrorHandling(
type: ErrorTypes,
args?: unknown[],
) {
let res
try {
res = args ? fn(...args) : fn()
return args ? fn(...args) : fn()
} catch (err) {
handleError(err, instance, type)
}
return res
}
export function callWithAsyncErrorHandling(

View File

@ -753,9 +753,15 @@ function propHasMismatch(
}
}
const cssVars = instance?.getCssVars?.()
for (const key in cssVars) {
expectedMap.set(`--${key}`, String(cssVars[key]))
const root = instance?.subTree
if (
vnode === root ||
(root?.type === Fragment && (root.children as VNode[]).includes(vnode))
) {
const cssVars = instance?.getCssVars?.()
for (const key in cssVars) {
expectedMap.set(`--${key}`, String(cssVars[key]))
}
}
if (!isMapEqual(actualMap, expectedMap)) {

View File

@ -1,6 +1,6 @@
{
"name": "@vue/runtime-dom",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/runtime-dom",
"main": "index.js",
"module": "dist/runtime-dom.esm-bundler.js",

View File

@ -22,7 +22,11 @@ export const vShow: ObjectDirective<VShowElement> & { name?: 'show' } = {
}
},
updated(el, { value, oldValue }, { transition }) {
if (!value === !oldValue && el.style.display === el[vShowOldKey]) return
if (
!value === !oldValue &&
(el.style.display === el[vShowOldKey] || !value)
)
return
if (transition) {
if (value) {
transition.beforeEnter(el)

View File

@ -1,6 +1,6 @@
{
"name": "@vue/server-renderer",
"version": "3.4.18",
"version": "3.4.19",
"description": "@vue/server-renderer",
"main": "index.js",
"module": "dist/server-renderer.esm-bundler.js",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/shared",
"version": "3.4.18",
"version": "3.4.19",
"description": "internal utils shared across @vue packages",
"main": "index.js",
"module": "dist/shared.esm-bundler.js",

View File

@ -1,6 +1,6 @@
{
"name": "@vue/compat",
"version": "3.4.18",
"version": "3.4.19",
"description": "Vue 3 compatibility build for Vue 2",
"main": "index.js",
"module": "dist/vue.runtime.esm-bundler.js",

View File

@ -1,6 +1,6 @@
{
"name": "vue",
"version": "3.4.18",
"version": "3.4.19",
"description": "The progressive JavaScript framework for building modern web UI.",
"main": "index.js",
"module": "dist/vue.runtime.esm-bundler.js",

View File

@ -114,8 +114,8 @@ importers:
specifier: ^1.2.8
version: 1.2.8
npm-run-all2:
specifier: ^5.0.2
version: 5.0.2
specifier: ^6.1.2
version: 6.1.2
picocolors:
specifier: ^1.0.0
version: 1.0.0
@ -245,14 +245,14 @@ importers:
specifier: ^7.23.9
version: 7.23.9
'@vue/consolidate':
specifier: ^0.17.3
version: 0.17.3
specifier: ^1.0.0
version: 1.0.0
hash-sum:
specifier: ^2.0.0
version: 2.0.0
lru-cache:
specifier: ^10.2.0
version: 10.2.0
specifier: 10.1.0
version: 10.1.0
merge-source-map:
specifier: ^1.1.0
version: 1.1.0
@ -1896,6 +1896,11 @@ packages:
engines: {node: '>= 0.12.0'}
dev: true
/@vue/consolidate@1.0.0:
resolution: {integrity: sha512-oTyUE+QHIzLw2PpV14GD/c7EohDyP64xCniWTcqcEmTd699eFqTIwOmtDYjcO1j3QgdXoJEoWv1/cCdLrRoOfg==}
engines: {node: '>= 0.12.0'}
dev: true
/@vue/repl@4.0.0:
resolution: {integrity: sha512-/C4moGPnuc/t7JdBdEAOn/9MkdLH0KzY8zhZN33gfKY6E7ln0I2umsTjQAxvjTFuPS01oAOlATvaWz5cW8HLgQ==}
dev: false
@ -3647,15 +3652,11 @@ packages:
function-bind: 1.1.2
dev: true
/hosted-git-info@2.8.9:
resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==}
dev: true
/hosted-git-info@7.0.1:
resolution: {integrity: sha512-+K84LB1DYwMHoHSgaOY/Jfhw3ucPmSET5v98Ke/HdNSw4a0UktWzyW1mjhjpuxxTqOOsfWT/7iVshHmVZ4IpOA==}
engines: {node: ^16.14.0 || >=18.0.0}
dependencies:
lru-cache: 10.2.0
lru-cache: 10.1.0
dev: true
/html-encoding-sniffer@4.0.0:
@ -4248,8 +4249,8 @@ packages:
get-func-name: 2.0.2
dev: true
/lru-cache@10.2.0:
resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==}
/lru-cache@10.1.0:
resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==}
engines: {node: 14 || >=16.14}
dev: true
@ -4485,15 +4486,6 @@ packages:
resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==}
dev: true
/normalize-package-data@2.5.0:
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
dependencies:
hosted-git-info: 2.8.9
resolve: 1.22.8
semver: 5.7.2
validate-npm-package-license: 3.0.4
dev: true
/normalize-package-data@6.0.0:
resolution: {integrity: sha512-UL7ELRVxYBHBgYEtZCXjxuD5vPxnmvMGq0jp/dGPKKrN7tfsBh2IY7TlJ15WWwdjRWD3RJbnsygUurTK3xkPkg==}
engines: {node: ^16.14.0 || >=18.0.0}
@ -4509,17 +4501,22 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/npm-run-all2@5.0.2:
resolution: {integrity: sha512-S2G6FWZ3pNWAAKm2PFSOtEAG/N+XO/kz3+9l6V91IY+Y3XFSt7Lp7DV92KCgEboEW0hRTu0vFaMe4zXDZYaOyA==}
engines: {node: '>= 10'}
/npm-normalize-package-bin@3.0.1:
resolution: {integrity: sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dev: true
/npm-run-all2@6.1.2:
resolution: {integrity: sha512-WwwnS8Ft+RpXve6T2EIEVpFLSqN+ORHRvgNk3H9N62SZXjmzKoRhMFg3I17TK3oMaAEr+XFbRirWS2Fn3BCPSg==}
engines: {node: ^14.18.0 || >=16.0.0, npm: '>= 8'}
hasBin: true
dependencies:
ansi-styles: 5.2.0
ansi-styles: 6.2.1
cross-spawn: 7.0.3
memorystream: 0.3.1
minimatch: 3.1.2
pidtree: 0.5.0
read-pkg: 5.2.0
minimatch: 9.0.3
pidtree: 0.6.0
read-package-json-fast: 3.0.2
shell-quote: 1.8.1
dev: true
@ -4724,7 +4721,7 @@ packages:
resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==}
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
lru-cache: 10.2.0
lru-cache: 10.1.0
minipass: 7.0.4
dev: true
@ -4757,12 +4754,6 @@ packages:
engines: {node: '>=8.6'}
dev: true
/pidtree@0.5.0:
resolution: {integrity: sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA==}
engines: {node: '>=0.10'}
hasBin: true
dev: true
/pidtree@0.6.0:
resolution: {integrity: sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==}
engines: {node: '>=0.10'}
@ -5096,6 +5087,14 @@ packages:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: true
/read-package-json-fast@3.0.2:
resolution: {integrity: sha512-0J+Msgym3vrLOUB3hzQCuZHII0xkNGCtz/HJH9xZshwv9DbDwkw1KaE3gx/e2J5rpEY5rtOy6cyhKOPrkP7FZw==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
json-parse-even-better-errors: 3.0.0
npm-normalize-package-bin: 3.0.1
dev: true
/read-pkg-up@10.1.0:
resolution: {integrity: sha512-aNtBq4jR8NawpKJQldrQcSW9y/d+KWH4v24HWkHljOZ7H0av+YTGANBzRh9A5pw7v/bLVsLVPpOhJ7gHNVy8lA==}
engines: {node: '>=16'}
@ -5105,16 +5104,6 @@ packages:
type-fest: 4.5.0
dev: true
/read-pkg@5.2.0:
resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==}
engines: {node: '>=8'}
dependencies:
'@types/normalize-package-data': 2.4.3
normalize-package-data: 2.5.0
parse-json: 5.2.0
type-fest: 0.6.0
dev: true
/read-pkg@8.1.0:
resolution: {integrity: sha512-PORM8AgzXeskHO/WEv312k9U03B8K9JSiWF/8N9sUuFjBa+9SF2u6K7VClzXwDXab51jCd8Nd36CNM+zR97ScQ==}
engines: {node: '>=16'}
@ -5328,11 +5317,6 @@ packages:
xmlchars: 2.2.0
dev: true
/semver@5.7.2:
resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==}
hasBin: true
dev: true
/semver@6.3.1:
resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==}
hasBin: true
@ -5851,11 +5835,6 @@ packages:
engines: {node: '>=10'}
dev: true
/type-fest@0.6.0:
resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==}
engines: {node: '>=8'}
dev: true
/type-fest@2.19.0:
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
engines: {node: '>=12.20'}

View File

@ -264,7 +264,7 @@ async function main() {
if (!skipTests) {
step('\nRunning tests...')
if (!isDryRun) {
await run('pnpm', ['run', 'test'])
await run('pnpm', ['run', 'test', '--run'])
} else {
console.log(`Skipped (dry run)`)
}