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): check rawValue exists in target via set.add vuejs#8647 #12393

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shengxj1
Copy link

fix #8647

expect(observedSet.size).toBe(1)

const observedMap = reactive(new Map())
observedMap.set('key', observed)
Copy link
Member

Choose a reason for hiding this comment

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

The test case for Map.set here is incorrect because you only modified add without changing set. I think this part of the test would pass even without this PR. Additionally, the observedMap should have an initial value like observedSet

const target = toRaw(this)
const proto = getProto(target)
const hadKey = proto.has.call(target, value)
// 先获取原始值
Copy link
Member

Choose a reason for hiding this comment

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

this comment seems unnecessary

@edison1105 edison1105 added scope: reactivity 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. wait changes labels Nov 15, 2024
const target = toRaw(this)
const proto = getProto(target)
const hadKey = proto.has.call(target, value)
// 先获取原始值
const rawValue =
Copy link
Member

@edison1105 edison1105 Nov 15, 2024

Choose a reason for hiding this comment

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

Suggested change
const rawValue =
const valueToAdd =

The following operation doesn't always return a raw value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: reactivity wait changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unintuitive Proxy behavior violating set item uniqueness constraint
2 participants