fix(router): Fix occasional error when creating url tree in IE 11 and 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
This commit is contained in:
parent
0e95460cf8
commit
f0733d109e
|
@ -20,12 +20,10 @@ export function shallowEqualArrays(a: any[], b: any[]): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shallowEqual(a: Params, b: Params): boolean {
|
export function shallowEqual(a: Params, b: Params): boolean {
|
||||||
// Casting Object.keys return values to include `undefined` as there are some cases
|
// While `undefined` should never be possible, it would sometimes be the case in IE 11
|
||||||
// in IE 11 where this can happen. Cannot provide a test because the behavior only
|
// and pre-chromium Edge. The check below accounts for this edge case.
|
||||||
// exists in certain circumstances in IE 11, therefore doing this cast ensures the
|
const k1 = a ? Object.keys(a) : undefined;
|
||||||
// logic is correct for when this edge case is hit.
|
const k2 = b ? Object.keys(b) : undefined;
|
||||||
const k1 = Object.keys(a) as string[] | undefined;
|
|
||||||
const k2 = Object.keys(b) as string[] | undefined;
|
|
||||||
if (!k1 || !k2 || k1.length != k2.length) {
|
if (!k1 || !k2 || k1.length != k2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue