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): trigger Map custom has correctly #1972

Merged
merged 3 commits into from
Aug 26, 2020
Merged

fix(reactivity): trigger Map custom has correctly #1972

merged 3 commits into from
Aug 26, 2020

Conversation

Picknight
Copy link
Contributor

Fix the following situation:

let map = new Map()
map.has = function(key) {
  console.log('trigger has')
  return Map.prototype.has.call(map, key)
}

let proxy = reactive(map)
proxy.has('k')  // print 'trigger has' twice

btw, I am not sure if the following situation is as expected: (this PR did not affect this)

let map = new WeakMap()
map.has = function(key) {
  console.log('trigger has')
  return WeakMap.prototype.has.call(map, key)
}

let proxy = reactive(map)
proxy.has(reactive({}))  // print 'trigger has' twice

@yyx990803
Copy link
Member

Calling twice on reactive keys is necessary for the desired behavior. Wouldn't really say it's a bug.

@yyx990803 yyx990803 merged commit 97bc30e into vuejs:master Aug 26, 2020
@Picknight Picknight deleted the picknight/fix-map-trigger-error branch August 26, 2020 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants