ionic-team / stencil-router-v2

Other
44 stars 13 forks source link

[Important] 0.6.0 in npm is missing the helper function. Url change won't scroll to top! #26

Open kingdun3284 opened 3 years ago

kingdun3284 commented 3 years ago

This function is missing in the build.

const handlePushState = (win, loc, hstry, isFromPopState, newUrl) => {
    const pathBeforePush = urlToPath(loc);
    const newHref = newUrl.href;
    const hasHash = newUrl.hash.startsWith('#');
    if (shouldPushState(loc, newUrl)) {
        hstry.pushState(null, '', newHref);
    }
    if (!isFromPopState) {
        if (pathBeforePush !== urlToPath(newUrl)) {
            if (hasHash) {
                loc.href = newHref;
            }
            else {
                win.scrollTo(0, 0);
            }
        }
        else if (hasHash) {
            loc.href = newHref;
        }
    }
};