Skip to content

Commit 32215c5

Browse files
authored
Merge branch 'main' into fix/vuejs#3716
2 parents 3974b5d + 2d56816 commit 32215c5

File tree

11 files changed

+471
-283
lines changed

11 files changed

+471
-283
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.4.25",
4-
"packageManager": "[email protected].5",
4+
"packageManager": "[email protected].6",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -72,15 +72,15 @@
7272
"@types/minimist": "^1.2.5",
7373
"@types/node": "^20.12.7",
7474
"@types/semver": "^7.5.8",
75-
"@vitest/coverage-istanbul": "^1.5.0",
75+
"@vitest/coverage-istanbul": "^1.5.2",
7676
"@vue/consolidate": "1.0.0",
7777
"conventional-changelog-cli": "^4.1.0",
7878
"enquirer": "^2.4.1",
7979
"esbuild": "^0.20.2",
8080
"esbuild-plugin-polyfill-node": "^0.3.0",
81-
"eslint": "^9.0.0",
81+
"eslint": "^9.1.1",
8282
"eslint-plugin-import-x": "^0.5.0",
83-
"eslint-plugin-vitest": "^0.5.3",
83+
"eslint-plugin-vitest": "^0.5.4",
8484
"estree-walker": "^2.0.2",
8585
"execa": "^8.0.1",
8686
"jsdom": "^24.0.0",
@@ -95,23 +95,23 @@
9595
"prettier": "^3.2.5",
9696
"pretty-bytes": "^6.1.1",
9797
"pug": "^3.0.2",
98-
"puppeteer": "~22.6.5",
98+
"puppeteer": "~22.7.1",
9999
"rimraf": "^5.0.5",
100-
"rollup": "^4.16.1",
100+
"rollup": "^4.17.1",
101101
"rollup-plugin-dts": "^6.1.0",
102102
"rollup-plugin-esbuild": "^6.1.1",
103103
"rollup-plugin-polyfill-node": "^0.13.0",
104104
"semver": "^7.6.0",
105-
"serve": "^14.2.1",
105+
"serve": "^14.2.3",
106106
"simple-git-hooks": "^2.11.1",
107-
"terser": "^5.30.3",
107+
"terser": "^5.30.4",
108108
"todomvc-app-css": "^2.4.3",
109109
"tslib": "^2.6.2",
110-
"tsx": "^4.7.2",
110+
"tsx": "^4.7.3",
111111
"typescript": "~5.4.5",
112-
"typescript-eslint": "^7.6.0",
112+
"typescript-eslint": "^7.7.1",
113113
"vite": "^5.2.10",
114-
"vitest": "^1.5.0"
114+
"vitest": "^1.5.2"
115115
},
116116
"pnpm": {
117117
"peerDependencyRules": {

packages/compiler-core/src/parser.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const tokenizer = new Tokenizer(stack, {
179179
const name = currentOpenTag!.tag
180180
currentOpenTag!.isSelfClosing = true
181181
endOpenTag(end)
182-
if (stack[0]?.tag === name) {
182+
if (stack[0] && stack[0].tag === name) {
183183
onCloseTag(stack.shift()!, end)
184184
}
185185
},
@@ -587,14 +587,14 @@ function endOpenTag(end: number) {
587587

588588
function onText(content: string, start: number, end: number) {
589589
if (__BROWSER__) {
590-
const tag = stack[0]?.tag
590+
const tag = stack[0] && stack[0].tag
591591
if (tag !== 'script' && tag !== 'style' && content.includes('&')) {
592592
content = currentOptions.decodeEntities!(content, false)
593593
}
594594
}
595595
const parent = stack[0] || currentRoot
596596
const lastNode = parent.children[parent.children.length - 1]
597-
if (lastNode?.type === NodeTypes.TEXT) {
597+
if (lastNode && lastNode.type === NodeTypes.TEXT) {
598598
// merge
599599
lastNode.content += content
600600
setLocEnd(lastNode.loc, end)
@@ -771,7 +771,8 @@ function isComponent({ tag, props }: ElementNode): boolean {
771771
tag === 'component' ||
772772
isUpperCase(tag.charCodeAt(0)) ||
773773
isCoreComponent(tag) ||
774-
currentOptions.isBuiltInComponent?.(tag) ||
774+
(currentOptions.isBuiltInComponent &&
775+
currentOptions.isBuiltInComponent(tag)) ||
775776
(currentOptions.isNativeTag && !currentOptions.isNativeTag(tag))
776777
) {
777778
return true
@@ -828,8 +829,8 @@ function condenseWhitespace(
828829
if (node.type === NodeTypes.TEXT) {
829830
if (!inPre) {
830831
if (isAllWhitespace(node.content)) {
831-
const prev = nodes[i - 1]?.type
832-
const next = nodes[i + 1]?.type
832+
const prev = nodes[i - 1] && nodes[i - 1].type
833+
const next = nodes[i + 1] && nodes[i + 1].type
833834
// Remove if:
834835
// - the whitespace is the first or last node, or:
835836
// - (condense mode) the whitespace is between two comments, or:
@@ -1063,7 +1064,7 @@ export function baseParse(input: string, options?: ParserOptions): RootNode {
10631064
currentOptions.ns === Namespaces.SVG ||
10641065
currentOptions.ns === Namespaces.MATH_ML
10651066

1066-
const delimiters = options?.delimiters
1067+
const delimiters = options && options.delimiters
10671068
if (delimiters) {
10681069
tokenizer.delimiterOpen = toCharCodes(delimiters[0])
10691070
tokenizer.delimiterClose = toCharCodes(delimiters[1])

packages/reactivity/src/effect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class ReactiveEffect<T = any> {
128128
if (this.active) {
129129
preCleanupEffect(this)
130130
postCleanupEffect(this)
131-
this.onStop?.()
131+
this.onStop && this.onStop()
132132
this.active = false
133133
}
134134
}

packages/reactivity/src/reactiveEffect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ export function trigger(
146146
}
147147

148148
export function getDepFromReactive(object: any, key: string | number | symbol) {
149-
return targetMap.get(object)?.get(key)
149+
const depsMap = targetMap.get(object)
150+
return depsMap && depsMap.get(key)
150151
}

packages/runtime-core/__tests__/components/BaseTransition.spec.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
h,
88
nextTick,
99
nodeOps,
10-
onUnmounted,
1110
ref,
1211
render,
1312
serialize,
@@ -769,42 +768,6 @@ describe('BaseTransition', () => {
769768
test('w/ KeepAlive', async () => {
770769
await runTestWithKeepAlive(testOutIn)
771770
})
772-
773-
test('w/ KeepAlive + unmount innerChild', async () => {
774-
const unmountSpy = vi.fn()
775-
const includeRef = ref(['TrueBranch'])
776-
const trueComp = {
777-
name: 'TrueBranch',
778-
setup() {
779-
onUnmounted(unmountSpy)
780-
const count = ref(0)
781-
return () => h('div', count.value)
782-
},
783-
}
784-
785-
const toggle = ref(true)
786-
const { props } = mockProps({ mode: 'out-in' }, true /*withKeepAlive*/)
787-
const root = nodeOps.createElement('div')
788-
const App = {
789-
render() {
790-
return h(BaseTransition, props, () => {
791-
return h(
792-
KeepAlive,
793-
{ include: includeRef.value },
794-
toggle.value ? h(trueComp) : h('div'),
795-
)
796-
})
797-
},
798-
}
799-
render(h(App), root)
800-
801-
// trigger toggle
802-
toggle.value = false
803-
includeRef.value = []
804-
805-
await nextTick()
806-
expect(unmountSpy).toHaveBeenCalledTimes(1)
807-
})
808771
})
809772

810773
// #6835

packages/runtime-core/__tests__/hmr.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ describe('hot module replacement', () => {
356356
triggerEvent(root.children[1] as TestElement, 'click')
357357
await nextTick()
358358
await new Promise(r => setTimeout(r, 0))
359-
expect(serializeInner(root)).toBe(`<button></button><!---->`)
359+
expect(serializeInner(root)).toBe(`<button></button><!--v-if-->`)
360360
expect(unmountSpy).toHaveBeenCalledTimes(1)
361361
expect(mountSpy).toHaveBeenCalledTimes(1)
362362
expect(activeSpy).toHaveBeenCalledTimes(1)

packages/runtime-core/src/apiWatch.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -466,39 +466,32 @@ export function createPathGetter(ctx: any, path: string) {
466466

467467
export function traverse(
468468
value: unknown,
469-
depth?: number,
470-
currentDepth = 0,
469+
depth = Infinity,
471470
seen?: Set<unknown>,
472471
) {
473-
if (!isObject(value) || (value as any)[ReactiveFlags.SKIP]) {
472+
if (depth <= 0 || !isObject(value) || (value as any)[ReactiveFlags.SKIP]) {
474473
return value
475474
}
476475

477-
if (depth && depth > 0) {
478-
if (currentDepth >= depth) {
479-
return value
480-
}
481-
currentDepth++
482-
}
483-
484476
seen = seen || new Set()
485477
if (seen.has(value)) {
486478
return value
487479
}
488480
seen.add(value)
481+
depth--
489482
if (isRef(value)) {
490-
traverse(value.value, depth, currentDepth, seen)
483+
traverse(value.value, depth, seen)
491484
} else if (isArray(value)) {
492485
for (let i = 0; i < value.length; i++) {
493-
traverse(value[i], depth, currentDepth, seen)
486+
traverse(value[i], depth, seen)
494487
}
495488
} else if (isSet(value) || isMap(value)) {
496489
value.forEach((v: any) => {
497-
traverse(v, depth, currentDepth, seen)
490+
traverse(v, depth, seen)
498491
})
499492
} else if (isPlainObject(value)) {
500493
for (const key in value) {
501-
traverse(value[key], depth, currentDepth, seen)
494+
traverse(value[key], depth, seen)
502495
}
503496
}
504497
return value

packages/runtime-core/src/components/BaseTransition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const BaseTransitionImpl: ComponentOptions = {
224224
// update old tree's hooks in case of dynamic transition
225225
setTransitionHooks(oldInnerChild, leavingHooks)
226226
// switching between different views
227-
if (mode === 'out-in') {
227+
if (mode === 'out-in' && innerChild.type !== Comment) {
228228
state.isLeaving = true
229229
// return placeholder node and queue update when leave finishes
230230
leavingHooks.afterLeave = () => {

packages/runtime-core/src/components/KeepAlive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const KeepAliveImpl: ComponentOptions = {
254254
pendingCacheKey = null
255255

256256
if (!slots.default) {
257-
return (current = null)
257+
return null
258258
}
259259

260260
const children = slots.default()

packages/runtime-core/src/components/Suspense.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function createSuspenseBoundary(
479479
let parentSuspenseId: number | undefined
480480
const isSuspensible = isVNodeSuspensible(vnode)
481481
if (isSuspensible) {
482-
if (parentSuspense?.pendingBranch) {
482+
if (parentSuspense && parentSuspense.pendingBranch) {
483483
parentSuspenseId = parentSuspense.pendingId
484484
parentSuspense.deps++
485485
}
@@ -898,5 +898,6 @@ function setActiveBranch(suspense: SuspenseBoundary, branch: VNode) {
898898
}
899899

900900
function isVNodeSuspensible(vnode: VNode) {
901-
return vnode.props?.suspensible != null && vnode.props.suspensible !== false
901+
const suspensible = vnode.props && vnode.props.suspensible
902+
return suspensible != null && suspensible !== false
902903
}

0 commit comments

Comments
 (0)