@@ -94,26 +94,24 @@ export function isSameRoute (a: Route, b: ?Route, onlyPath: ?boolean): boolean {
94
94
}
95
95
96
96
function isObjectEqual ( a = { } , b = { } ) : boolean {
97
- // handle null value #1566
98
97
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 ] ) )
103
100
}
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
113
111
return isObjectEqual ( aVal , bVal )
114
- }
115
- return String ( aVal ) === String ( bVal )
116
- } )
112
+ } )
113
+ }
114
+ return String ( a ) === String ( b )
117
115
}
118
116
119
117
export function isIncludedRoute ( current : Route , target : Route ) : boolean {
@@ -126,11 +124,9 @@ export function isIncludedRoute (current: Route, target: Route): boolean {
126
124
)
127
125
}
128
126
129
- function queryIncludes ( current : Dictionary < string > , target : Dictionary < string > ) : boolean {
127
+ function queryIncludes ( current : QueryDictionary , target : QueryDictionary ) : boolean {
130
128
for ( const key in target ) {
131
- if ( ! ( key in current ) ) {
132
- return false
133
- }
129
+ if ( ! ( key in current ) ) return false
134
130
}
135
131
return true
136
132
}
0 commit comments