tosijs-ui 1.16.5 → 1.16.6

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.16.6
4
+
5
+ A one-fix patch: a link to the page you are already on no longer adds a history entry that Back
6
+ has to step through (#174). No API change.
7
+
8
+ ### Clicking a link to the page you are on no longer costs an extra Back (#174)
9
+
10
+ A doc link pointing at the document already showing pushed a duplicate history entry, so the
11
+ next Back press left the page where it was. It now replaces the entry, as a native same-URL
12
+ navigation does. "The same page" means the same document: `/x`, `/x/` and `/x/index.html`, or
13
+ `?x` with extra query parameters, all count. A URL with a hash still pushes, so Back from
14
+ `/x/` returns to `/x/#example`. The `router`'s `navigate()` had the same defect and gets the
15
+ same rule: navigating to the current path (with no hash) replaces.
16
+
17
+ The double push #174 measured on every link (ensemble on 1.14.1) does not reproduce on 1.16.4
18
+ with the same direct import: one click, one entry, and Back and Forward both work, in Chromium
19
+ and WebKit. The documented consumer entry point is `import 'tosijs-ui/doc-browser'`, which
20
+ registers `<tosi-doc-system>` since 1.14.2. The deep `tosijs-ui/doc-system/doc-system.js`
21
+ import loads the same module.
22
+
3
23
  ## 1.16.5
4
24
 
5
25
  A patch, mostly found by using the doc site on an iPhone: menus that stay on screen as Safari's
@@ -1027,7 +1027,19 @@ export function createDocBrowser(options) {
1027
1027
  }
1028
1028
  else {
1029
1029
  const href = hrefFor(filename);
1030
- window.history.pushState({ href }, '', href);
1030
+ /*
1031
+ A link to the document already showing REPLACES the entry rather than pushing one, as a
1032
+ native same-URL navigation does. Pushing left a duplicate the reader had to Back
1033
+ through, and Back then visibly did nothing — the symptom #174 reported.
1034
+
1035
+ "Same" is the DOCUMENT, the identity the popstate guard uses, not the raw path: `/x`,
1036
+ `/x/` and `/x/index.html`, or `?x` and `?x&_testMode=1`, are one page. A URL carrying a
1037
+ hash still pushes, because leaving `/x/#example` for `/x/` is a navigation the reader
1038
+ may want to come Back from.
1039
+ */
1040
+ const same = filename === String(app.currentDoc.filename) &&
1041
+ document.location.hash === '';
1042
+ window.history[same ? 'replaceState' : 'pushState']({ href }, '', href);
1031
1043
  }
1032
1044
  navigateTo(filename);
1033
1045
  };