@webqit/webflo 1.0.9 → 1.0.11

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 CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "1.0.9",
15
+ "version": "1.0.11",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -454,6 +454,7 @@ export class WebfloClient extends WebfloRuntime {
454
454
  scope.httpEvent.client.postMessage(scope.data.status, { messageType: 'status' });
455
455
  }
456
456
  await this.render(scope.httpEvent, scope.data, !(['GET'].includes(scope.request.method) || scope.response.redirected || scope.detail.navigationType === 'rdr'));
457
+ await this.applyPostRenderState(scope.httpEvent);
457
458
  });
458
459
  }
459
460
 
@@ -538,6 +539,12 @@ export class WebfloClient extends WebfloRuntime {
538
539
  }
539
540
  });
540
541
  }
542
+
543
+ async applyPostRenderState(httpEvent) {
544
+ if (!httpEvent.url.hash && httpEvent.detail.navigationType !== 'traverse' && httpEvent.request.method === 'GET') {
545
+ (this.host === document ? window : this.host).scrollTo(0, 0);
546
+ }
547
+ }
541
548
 
542
549
  async remoteFetch(request, ...args) {
543
550
  Observer.set(this.#navigator, 'remotely', true);
@@ -178,6 +178,6 @@ export class WebfloRootClient1 extends WebfloClient {
178
178
  if (destinationState.scrollPosition?.length) {
179
179
  window.scroll(...destinationState.scrollPosition);
180
180
  (document.querySelector('[autofocus]') || document.body).focus();
181
- }
181
+ } else await super.applyPostRenderState(httpEvent);
182
182
  }
183
183
  }
@@ -161,9 +161,7 @@ export class WebfloSubClient extends WebfloClient {
161
161
  async applyPostRenderState(httpEvent) {
162
162
  if (httpEvent.url.hash) {
163
163
  this.host.querySelector(httpEvent.url.hash)?.scrollIntoView();
164
- } else {
165
- this.host.scrollTo(0, 0);
166
- }
164
+ } else await super.applyPostRenderState(httpEvent);
167
165
  (this.host.querySelector('[autofocus]') || this.host).focus();
168
166
  }
169
167
  }
@@ -3,7 +3,8 @@ import { WebfloRootClient2 } from './WebfloRootClient2.js';
3
3
  import { WebfloSubClient } from './WebfloSubClient.js';
4
4
 
5
5
  export function start() {
6
- const WebfloRootClient = window.navigation ? WebfloRootClient2 : WebfloRootClient1;
6
+ const navigationAPIMeta = document.querySelector('meta[name="webflo-navigationapi"]')?.value;
7
+ const WebfloRootClient = window.navigation && navigationAPIMeta ? WebfloRootClient2 : WebfloRootClient1;
7
8
  const instance = WebfloRootClient.create(document, this || {});
8
9
  instance.initialize();
9
10
  WebfloSubClient.defineElement();
@@ -688,7 +688,7 @@ export class WebfloServer extends WebfloRuntime {
688
688
  const newRoute = '/' + `routes/${httpEvent.url.pathname}`.split('/').map(a => (a => a.startsWith('$') ? '-' : a)(a.trim())).filter(a => a).join('/');
689
689
  document.body.setAttribute(modulesContextAttrs.importscontext, newRoute);
690
690
  }
691
- await new Promise(res => setTimeout(res, 150));
691
+ await new Promise(res => setTimeout(res, 500));
692
692
  }
693
693
  // Append background-activity meta
694
694
  let backgroundActivityMeta = document.querySelector('meta[name="X-Background-Messaging"]');