Skip to content

Commit

Permalink
Merge pull request #142 from vuejs/main
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Tomxuetao committed Mar 26, 2024
2 parents 5a39678 + 01172fd commit 8c77ecf
Show file tree
Hide file tree
Showing 16 changed files with 554 additions and 493 deletions.
7 changes: 7 additions & 0 deletions FUNDING.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"drips": {
"ethereum": {
"ownedBy": "0x5393BdeA2a020769256d9f337B0fc81a2F64850A"
}
}
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"version": "3.4.21",
"packageManager": "pnpm@8.15.4",
"packageManager": "pnpm@8.15.5",
"type": "module",
"scripts": {
"dev": "node scripts/dev.js",
Expand Down Expand Up @@ -59,9 +59,9 @@
"node": ">=18.12.0"
},
"devDependencies": {
"@babel/parser": "^7.24.0",
"@babel/parser": "^7.24.1",
"@babel/types": "^7.24.0",
"@codspeed/vitest-plugin": "^2.3.1",
"@codspeed/vitest-plugin": "^3.1.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
Expand All @@ -70,15 +70,15 @@
"@rollup/plugin-terser": "^0.4.4",
"@types/hash-sum": "^1.0.2",
"@types/minimist": "^1.2.5",
"@types/node": "^20.11.25",
"@types/node": "^20.11.30",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@vitest/coverage-istanbul": "^1.3.1",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitest/coverage-istanbul": "^1.4.0",
"@vue/consolidate": "1.0.0",
"conventional-changelog-cli": "^4.1.0",
"enquirer": "^2.4.1",
"esbuild": "^0.20.1",
"esbuild": "^0.20.2",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^8.57.0",
"eslint-define-config": "^2.1.0",
Expand All @@ -98,21 +98,21 @@
"prettier": "^3.2.5",
"pretty-bytes": "^6.1.1",
"pug": "^3.0.2",
"puppeteer": "~22.4.1",
"puppeteer": "~22.6.0",
"rimraf": "^5.0.5",
"rollup": "^4.12.1",
"rollup": "^4.13.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"semver": "^7.6.0",
"serve": "^14.2.1",
"simple-git-hooks": "^2.10.0",
"terser": "^5.29.1",
"simple-git-hooks": "^2.11.0",
"terser": "^5.29.2",
"todomvc-app-css": "^2.4.3",
"tslib": "^2.6.2",
"tsx": "^4.7.1",
"typescript": "^5.2.2",
"vite": "^5.1.5",
"vitest": "^1.3.1"
"vite": "^5.2.6",
"vitest": "^1.4.0"
}
}
4 changes: 2 additions & 2 deletions packages/compiler-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
"dependencies": {
"@babel/parser": "^7.24.0",
"@babel/parser": "^7.24.1",
"@vue/shared": "workspace:*",
"entities": "^4.5.0",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
"source-map-js": "^1.2.0"
},
"devDependencies": {
"@babel/types": "^7.24.0"
Expand Down
39 changes: 39 additions & 0 deletions packages/compiler-sfc/__tests__/compileStyle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,45 @@ describe('SFC scoped CSS', () => {
`)
})

// #10511
test(':is() and :where() in compound selectors', () => {
expect(
compileScoped(`.div { color: red; } .div:where(:hover) { color: blue; }`),
).toMatchInlineSnapshot(`
".div[data-v-test] { color: red;
}
.div[data-v-test]:where(:hover) { color: blue;
}"`)

expect(
compileScoped(`.div { color: red; } .div:is(:hover) { color: blue; }`),
).toMatchInlineSnapshot(`
".div[data-v-test] { color: red;
}
.div[data-v-test]:is(:hover) { color: blue;
}"`)

expect(
compileScoped(
`.div { color: red; } .div:where(.foo:hover) { color: blue; }`,
),
).toMatchInlineSnapshot(`
".div[data-v-test] { color: red;
}
.div[data-v-test]:where(.foo:hover) { color: blue;
}"`)

expect(
compileScoped(
`.div { color: red; } .div:is(.foo:hover) { color: blue; }`,
),
).toMatchInlineSnapshot(`
".div[data-v-test] { color: red;
}
.div[data-v-test]:is(.foo:hover) { color: blue;
}"`)
})

