Merge pull request #1889 from pygy/fix-1857

Don't overwrite the options object when redirecting from onmatch with m.route.set
This commit is contained in:
Pierre-Yves Gérardy 2017-07-06 21:10:03 +02:00 committed by GitHub
commit 4df43499be
2 changed files with 6 additions and 2 deletions

View file

@ -39,7 +39,10 @@ module.exports = function($window, redrawService) {
redrawService.subscribe(root, run)
}
route.set = function(path, data, options) {
if (lastUpdate != null) options = {replace: true}
if (lastUpdate != null) {
options = options || {}
options.replace = true
}
lastUpdate = null
routeService.setPath(path, data, options)
}

View file

@ -667,7 +667,7 @@ o.spec("route", function() {
route(root, "/a", {
"/a" : {
onmatch: function() {
route.set("/b")
route.set("/b", {}, {state: {a: 5}})
},
render: render
},
@ -686,6 +686,7 @@ o.spec("route", function() {
o(view.callCount).equals(1)
o(root.childNodes.length).equals(1)
o(root.firstChild.nodeName).equals("DIV")
o($window.history.state).deepEquals({a: 5})
done()
})