@@ -94,26 +94,24 @@ export function isSameRoute (a: Route, b: ?Route, onlyPath: ?boolean): boolean {
9494}
9595
9696function isObjectEqual ( a = { } , b = { } ) : boolean {
97- // handle null value #1566
9897 if ( ! a || ! b ) return a === b
99- const aKeys = Object . keys ( a ) . sort ( )
100- const bKeys = Object . keys ( b ) . sort ( )
101- if ( aKeys . length !== bKeys . length ) {
102- return false
98+ if ( Array . isArray ( a ) && Array . isArray ( b ) ) {
99+ return a . length === b . length && a . every ( ( v , i ) => String ( v ) === String ( b [ i ] ) )
103100 }
104- return aKeys . every ( ( key , i ) => {
105- const aVal = a [ key ]
106- const bKey = bKeys [ i ]
107- if ( bKey !== key ) return false
108- const bVal = b [ key ]
109- // query values can be null and undefined
110- if ( aVal == null || bVal == null ) return aVal === bVal
111- // check nested equality
112- if ( typeof aVal === 'object' && typeof bVal === 'object' ) {
101+ if ( a instanceof Object && b instanceof Object ) {
102+ const aKeys = Object . keys ( a ) . sort ( )
103+ const bKeys = Object . keys ( b ) . sort ( )
104+ if ( aKeys . length !== bKeys . length ) return false
105+ return aKeys . every ( ( key , i ) => {
106+ const aVal = a [ key ]
107+ const bKey = bKeys [ i ]
108+ if ( bKey !== key ) return false
109+ const bVal = b [ key ]
110+ if ( aVal == null || bVal == null ) return aVal === bVal
113111 return isObjectEqual ( aVal , bVal )
114- }
115- return String ( aVal ) === String ( bVal )
116- } )
112+ } )
113+ }
114+ return String ( a ) === String ( b )
117115}
118116
119117export function isIncludedRoute ( current : Route , target : Route ) : boolean {
@@ -126,11 +124,9 @@ export function isIncludedRoute (current: Route, target: Route): boolean {
126124 )
127125}
128126
129- function queryIncludes ( current : Dictionary < string > , target : Dictionary < string > ) : boolean {
127+ function queryIncludes ( current : QueryDictionary , target : QueryDictionary ) : boolean {
130128 for ( const key in target ) {
131- if ( ! ( key in current ) ) {
132- return false
133- }
129+ if ( ! ( key in current ) ) return false
134130 }
135131 return true
136132}
0 commit comments