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: handle more edge cases in looseEqual() #379

Merged
merged 8 commits into from
Jul 15, 2020

Conversation

jacobmllr95
Copy link
Contributor

See vuejs/vue#9527 details.

@ayush987goyal
Copy link
Contributor

Hey! @yyx990803 Should this function (and some other functions) in vModel.ts be exported so that it can be unit tested?

@jacobmllr95
Copy link
Contributor Author

@yyx990803 Maybe you can revisit this when you find some time.
For more details see: vuejs/vue#9527

@wangfengming
Copy link

wangfengming commented Jun 13, 2020

given a and b

const a = {x: undefined}
const b = {y: 1}

the previous logic of looseEqual(a, b) will return true because of:

const keysA = Object.keys(a)
const keysB = Object.keys(b)

keysA.length === keysB.length && keysA.every((key) => looseEqual(a[key], b[key]))

should check the key set of a and b to be equal

const a = {x: undefined}
const b = {y: 1}

const keysA = Object.keys(a)
const keysB = Object.keys(b)

keysA.length === keysB.length
&& keysA.every((key) => hasOwnProp(b, key))
&& keysB.every((key) => hasOwnProp(a, key))
&& keysA.every((key) => looseEqual(a[key], b[key]))

@wangfengming
Copy link

found that you use aHasKey and bHasKey to ensure the key set to be equal. great!

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.

7 participants