@sveltejs/kit 1.0.0-next.196 → 1.0.0-next.197

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.
@@ -656,48 +656,43 @@ class Renderer {
656
656
  this._init(navigation_result);
657
657
  }
658
658
 
659
- getSelection()?.removeAllRanges();
659
+ const { hash, scroll, keepfocus } = opts || {};
660
660
 
661
- if (!opts) {
662
- await 0;
663
- } else {
664
- const { hash, scroll, keepfocus } = opts;
665
-
666
- if (!keepfocus) {
667
- document.body.focus();
668
- }
661
+ if (!keepfocus) {
662
+ getSelection()?.removeAllRanges();
663
+ document.body.focus();
664
+ }
669
665
 
670
- const old_page_y_offset = Math.round(pageYOffset);
671
- const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
672
-
673
- await 0;
674
-
675
- const new_page_y_offset = Math.round(pageYOffset);
676
- const new_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
677
-
678
- // After `await 0`, the `onMount()` function in the component executed.
679
- // Check if no scrolling happened on mount.
680
- const no_scroll_happened =
681
- // In most cases, we can compare whether `pageYOffset` changed between navigation
682
- new_page_y_offset === Math.min(old_page_y_offset, new_max_page_y_offset) ||
683
- // But if the page is scrolled to/near the bottom, the browser would also scroll
684
- // to/near the bottom of the new page on navigation. Since we can't detect when this
685
- // behaviour happens, we naively compare by the y offset from the bottom of the page.
686
- old_max_page_y_offset - old_page_y_offset === new_max_page_y_offset - new_page_y_offset;
687
-
688
- // If there was no scrolling, we run on our custom scroll handling
689
- if (no_scroll_happened) {
690
- const deep_linked = hash && document.getElementById(hash.slice(1));
691
- if (scroll) {
692
- scrollTo(scroll.x, scroll.y);
693
- } else if (deep_linked) {
694
- // Here we use `scrollIntoView` on the element instead of `scrollTo`
695
- // because it natively supports the `scroll-margin` and `scroll-behavior`
696
- // CSS properties.
697
- deep_linked.scrollIntoView();
698
- } else {
699
- scrollTo(0, 0);
700
- }
666
+ const old_page_y_offset = Math.round(pageYOffset);
667
+ const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
668
+
669
+ await 0;
670
+
671
+ const new_page_y_offset = Math.round(pageYOffset);
672
+ const new_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
673
+
674
+ // After `await 0`, the `onMount()` function in the component executed.
675
+ // Check if no scrolling happened on mount.
676
+ const no_scroll_happened =
677
+ // In most cases, we can compare whether `pageYOffset` changed between navigation
678
+ new_page_y_offset === Math.min(old_page_y_offset, new_max_page_y_offset) ||
679
+ // But if the page is scrolled to/near the bottom, the browser would also scroll
680
+ // to/near the bottom of the new page on navigation. Since we can't detect when this
681
+ // behaviour happens, we naively compare by the y offset from the bottom of the page.
682
+ old_max_page_y_offset - old_page_y_offset === new_max_page_y_offset - new_page_y_offset;
683
+
684
+ // If there was no scrolling, we run on our custom scroll handling
685
+ if (no_scroll_happened) {
686
+ const deep_linked = hash && document.getElementById(hash.slice(1));
687
+ if (scroll) {
688
+ scrollTo(scroll.x, scroll.y);
689
+ } else if (deep_linked) {
690
+ // Here we use `scrollIntoView` on the element instead of `scrollTo`
691
+ // because it natively supports the `scroll-margin` and `scroll-behavior`
692
+ // CSS properties.
693
+ deep_linked.scrollIntoView();
694
+ } else {
695
+ scrollTo(0, 0);
701
696
  }
702
697
  }
703
698
 
package/dist/cli.js CHANGED
@@ -817,7 +817,7 @@ async function launch(port, https) {
817
817
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
818
818
  }
819
819
 
820
- const prog = sade('svelte-kit').version('1.0.0-next.196');
820
+ const prog = sade('svelte-kit').version('1.0.0-next.197');
821
821
 
822
822
  prog
823
823
  .command('dev')
@@ -982,7 +982,7 @@ async function check_port(port) {
982
982
  function welcome({ port, host, https, open, loose, allow, cwd }) {
983
983
  if (open) launch(port, https);
984
984
 
985
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.196'}\n`));
985
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.197'}\n`));
986
986
 
987
987
  const protocol = https ? 'https:' : 'http:';
988
988
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.196",
3
+ "version": "1.0.0-next.197",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",