From: Eduardo San Martin Morote Date: Mon, 25 May 2020 08:17:21 +0000 (+0200) Subject: fix(matcher): correct check when removing existing records on add X-Git-Tag: v4.0.0-alpha.13~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c267f5aceec899c84514571e4fa75dc61441ed4;p=thirdparty%2Fvuejs%2Frouter.git fix(matcher): correct check when removing existing records on add --- diff --git a/src/matcher/index.ts b/src/matcher/index.ts index ab02038d..de894a29 100644 --- a/src/matcher/index.ts +++ b/src/matcher/index.ts @@ -118,6 +118,11 @@ export function createRouterMatcher( // otherwise, the first record is the original and others are aliases originalMatcher = originalMatcher || matcher if (originalMatcher !== matcher) originalMatcher.alias.push(matcher) + + // remove the route if named and only for the top record (avoid in nested calls) + // this works because the original record is the first one + if (isRootAdd && record.name && !isAliasRecord(matcher)) + removeRoute(record.name) } // only non redirect records have children @@ -136,9 +141,6 @@ export function createRouterMatcher( // other alias (if any) need to reference this record when adding children originalRecord = originalRecord || matcher - // remove the route if named and only for the top record (avoid in nested calls) - if (isRootAdd && record.name) removeRoute(record.name) - insertMatcher(matcher) }