]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat: explicit injection symbols in dev mode (#228)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Sat, 9 May 2020 08:18:31 +0000 (10:18 +0200)
committerGitHub <noreply@github.com>
Sat, 9 May 2020 08:18:31 +0000 (10:18 +0200)
src/injectionSymbols.ts

index cac3b0f7fca9cd64fb88057b81ace065aae39ee5..73ecdc9709d3fbd16286a6131164c46ec6fbe407 100644 (file)
@@ -8,18 +8,24 @@ export const hasSymbol =
 
 export const PolySymbol = (name: string) =>
   // vr = vue router
-  hasSymbol ? Symbol(name) : `_vr_` + name
+  hasSymbol
+    ? Symbol(__DEV__ ? '[vue-router]: ' + name : name)
+    : (__DEV__ ? '[vue-router]: ' : '_vr_') + name
 
 // rvlm = Router View Location Matched
-export const matchedRouteKey = PolySymbol('rvlm') as InjectionKey<
-  ComputedRef<RouteRecordNormalized | undefined>
->
+export const matchedRouteKey = PolySymbol(
+  __DEV__ ? 'router view location matched' : 'rvlm'
+) as InjectionKey<ComputedRef<RouteRecordNormalized | undefined>>
 // rvd = Router View Depth
-export const viewDepthKey = PolySymbol('rvd') as InjectionKey<number>
+export const viewDepthKey = PolySymbol(
+  __DEV__ ? 'router view depth' : 'rvd'
+) as InjectionKey<number>
 
 // r = router
-export const routerKey = PolySymbol('r') as InjectionKey<Router>
-// rt = route location
-export const routeLocationKey = PolySymbol('rl') as InjectionKey<
-  RouteLocationNormalizedLoaded
+export const routerKey = PolySymbol(__DEV__ ? 'router' : 'r') as InjectionKey<
+  Router
 >
+// rt = route location
+export const routeLocationKey = PolySymbol(
+  __DEV__ ? 'route location' : 'rl'
+) as InjectionKey<RouteLocationNormalizedLoaded>