test('media query', () => {
expect(compileScoped(`@media print { .foo { color: red }}`))
.toMatchInlineSnapshot(`
Expand Down
10 changes: 5 additions & 5 deletions packages/compiler-sfc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
"dependencies": {
"@babel/parser": "^7.24.0",
"@babel/parser": "^7.24.1",
"@vue/compiler-core": "workspace:*",
"@vue/compiler-dom": "workspace:*",
"@vue/compiler-ssr": "workspace:*",
"@vue/shared": "workspace:*",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.8",
"postcss": "^8.4.35",
"source-map-js": "^1.0.2"
"postcss": "^8.4.38",
"source-map-js": "^1.2.0"
},
"devDependencies": {
"@babel/types": "^7.24.0",
Expand All @@ -60,8 +60,8 @@
"merge-source-map": "^1.1.0",
"minimatch": "^9.0.3",
"postcss-modules": "^6.0.0",
"postcss-selector-parser": "^6.0.15",
"postcss-selector-parser": "^6.0.16",
"pug": "^3.0.2",
"sass": "^1.71.1"
"sass": "^1.72.0"
}
}
4 changes: 3 additions & 1 deletion packages/compiler-sfc/src/style/pluginScoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ function rewriteSelector(

if (
(n.type !== 'pseudo' && n.type !== 'combinator') ||
(n.type === 'pseudo' && (n.value === ':is' || n.value === ':where'))
(n.type === 'pseudo' &&
(n.value === ':is' || n.value === ':where') &&
!node)
) {
node = n
}
Expand Down
43 changes: 22 additions & 21 deletions packages/reactivity/__tests__/effectScope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EffectScope,
computed,
effect,
effectScope,
getCurrentScope,
onScopeDispose,
reactive,
Expand All @@ -13,29 +14,29 @@ import {
describe('reactivity/effect/scope', () => {
it('should run', () => {
const fnSpy = vi.fn(() => {})
new EffectScope().run(fnSpy)
effectScope().run(fnSpy)
expect(fnSpy).toHaveBeenCalledTimes(1)
})

it('should accept zero argument', () => {
const scope = new EffectScope()
const scope = effectScope()
expect(scope.effects.length).toBe(0)
})

it('should return run value', () => {
expect(new EffectScope().run(() => 1)).toBe(1)
expect(effectScope().run(() => 1)).toBe(1)
})

it('should work w/ active property', () => {
const scope = new EffectScope()
const scope = effectScope()
scope.run(() => 1)
expect(scope.active).toBe(true)
scope.stop()
expect(scope.active).toBe(false)
})

it('should collect the effects', () => {
const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
let dummy
const counter = reactive({ num: 0 })
Expand All @@ -53,7 +54,7 @@ describe('reactivity/effect/scope', () => {
let dummy, doubled
const counter = reactive({ num: 0 })

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
effect(() => (dummy = counter.num))
effect(() => (doubled = counter.num * 2))
Expand All @@ -77,11 +78,11 @@ describe('reactivity/effect/scope', () => {
let dummy, doubled
const counter = reactive({ num: 0 })

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
effect(() => (dummy = counter.num))
// nested scope
new EffectScope().run(() => {
effectScope().run(() => {
effect(() => (doubled = counter.num * 2))
})
})
Expand All @@ -107,11 +108,11 @@ describe('reactivity/effect/scope', () => {
let dummy, doubled
const counter = reactive({ num: 0 })

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
effect(() => (dummy = counter.num))
// nested scope
new EffectScope(true).run(() => {
effectScope(true).run(() => {
effect(() => (doubled = counter.num * 2))
})
})
Expand All @@ -136,7 +137,7 @@ describe('reactivity/effect/scope', () => {
let dummy, doubled
const counter = reactive({ num: 0 })

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
effect(() => (dummy = counter.num))
})
Expand All @@ -160,7 +161,7 @@ describe('reactivity/effect/scope', () => {
let dummy, doubled
const counter = reactive({ num: 0 })

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
effect(() => (dummy = counter.num))
})
Expand All @@ -185,7 +186,7 @@ describe('reactivity/effect/scope', () => {
it('should fire onScopeDispose hook', () => {
let dummy = 0

const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
onScopeDispose(() => (dummy += 1))
onScopeDispose(() => (dummy += 2))
Expand All @@ -203,7 +204,7 @@ describe('reactivity/effect/scope', () => {

it('should warn onScopeDispose() is called when there is no active effect scope', () => {
const spy = vi.fn()
const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
onScopeDispose(spy)
})
Expand All @@ -221,8 +222,8 @@ describe('reactivity/effect/scope', () => {
})

it('should dereference child scope from parent scope after stopping child scope (no memleaks)', () => {
const parent = new EffectScope()
const child = parent.run(() => new EffectScope())!
const parent = effectScope()
const child = parent.run(() => effectScope())!
expect(parent.scopes!.includes(child)).toBe(true)
child.stop()
expect(parent.scopes!.includes(child)).toBe(false)
Expand All @@ -236,7 +237,7 @@ describe('reactivity/effect/scope', () => {
const watchEffectSpy = vi.fn()

let c: ComputedRef
const scope = new EffectScope()
const scope = effectScope()
scope.run(() => {
c = computed(() => {
computedSpy()
Expand Down Expand Up @@ -274,23 +275,23 @@ describe('reactivity/effect/scope', () => {
})

it('getCurrentScope() stays valid when running a detached nested EffectScope', () => {
const parentScope = new EffectScope()
const parentScope = effectScope()

parentScope.run(() => {
const currentScope = getCurrentScope()
expect(currentScope).toBeDefined()
const detachedScope = new EffectScope(true)
const detachedScope = effectScope(true)
detachedScope.run(() => {})

expect(getCurrentScope()).toBe(currentScope)
})
})

it('calling .off() of a detached scope inside an active scope should not break currentScope', () => {
const parentScope = new EffectScope()
const parentScope = effectScope()

parentScope.run(() => {
const childScope = new EffectScope(true)
const childScope = effectScope(true)
childScope.on()
childScope.off()
expect(getCurrentScope()).toBe(parentScope)
Expand Down
26 changes: 26 additions & 0 deletions packages/runtime-core/__tests__/errorHandling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,31 @@ describe('error handling', () => {
expect(handler).toHaveBeenCalledTimes(4)
})

// #9574
test('should pause tracking in error handler', async () => {
const error = new Error('error')
const x = ref(Math.random())

const handler = vi.fn(() => {
x.value
x.value = Math.random()
})

const app = createApp({
setup() {
return () => {
throw error
}
},
})

app.config.errorHandler = handler
app.mount(nodeOps.createElement('div'))

await nextTick()
expect(handler).toHaveBeenCalledWith(error, {}, 'render function')
expect(handler).toHaveBeenCalledTimes(1)
})

// native event handler handling should be tested in respective renderers
})
3 changes: 3 additions & 0 deletions packages/runtime-core/src/errorHandling.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pauseTracking, resetTracking } from '@vue/reactivity'
import type { VNode } from './vnode'
import type { ComponentInternalInstance } from './component'
import { popWarningContext, pushWarningContext, warn } from './warning'
Expand Down Expand Up @@ -127,12 +128,14 @@ export function handleError(
// app-level handling
const appErrorHandler = instance.appContext.config.errorHandler
if (appErrorHandler) {
pauseTracking()
callWithErrorHandling(
appErrorHandler,
null,
ErrorCodes.APP_ERROR_HANDLER,
[err, exposedInstance, errorInfo],
)
resetTracking()
return
}
}
Expand Down
Loading

0 comments on commit 8c77ecf

Please sign in to comment.