fix(router): Remove usage of `Object.entries` to avoid the need for a polyfill (#40340)

`Object.entries` is not supported in IE11 without a polyfill. The quickest,
most straightfoward fix for this is to simply use `Object.keys` instead.
We may want to consider including the polyfill in the CLI in the future
or just wait until IE11 support is dropped before using
`Object.entries`.

PR Close #40340
This commit is contained in:
Andrew Scott 2021-01-07 09:58:04 -08:00 committed by atscott
parent 1e151f9fe4
commit 2028a43580
1 changed files with 2 additions and 1 deletions

View File

@ -502,7 +502,8 @@ function mergeTrivialChildren(s: UrlSegmentGroup): UrlSegmentGroup {
*/ */
function squashSegmentGroup(segmentGroup: UrlSegmentGroup): UrlSegmentGroup { function squashSegmentGroup(segmentGroup: UrlSegmentGroup): UrlSegmentGroup {
const newChildren = {} as any; const newChildren = {} as any;
for (const [childOutlet, child] of Object.entries(segmentGroup.children)) { for (const childOutlet of Object.keys(segmentGroup.children)) {
const child = segmentGroup.children[childOutlet];
const childCandidate = squashSegmentGroup(child); const childCandidate = squashSegmentGroup(child);
// don't add empty children // don't add empty children
if (childCandidate.segments.length > 0 || childCandidate.hasChildren()) { if (childCandidate.segments.length > 0 || childCandidate.hasChildren()) {