Skip to content

Commit 04adba1

Browse files
authored
Merge pull request #344 from ambit-tsai/master
提高getLocation函数的ie8兼容性
2 parents 8b6aa3a + 664dcd7 commit 04adba1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/router/history.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ import {
55
export var modeObject = {}
66
//伪造一个Location对象
77
function getLocation(source) {
8-
return {
9-
...source.location,
8+
const location = {
109
getPath() {
1110
return modeObject.value === "hash" ? this.hash.slice(1) : this.pathname
1211
},
1312
state: source.history.state,
1413
key: (source.history.state && source.history.state.key) || "initial"
1514
};
15+
for (const key in source.location) {
16+
if (Object.prototype.hasOwnProperty.call(source.location, key)) {
17+
location[key] = source.location[key];
18+
}
19+
}
20+
return location;
1621
}
1722

1823
//伪造一个History对象
@@ -175,4 +180,4 @@ export {
175180
navigate,
176181
createHistory,
177182
createMemorySource
178-
};
183+
};

0 commit comments

Comments
 (0)