Skip to content

Commit

Permalink
snake case #2
Browse files Browse the repository at this point in the history
  • Loading branch information
zommerberg committed Dec 12, 2021
1 parent 7c9def1 commit 6055ae7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/kit/src/runtime/client/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ function scroll_state() {
* @returns {boolean}
*/
function dispatch_navigation_intent(url) {
let canNavigate = true;
let can_navigate = true;

dispatchEvent(
new CustomEvent('sveltekit:navigation-intent', {
detail: {
url,
cancel: () => {
canNavigate = false;
can_navigate = false;
}
}
})
);
return canNavigate;
return can_navigate;
}

/**
Expand Down Expand Up @@ -76,7 +76,7 @@ export class Router {
// create initial history entry, so we can return here
history.replaceState(history.state || {}, '', location.href);
// keeping track of the last known location in order to prevent popstate event navigation if needed
this.lastKnownLocation = location.href;
this.last_known_location = location.href;
}

init_listeners() {
Expand Down Expand Up @@ -174,8 +174,8 @@ export class Router {

if (!this.owns(url)) return;

const canNavigate = dispatch_navigation_intent(url);
if (!canNavigate) {
const can_navigate = dispatch_navigation_intent(url);
if (!can_navigate) {
event.preventDefault();
return;
}
Expand All @@ -198,10 +198,10 @@ export class Router {
if (event.state && this.enabled) {
const url = new URL(location.href);

const canNavigate = dispatch_navigation_intent(url);
if (!canNavigate) {
const can_navigate = dispatch_navigation_intent(url);
if (!can_navigate) {
// "disabling" the back/forward button click by pushing the last known location
history.pushState({}, '', this.lastKnownLocation);
history.pushState({}, '', this.last_known_location);
return;
}

Expand Down Expand Up @@ -247,8 +247,8 @@ export class Router {
) {
const url = new URL(href, get_base_uri(document));

const canNavigate = dispatch_navigation_intent(url);
if (!canNavigate) return;
const can_navigate = dispatch_navigation_intent(url);
if (!can_navigate) return;

if (this.enabled && this.owns(url)) {
history[replaceState ? 'replaceState' : 'pushState'](state, '', href);
Expand Down Expand Up @@ -307,7 +307,7 @@ export class Router {
* @param {string} [hash]
*/
async _navigate(url, scroll, keepfocus, chain, hash) {
this.lastKnownLocation = url.href;
this.last_known_location = url.href;
const info = this.parse(url);

if (!info) {
Expand Down

0 comments on commit 6055ae7

Please sign in to comment.