Skip to content

Commit 01d82a7

Browse files
Merge branch 'main' into fix/types/shallowRef
2 parents 6c3b32e + 0a387df commit 01d82a7

File tree

14 files changed

+321
-286
lines changed

14 files changed

+321
-286
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
- run: pnpm install
7979

8080
- name: Run benchmarks
81-
uses: CodSpeedHQ/action@v1
81+
uses: CodSpeedHQ/action@v2
8282
with:
8383
run: pnpm vitest bench --run
8484
token: ${{ secrets.CODSPEED_TOKEN }}

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"version": "3.3.11",
4-
"packageManager": "pnpm@8.11.0",
4+
"packageManager": "pnpm@8.12.0",
55
"type": "module",
66
"scripts": {
77
"dev": "node scripts/dev.js",
@@ -69,31 +69,31 @@
6969
"@rollup/plugin-replace": "^5.0.4",
7070
"@rollup/plugin-terser": "^0.4.4",
7171
"@types/hash-sum": "^1.0.2",
72-
"@types/node": "^20.10.3",
73-
"@typescript-eslint/parser": "^6.13.0",
74-
"@vitest/coverage-istanbul": "^1.0.2",
72+
"@types/node": "^20.10.4",
73+
"@typescript-eslint/parser": "^6.13.2",
74+
"@vitest/coverage-istanbul": "^1.0.4",
7575
"@vue/consolidate": "0.17.3",
7676
"conventional-changelog-cli": "^4.1.0",
7777
"enquirer": "^2.4.1",
7878
"esbuild": "^0.19.5",
7979
"esbuild-plugin-polyfill-node": "^0.3.0",
80-
"eslint": "^8.54.0",
80+
"eslint": "^8.55.0",
8181
"eslint-plugin-jest": "^27.6.0",
8282
"estree-walker": "^2.0.2",
8383
"execa": "^8.0.1",
84-
"jsdom": "^22.1.0",
85-
"lint-staged": "^15.1.0",
84+
"jsdom": "^23.0.1",
85+
"lint-staged": "^15.2.0",
8686
"lodash": "^4.17.21",
8787
"magic-string": "^0.30.5",
8888
"markdown-table": "^3.0.3",
89-
"marked": "^9.1.6",
89+
"marked": "^11.0.1",
9090
"minimist": "^1.2.8",
9191
"npm-run-all": "^4.1.5",
9292
"picocolors": "^1.0.0",
93-
"prettier": "^3.1.0",
93+
"prettier": "^3.1.1",
9494
"pretty-bytes": "^6.1.1",
9595
"pug": "^3.0.2",
96-
"puppeteer": "~21.5.2",
96+
"puppeteer": "~21.6.0",
9797
"rimraf": "^5.0.5",
9898
"rollup": "^4.1.4",
9999
"rollup-plugin-dts": "^6.1.0",
@@ -108,6 +108,6 @@
108108
"tsx": "^4.6.2",
109109
"typescript": "^5.2.2",
110110
"vite": "^5.0.5",
111-
"vitest": "^1.0.0"
111+
"vitest": "^1.0.4"
112112
}
113113
}

packages/compiler-sfc/src/script/resolveType.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ export function inferRuntimeType(
14531453
scope
14541454
)
14551455
}
1456+
break
14561457
case 'TSMethodSignature':
14571458
case 'TSFunctionType':
14581459
return ['Function']

packages/reactivity/src/baseHandlers.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,19 @@ class MutableReactiveHandler extends BaseReactiveHandler {
174174
receiver: object
175175
): boolean {
176176
let oldValue = (target as any)[key]
177-
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
178-
return false
179-
}
180177
if (!this._shallow) {
178+
const isOldValueReadonly = isReadonly(oldValue)
181179
if (!isShallow(value) && !isReadonly(value)) {
182180
oldValue = toRaw(oldValue)
183181
value = toRaw(value)
184182
}
185183
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
186-
oldValue.value = value
187-
return true
184+
if (isOldValueReadonly) {
185+
return false
186+
} else {
187+
oldValue.value = value
188+
return true
189+
}
188190
}
189191
} else {
190192
// in shallow mode, objects are set as-is regardless of reactive or not

packages/runtime-core/src/componentEmits.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ export type EmitsOptions = ObjectEmitsOptions | string[]
3838

3939
export type EmitsToProps<T extends EmitsOptions> = T extends string[]
4040
? {
41-
[K in string & `on${Capitalize<T[number]>}`]?: (...args: any[]) => any
41+
[K in `on${Capitalize<T[number]>}`]?: (...args: any[]) => any
4242
}
4343
: T extends ObjectEmitsOptions
4444
? {
45-
[K in string &
46-
`on${Capitalize<string & keyof T>}`]?: K extends `on${infer C}`
47-
? T[Uncapitalize<C>] extends null
48-
? (...args: any[]) => any
49-
: (
50-
...args: T[Uncapitalize<C>] extends (...args: infer P) => any
51-
? P
45+
[K in `on${Capitalize<string & keyof T>}`]?: K extends `on${infer C}`
46+
? (
47+
...args: T[Uncapitalize<C>] extends (...args: infer P) => any
48+
? P
49+
: T[Uncapitalize<C>] extends null
50+
? any[]
5251
: never
53-
) => any
52+
) => any
5453
: never
5554
}
5655
: {}

packages/runtime-dom/__tests__/helpers/useCssVars.spec.ts

+31
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,35 @@ describe('useCssVars', () => {
293293
await nextTick()
294294
expect(target.children.length).toBe(0)
295295
})
296+
297+
test('with string style', async () => {
298+
document.body.innerHTML = ''
299+
const state = reactive({ color: 'red' })
300+
const root = document.createElement('div')
301+
const disabled = ref(false)
302+
303+
const App = {
304+
setup() {
305+
useCssVars(() => state)
306+
return () => [
307+
h(
308+
'div',
309+
{ style: disabled.value ? 'pointer-events: none' : undefined },
310+
'foo'
311+
)
312+
]
313+
}
314+
}
315+
render(h(App), root)
316+
await nextTick()
317+
for (const c of [].slice.call(root.children as any)) {
318+
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
319+
}
320+
disabled.value = true
321+
await nextTick()
322+
323+
for (const c of [].slice.call(root.children as any)) {
324+
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
325+
}
326+
})
296327
})

