Skip to content

Commit f0b5349

Browse files
committed
Fix bug where isObjectEqual throws exception with null values.
Fixes vuejs#1566.
1 parent 5c2a291 commit f0b5349

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: src/util/route.js

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export function isSameRoute (a: Route, b: ?Route): boolean {
7474
}
7575

7676
function isObjectEqual (a = {}, b = {}): boolean {
77+
if (a === null) {
78+
return b === null
79+
}
80+
if (b === null) {
81+
return false
82+
}
7783
const aKeys = Object.keys(a)
7884
const bKeys = Object.keys(b)
7985
if (aKeys.length !== bKeys.length) {

Diff for: test/unit/specs/route.spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ describe('Route utils', () => {
4747
expect(isSameRoute(a, b)).toBe(true)
4848
expect(isSameRoute(a, c)).toBe(false)
4949
})
50+
51+
it('null values (regression test for #1566)', () => {
52+
const a = {
53+
path: '/abc',
54+
query: { foo: 'bar' }
55+
}
56+
const b = {
57+
path: '/abc',
58+
query: { foo: null }
59+
}
60+
expect(isSameRoute(a, b)).toBe(false);
61+
})
5062
})
5163

5264
describe('isIncludedRoute', () => {

0 commit comments

Comments
 (0)