Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reactivity): clear on readonly collections return undefined #7316

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

wsypower
Copy link
Contributor

clear on readonly collections return the proxy

const warp = readonly(new Map())
console.log(warp.clear() === warp)  // true

This fix now return undefined

const warp = readonly(new Map())
console.log(warp.clear())  // undefined

@wsypower
Copy link
Contributor Author

currently, only the return value of the clear method is different from the rules of Map and Set.

const readonlyMap = readonly(new Map())
console.log('size',readonlyMap.size) // 0
console.log('get',readonlyMap.get('key')) // undefined
console.log('set',readonlyMap.set('key',2)) // readonlyMap
console.log('has',readonlyMap.has('key')) // false
console.log('delete',readonlyMap.delete('key')) // false
console.log('clear',readonlyMap.clear()) // readonlyMap

or was it designed this way on purpose?

Copy link

@PraveenNanda124 PraveenNanda124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@pikax pikax added the ready to merge The PR is ready to be merged. label Oct 20, 2023
Copy link

github-actions bot commented Nov 9, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 86.4 kB (+21 B) 32.9 kB (+7 B) 29.7 kB (+20 B)
vue.global.prod.js 132 kB (+21 B) 49.6 kB (+6 B) 44.5 kB (+21 B)

Usages

Name Size Gzip Brotli
createApp 48 kB (+21 B) 18.9 kB (+7 B) 17.2 kB (-46 B)
createSSRApp 51.2 kB (+21 B) 20.2 kB (+7 B) 18.4 kB (+9 B)
defineCustomElement 50.3 kB (+21 B) 19.7 kB (+7 B) 17.9 kB (-3 B)
overall 61.3 kB (+21 B) 23.7 kB (+7 B) 21.6 kB (+4 B)

@yyx990803 yyx990803 merged commit 657476d into vuejs:main Nov 9, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
Development

Successfully merging this pull request may close these issues.

6 participants