@trullock/page-manager 0.6.8 → 0.6.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.
- package/package.json +1 -1
- package/src/index.js +6 -2
- package/tests/dist/index.html +0 -18
- package/tests/dist/main.js +0 -1581
- package/tests/dist/main.js.map +0 -1
- package/tests/dist/page1.htm +0 -4
- package/tests/dist/page2.htm +0 -4
- package/tests/dist/page3.htm +0 -5
- package/tests/dist/page4.htm +0 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -122,7 +122,11 @@ function showPage(url, data, event) {
|
|
|
122
122
|
var route = router.parse(url);
|
|
123
123
|
if (route == null) {
|
|
124
124
|
console.error(`Can't find page: '${url}'`);
|
|
125
|
-
|
|
125
|
+
let page404 = pageHash[options.error404PageName];
|
|
126
|
+
if(!page404)
|
|
127
|
+
return Promise.reject(new PageShowError('/', `Can't find page: '${url}'. Also can't find 404 page: '${options.error404PageName}'`, {}, 'replace'));
|
|
128
|
+
|
|
129
|
+
return Promise.reject(new PageShowError(page404.url, `Can't find page: '${url}'`, {}, 'replace'));
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
data = data || {};
|
|
@@ -318,7 +322,7 @@ export async function init(opts) {
|
|
|
318
322
|
showPage(window.location.pathname + window.location.search + window.location.hash, null, { action: 'load', distance: 0 }).catch(e => {
|
|
319
323
|
console.error(e);
|
|
320
324
|
if (e instanceof PageShowError)
|
|
321
|
-
return showPage(e.url, e.data, { action: e.action || 'show' });
|
|
325
|
+
return showPage(e.url, e.data, { action: stackPointer == -1 ? 'load' : e.action || 'show' });
|
|
322
326
|
});
|
|
323
327
|
|
|
324
328
|
function handlePopstate(context, direction, distance) {
|
package/tests/dist/index.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<script defer src="/main.js"></script></head>
|
|
4
|
-
<body style="height: 100%;">
|
|
5
|
-
<div style="position: fixed; top: 0; background-color: white;">
|
|
6
|
-
<a href="/page1">Page 1</a>
|
|
7
|
-
<a href="/page2">Page 2</a>
|
|
8
|
-
<a href="/page3">Page 3</a>
|
|
9
|
-
<a href="/page4">Page 4</a>
|
|
10
|
-
</div>
|
|
11
|
-
<div id="page-loading">
|
|
12
|
-
Loading
|
|
13
|
-
</div>
|
|
14
|
-
<div>
|
|
15
|
-
<button class="btnStack">Print stack</button>
|
|
16
|
-
</div>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|