packages/runtime-dom/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"dependencies": {
3838
"@vue/shared": "workspace:*",
3939
"@vue/runtime-core": "workspace:*",
40-
"csstype": "^3.1.2"
40+
"csstype": "^3.1.3"
4141
}
4242
}

packages/runtime-dom/src/helpers/useCssVars.ts

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '@vue/runtime-core'
1111
import { ShapeFlags } from '@vue/shared'
1212

13+
export const CSS_VAR_TEXT = Symbol(__DEV__ ? 'CSS_VAR_TEXT' : '')
1314
/**
1415
* Runtime helper for SFC's CSS variable injection feature.
1516
* @private
@@ -79,8 +80,11 @@ function setVarsOnVNode(vnode: VNode, vars: Record<string, string>) {
7980
function setVarsOnNode(el: Node, vars: Record<string, string>) {
8081
if (el.nodeType === 1) {
8182
const style = (el as HTMLElement).style
83+
let cssText = ''
8284
for (const key in vars) {
8385
style.setProperty(`--${key}`, vars[key])
86+
cssText += `--${key}: ${vars[key]};`
8487
}
88+
;(style as any)[CSS_VAR_TEXT] = cssText
8589
}
8690
}

packages/runtime-dom/src/modules/style.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isString, hyphenate, capitalize, isArray } from '@vue/shared'
22
import { camelize, warn } from '@vue/runtime-core'
33
import { vShowOldKey } from '../directives/vShow'
4+
import { CSS_VAR_TEXT } from '../helpers/useCssVars'
45

56
type Style = string | Record<string, string | string[]> | null
67

@@ -22,6 +23,11 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
2223
const currentDisplay = style.display
2324
if (isCssString) {
2425
if (prev !== next) {
26+
// #9821
27+
const cssVarText = (style as any)[CSS_VAR_TEXT]
28+
if (cssVarText) {
29+
;(next as string) += ';' + cssVarText
30+
}
2531
style.cssText = next as string
2632
}
2733
} else if (prev) {

packages/sfc-playground/src/Header.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const vueVersion = ref(`@${currentCommit}`)
2424
async function setVueVersion(v: string) {
2525
vueVersion.value = `loading...`
2626
await store.setVueVersion(v)
27-
vueVersion.value = `v${v}`
27+
vueVersion.value = v
2828
}
2929
3030
function resetVueVersion() {

packages/sfc-playground/src/VersionSelect.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ onMounted(() => {
7474

7575
<ul class="versions" :class="{ expanded }">
7676
<li v-if="!versions"><a>loading versions...</a></li>
77-
<li v-for="version of versions">
78-
<a @click="setVersion(version)">v{{ version }}</a>
77+
<li v-for="ver of versions" :class="{ active: ver === version }">
78+
<a @click="setVersion(ver)">v{{ ver }}</a>
7979
</li>
8080
<div @click="expanded = false">
8181
<slot />
@@ -111,4 +111,8 @@ onMounted(() => {
111111
border-top: 6px solid #aaa;
112112
margin-left: 8px;
113113
}
114+
115+
.versions .active a {
116+
color: var(--green);
117+
}
114118
</style>

packages/template-explorer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"enableNonBrowserBranches": true
1212
},
1313
"dependencies": {
14-
"monaco-editor": "^0.44.0",
14+
"monaco-editor": "^0.45.0",
1515
"source-map-js": "^1.0.2"
1616
}
1717
}

0 commit comments

Comments
 (0)