Skip to content

Commit

Permalink
Set default value for push to true
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-cz committed Mar 12, 2021
1 parent 91bc136 commit d24fa7a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/preact-iso/router.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { h, createContext, cloneElement } from 'preact';
import { useContext, useMemo, useReducer, useEffect, useLayoutEffect, useRef } from 'preact/hooks';

const UPDATE = (state, url, push) => {
const UPDATE = (state, url) => {
let push = true;
if (url && url.type === 'click') {
const link = url.target.closest('a[href]');
if (!link || link.origin != location.origin) return state;

url.preventDefault();
push = true;
url = link.href.replace(location.origin, '');
} else if (typeof url !== 'string') {
url = location.pathname + location.search;
push = undefined;
}

if (push === true) history.pushState(null, '', url);
Expand Down

0 comments on commit d24fa7a

Please sign in to comment.