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(util): handle more edge cases in looseEqual() util and add spec #9527

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

jacobmllr95
Copy link

@jacobmllr95 jacobmllr95 commented Feb 19, 2019

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

This PR makes the looseEqual() util more bulletproof and adds an extra spec for it.

The previous implementation failed at following tests:

Expected: false
Received: true

  65 |     // Files with slightly different dates
> 66 |     expect(looseEqual(file1, file3)).toBe(false)
Expected: false
Received: true

  102 |     // Different regex
> 103 |     expect(looseEqual(rx1, rx3)).toBe(false)
Expected: false
Received: true

> 153 |     expect(looseEqual(obj1, date1)).toBe(false)

Performance should also be equal or slightly better because early exits are used wherever possible:
https://jsperf.com/looseequal-comparison

Shoutout to @tmorehouse for helping with the tests and handling all the edge cases.

@jacobmllr95 jacobmllr95 changed the title fix(utils): Handle more edgecases in looseEqual() util and add spec Feb 19, 2019
src/shared/util.js Outdated Show resolved Hide resolved
@jacobmllr95
Copy link
Author

@posva @yyx990803 Since the same changes landed in Vue v3 it would be awesome to have them in Vue v2.7 too.

Ref: vuejs/core#379

@posva posva added this to Planned in 2.6.13 via automation May 6, 2021
@posva posva moved this from Planned to Reviewed once, needs another review in 2.6.13 May 6, 2021
@posva posva added this to Planned in 2.6.15 via automation Jun 1, 2021
@posva posva moved this from Planned to Reviewed once, needs another review in 2.6.15 Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants