@thepassle/app-tools 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/router/index.js +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepassle/app-tools",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
package/router/index.js CHANGED
@@ -106,7 +106,7 @@ export class Router extends EventTarget {
106
106
  }
107
107
 
108
108
  _onPopState = () => {
109
- this.navigate(new URL(window.location.href));
109
+ this.navigate(new URL(window.location.href), { backNav: true });
110
110
  }
111
111
 
112
112
  _onAnchorClick = (e) => {
@@ -137,9 +137,12 @@ export class Router extends EventTarget {
137
137
  }
138
138
 
139
139
  /**
140
- * @param {string | URL} url
140
+ * @param {string | URL} url The URL to navigate to.
141
+ * @param {@param {{
142
+ * backNav?: boolean
143
+ * }} options} options An options object to configure the navigation. The backNav property specifies whether the navigation is a backward navigation, which doesn't push the navigation into browser nav history.
141
144
  */
142
- async navigate(url) {
145
+ async navigate(url, options = {}) {
143
146
  if (typeof url === 'string') {
144
147
  url = new URL(url, this.baseUrl);
145
148
  }
@@ -183,7 +186,9 @@ export class Router extends EventTarget {
183
186
  }
184
187
  }
185
188
 
186
- window.history.pushState(null, '', `${url.pathname}${url.search}`);
189
+ if (!options.backNav) {
190
+ window.history.pushState(null, '', `${url.pathname}${url.search}`);
191
+ }
187
192
  document.title = this.context.title;
188
193
  this._notifyUrlChanged();
189
194