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(router): handle Object.keys router error in Edge #40488

Closed
wants to merge 1 commit into from
Closed

fix(router): handle Object.keys router error in Edge #40488

wants to merge 1 commit into from

Conversation

agale123
Copy link
Contributor

@agale123 agale123 commented Jan 19, 2021

For the Google Cloud Console within Google we observed errors in the
shallowEqual function for users in IE and Edge. I made this patch within
Google and observed that the errors went away so I am upstreaming this
change into Angular.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

An error would be thrown in Edge when navigating using shallowEqual

Issue Number: #40090

What is the new behavior?

No error is thrown

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla google-cla bot added the cla: yes label Jan 19, 2021
@pullapprove pullapprove bot requested a review from atscott January 19, 2021 19:53
@petebacondarwin petebacondarwin added area: router target: patch This PR is targeted for the next patch release labels Jan 19, 2021
@ngbot ngbot bot added this to the Backlog milestone Jan 19, 2021
Comment on lines +29 to 28
const k1 = a ? Object.keys(a) : undefined;
const k2 = b ? Object.keys(b) : undefined;
if (!k1 || !k2 || k1.length != k2.length) {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

Could we just bail out early if a or b is undefined?

Suggested change
const k1 = a ? Object.keys(a) : undefined;
const k2 = b ? Object.keys(b) : undefined;
if (!k1 || !k2 || k1.length != k2.length) {
return false;
if (!a || !b) {
return false;
}
const k1 = Object.keys(a);
const k2 = Object.keys(b);
if (k1.length != k2.length) {
return false;

Or is it still possible for Object.keys(x) to return undefined even if x is not undefined?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the old comment is indicating that Object.keys(x) would sometimes return undefined even if x is not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this change simplifies the casting of k1 and k2 and has been tested already I'd prefer to keep it as it. Might be able to simplify this in the future once folks are off older versions of Edge

packages/router/src/utils/collection.ts Outdated Show resolved Hide resolved
… Edge

For the Google Cloud Console within Google we observed errors in the
shallowEqual function for users in IE and Edge. This patch was made within
Google and the errors went away. This commit upstreams the change into Angular.
Copy link

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

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

LGTM +1

@atscott atscott added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Jan 20, 2021
@atscott
Copy link
Contributor

atscott commented Jan 20, 2021

caretaker note: After merging this PR, you will have to remove the g3 local patch for this, found here

jessicajaniuk pushed a commit that referenced this pull request Jan 21, 2021
… Edge (#40488)

For the Google Cloud Console within Google we observed errors in the
shallowEqual function for users in IE and Edge. This patch was made within
Google and the errors went away. This commit upstreams the change into Angular.

PR Close #40488
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants