Skip to content

Commit

Permalink
Merge pull request #173 from vuejs/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Tomxuetao authored Feb 13, 2025
2 parents 57fef67 + d6a6ec1 commit 73bd4dd
Show file tree
Hide file tree
Showing 24 changed files with 1,184 additions and 1,191 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: Run prettier
run: pnpm run format

- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c
- uses: autofix-ci/action@551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef
4 changes: 2 additions & 2 deletions .github/workflows/size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: pnpm install

- name: Download Size Data
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v7
with:
name: size-data
run_id: ${{ github.event.workflow_run.id }}
Expand All @@ -56,7 +56,7 @@ jobs:
path: temp/size/base.txt

- name: Download Previous Size Data
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v7
with:
branch: ${{ steps.pr-base.outputs.content }}
workflow: size-data.yml
Expand Down
120 changes: 0 additions & 120 deletions changelogs/CHANGELOG-3.4.md

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.5.13",
"packageManager": "pnpm@9.13.2",
"packageManager": "pnpm@9.15.4",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -65,41 +65,41 @@
"@babel/parser": "catalog:",
"@babel/types": "catalog:",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "5.0.4",
"@swc/core": "^1.9.2",
"@swc/core": "^1.10.15",
"@types/hash-sum": "^1.0.2",
"@types/node": "^22.9.0",
"@types/node": "^22.12.0",
"@types/semver": "^7.5.8",
"@types/serve-handler": "^6.1.4",
"@vitest/coverage-v8": "^2.1.5",
"@vitest/coverage-v8": "^3.0.5",
"@vue/consolidate": "1.0.0",
"conventional-changelog-cli": "^5.0.0",
"enquirer": "^2.4.1",
"esbuild": "^0.24.0",
"esbuild": "^0.25.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^9.15.0",
"eslint-plugin-import-x": "^4.4.2",
"@vitest/eslint-plugin": "^1.1.10",
"eslint": "^9.18.0",
"eslint-plugin-import-x": "^4.6.1",
"@vitest/eslint-plugin": "^1.1.27",
"estree-walker": "catalog:",
"jsdom": "^25.0.1",
"lint-staged": "^15.2.10",
"jsdom": "^26.0.0",
"lint-staged": "^15.4.1",
"lodash": "^4.17.21",
"magic-string": "^0.30.12",
"magic-string": "^0.30.17",
"markdown-table": "^3.0.4",
"marked": "13.0.3",
"npm-run-all2": "^7.0.1",
"npm-run-all2": "^7.0.2",
"picocolors": "^1.1.1",
"prettier": "^3.3.3",
"prettier": "^3.4.2",
"pretty-bytes": "^6.1.1",
"pug": "^3.0.3",
"puppeteer": "~23.3.0",
"puppeteer": "~24.2.0",
"rimraf": "^6.0.1",
"rollup": "^4.27.2",
"rollup": "^4.34.6",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-esbuild": "^6.2.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"semver": "^7.6.3",
"serve": "^14.2.4",
Expand All @@ -108,9 +108,9 @@
"todomvc-app-css": "^2.4.3",
"tslib": "^2.8.1",
"typescript": "~5.6.2",
"typescript-eslint": "^8.14.0",
"typescript-eslint": "^8.20.0",
"vite": "catalog:",
"vitest": "^2.1.5"
"vitest": "^3.0.5"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
2 changes: 1 addition & 1 deletion packages-private/sfc-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"vite": "catalog:"
},
"dependencies": {
"@vue/repl": "^4.4.2",
"@vue/repl": "^4.4.3",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
"vue": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"vue": "^3.4.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.0",
"vite": "^5.4.11"
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.1.0"
}
}
2 changes: 1 addition & 1 deletion packages-private/template-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"enableNonBrowserBranches": true
},
"dependencies": {
"monaco-editor": "^0.52.0",
"monaco-editor": "^0.52.2",
"source-map-js": "^1.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/compiler-core/src/transforms/vBind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { camelize } from '@vue/shared'
import { CAMELIZE } from '../runtimeHelpers'
import { processExpression } from './transformExpression'

// v-bind without arg is handled directly in ./transformElements.ts due to it affecting
// v-bind without arg is handled directly in ./transformElement.ts due to its affecting
// codegen for the entire props object. This transform here is only for v-bind
// *with* args.
export const transformBind: DirectiveTransform = (dir, _node, context) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/transforms/vOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { hasScopeRef, isFnExpression, isMemberExpression } from '../utils'
import { TO_HANDLER_KEY } from '../runtimeHelpers'

export interface VOnDirectiveNode extends DirectiveNode {
// v-on without arg is handled directly in ./transformElements.ts due to it affecting
// v-on without arg is handled directly in ./transformElement.ts due to its affecting
// codegen for the entire props object. This transform here is only for v-on
// *with* args.
arg: ExpressionNode
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@vue/shared": "workspace:*",
"estree-walker": "catalog:",
"magic-string": "catalog:",
"postcss": "^8.4.49",
"postcss": "^8.5.1",
"source-map-js": "catalog:"
},
"devDependencies": {
Expand All @@ -58,10 +58,10 @@
"hash-sum": "^2.0.0",
"lru-cache": "10.1.0",
"merge-source-map": "^1.1.0",
"minimatch": "~9.0.5",
"minimatch": "~10.0.1",
"postcss-modules": "^6.0.1",
"postcss-selector-parser": "^7.0.0",
"pug": "^3.0.3",
"sass": "^1.81.0"
"sass": "^1.83.4"
}
}
8 changes: 0 additions & 8 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ export function compileScript(
const scriptLang = script && script.lang
const scriptSetupLang = scriptSetup && scriptSetup.lang

let refBindings: string[] | undefined

if (!scriptSetup) {
if (!script) {
throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`)
Expand Down Expand Up @@ -740,12 +738,6 @@ export function compileScript(
for (const key in setupBindings) {
ctx.bindingMetadata[key] = setupBindings[key]
}
// known ref bindings
if (refBindings) {
for (const key of refBindings) {
ctx.bindingMetadata[key] = BindingTypes.SETUP_REF
}
}

// 7. inject `useCssVars` calls
if (
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/rewriteDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function rewriteDefaultAST(
ast.forEach(node => {
if (node.type === 'ExportDefaultDeclaration') {
if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
let start: number =
const start: number =
node.declaration.decorators && node.declaration.decorators.length > 0
? node.declaration.decorators[
node.declaration.decorators.length - 1
Expand Down
15 changes: 13 additions & 2 deletions packages/reactivity/src/effectScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export class EffectScope {
* @internal
*/
private _active = true
/**
* @internal track `on` calls, allow `on` call multiple times
*/
private _on = 0
/**
* @internal
*/
Expand Down Expand Up @@ -99,20 +103,27 @@ export class EffectScope {
}
}

prevScope: EffectScope | undefined
/**
* This should only be called on non-detached scopes
* @internal
*/
on(): void {
activeEffectScope = this
if (++this._on === 1) {
this.prevScope = activeEffectScope
activeEffectScope = this
}
}

/**
* This should only be called on non-detached scopes
* @internal
*/
off(): void {
activeEffectScope = this.parent
if (this._on > 0 && --this._on === 0) {
activeEffectScope = this.prevScope
this.prevScope = undefined
}
}

stop(fromParent?: boolean): void {
Expand Down
28 changes: 28 additions & 0 deletions packages/runtime-core/__tests__/apiWatch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
TrackOpTypes,
TriggerOpTypes,
effectScope,
onScopeDispose,
shallowReactive,
shallowRef,
toRef,
Expand Down Expand Up @@ -1982,4 +1983,31 @@ describe('api: watch', () => {
expect(spy1).toHaveBeenCalled()
expect(spy2).toHaveBeenCalled()
})

// #12631
test('this.$watch w/ onScopeDispose', () => {
const onCleanup = vi.fn()
const toggle = ref(true)

const Comp = defineComponent({
render() {},
created(this: any) {
this.$watch(
() => 1,
function () {},
)
onScopeDispose(onCleanup)
},
})

const App = defineComponent({
render() {
return toggle.value ? h(Comp) : null
},
})

const root = nodeOps.createElement('div')
createApp(App).mount(root)
expect(onCleanup).toBeCalledTimes(0)
})
})
5 changes: 5 additions & 0 deletions packages/runtime-core/src/components/KeepAlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ const KeepAliveImpl: ComponentOptions = {
// Update components tree
devtoolsComponentAdded(instance)
}

// for e2e test
if (__DEV__ && __BROWSER__) {
;(instance as any).__keepAliveStorageContainer = storageContainer
}
}

function unmount(vnode: VNode) {
Expand Down
8 changes: 7 additions & 1 deletion packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,13 @@ function baseCreateRenderer(
queuePostRenderEffect(() => transition!.enter(el!), parentSuspense)
} else {
const { leave, delayLeave, afterLeave } = transition!
const remove = () => hostInsert(el!, container, anchor)
const remove = () => {
if (vnode.ctx!.isUnmounted) {
hostRemove(el!)
} else {
hostInsert(el!, container, anchor)
}
}
const performLeave = () => {
leave(el!, () => {
remove()
Expand Down
69 changes: 69 additions & 0 deletions packages/vue/__tests__/e2e/Transition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ElementHandle } from 'puppeteer'
import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
import path from 'node:path'
import { Transition, createApp, h, nextTick, ref } from 'vue'
Expand Down Expand Up @@ -1653,6 +1654,74 @@ describe('e2e: Transition', () => {
},
E2E_TIMEOUT,
)

// #12860
test(
'unmount children',
async () => {
const unmountSpy = vi.fn()
let storageContainer: ElementHandle<HTMLDivElement>
const setStorageContainer = (container: any) =>
(storageContainer = container)
await page().exposeFunction('unmountSpy', unmountSpy)
await page().exposeFunction('setStorageContainer', setStorageContainer)
await page().evaluate(() => {
const { unmountSpy, setStorageContainer } = window as any
const { createApp, ref, h, onUnmounted, getCurrentInstance } = (
window as any
).Vue
createApp({
template: `
<div id="container">
<transition>
<KeepAlive :include="includeRef">
<TrueBranch v-if="toggle"></TrueBranch>
</KeepAlive>
</transition>
</div>
<button id="toggleBtn" @click="click">button</button>
`,
components: {
TrueBranch: {
name: 'TrueBranch',
setup() {
const instance = getCurrentInstance()
onUnmounted(() => {
unmountSpy()
setStorageContainer(instance.__keepAliveStorageContainer)
})
const count = ref(0)
return () => h('div', count.value)
},
},
},
setup: () => {
const includeRef = ref(['TrueBranch'])
const toggle = ref(true)
const click = () => {
toggle.value = !toggle.value
if (toggle.value) {
includeRef.value = ['TrueBranch']
} else {
includeRef.value = []
}
}
return { toggle, click, unmountSpy, includeRef }
},
}).mount('#app')
})

await transitionFinish()
expect(await html('#container')).toBe('<div>0</div>')

await click('#toggleBtn')
await transitionFinish()
expect(await html('#container')).toBe('<!--v-if-->')
expect(unmountSpy).toBeCalledTimes(1)
expect(await storageContainer!.evaluate(x => x.innerHTML)).toBe(``)
},
E2E_TIMEOUT,
)
})

describe('transition with Suspense', () => {
Expand Down
Loading

0 comments on commit 73bd4dd

Please sign in to comment.