]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix: mark currentRoute as non reactive to preserve properties
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 21 Jan 2020 17:19:10 +0000 (18:19 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 21 Jan 2020 17:19:10 +0000 (18:19 +0100)
src/router.ts
src/types/index.ts

index 6e7b869315897a6b8d52756a9442b7f3ec3066c5..0d1d2c40992430c29235bdd72aa6d94d2570c7d7 100644 (file)
@@ -33,7 +33,7 @@ import {
 import { extractComponentsGuards, guardToPromiseFn } from './utils'
 import { encodeParam } from './utils/encoding'
 import { decode } from './utils/encoding'
-import { ref, Ref } from '@vue/reactivity'
+import { ref, Ref, markNonReactive } from '@vue/reactivity'
 
 type ErrorHandler = (error: any) => any
 // resolve, reject arguments of Promise constructor
@@ -269,7 +269,7 @@ export function createRouter({
     else history.push(url)
 
     const from = currentRoute.value
-    currentRoute.value = toLocation
+    currentRoute.value = markNonReactive(toLocation)
     updateReactiveRoute()
     handleScroll(toLocation, from).catch(err => triggerError(err, false))
 
@@ -376,10 +376,10 @@ export function createRouter({
       }
 
       // accept current navigation
-      currentRoute.value = {
+      currentRoute.value = markNonReactive({
         ...to,
         ...matchedRoute,
-      }
+      })
       updateReactiveRoute()
       // TODO: refactor with a state getter
       // const { scroll } = history.state
@@ -532,7 +532,7 @@ export function createRouter({
     // already contains current location
 
     const from = currentRoute.value
-    currentRoute.value = toLocation
+    currentRoute.value = markNonReactive(toLocation)
     updateReactiveRoute()
 
     // navigation is confirmed, call afterGuards
index 44091c64f7aa7efed3abbd906e5988d9443269c9..fad29513c883051a1d86da7a499482620c295628 100644 (file)
@@ -1,5 +1,6 @@
 import { HistoryQuery, RawHistoryQuery } from '../history/common'
 import { PathParserOptions } from '../matcher/path-parser-ranker'
+import { markNonReactive } from '@vue/reactivity'
 
 // type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent
 
@@ -135,16 +136,18 @@ export type RouteRecord =
   | RouteRecordRedirect
 
 // TODO: this should probably be generate by ensureLocation
-export const START_LOCATION_NORMALIZED: RouteLocationNormalized = {
-  path: '/',
-  name: undefined,
-  params: {},
-  query: {},
-  hash: '',
-  fullPath: '/',
-  matched: [],
-  meta: {},
-}
+export const START_LOCATION_NORMALIZED: RouteLocationNormalized = markNonReactive(
+  {
+    path: '/',
+    name: undefined,
+    params: {},
+    query: {},
+    hash: '',
+    fullPath: '/',
+    matched: [],
+    meta: {},
+  }
+)
 
 // make matched non enumerable for easy printing
 Object.defineProperty(START_LOCATION_NORMALIZED, 'matched', {