diff --git a/examples/keep-url.html b/examples/keep-url.html new file mode 100644 index 0000000000000000000000000000000000000000..b3f3729a4dc1dffe419f3b7581e28ad98eb38c3d --- /dev/null +++ b/examples/keep-url.html @@ -0,0 +1,55 @@ + + + + + + + SIB test: sib-router + + + + + + + 1st page + 2nd page + 3rd page + + + + + + + + + diff --git a/index.html b/index.html index b14faeaab917c2c466660477f8dee04933cde0ca..ae1b17c4328a7e98dc1609856b250c83e1ffe56c 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,7 @@
  • basic
  • sub-menu
  • no-route-name
  • +
  • keep-url
  • diff --git a/src/sib-router.js b/src/sib-router.js index 7587e3d252d22c8a0a1ddd8b4782323c34c5a55d..576402bda2a6b68281ec1a67fb52c9e472b3d982 100644 --- a/src/sib-router.js +++ b/src/sib-router.js @@ -58,11 +58,13 @@ export default class SIBRouter extends HTMLElement { const path = route.getPath(this.prefix, routeName, id) //update current URL + + this.display(routeName, resource); + if(this.hasAttribute('keep-url')) return; if(this.useHash) window.location.hash = path; else history.pushState({}, routeName, '/' + path); - this.display(routeName, resource); } }