Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To maintain the state of object on URL in IE/Edge #107

Open
mveer-agarwal opened this issue Jun 12, 2018 · 0 comments
Open

To maintain the state of object on URL in IE/Edge #107

mveer-agarwal opened this issue Jun 12, 2018 · 0 comments

Comments

@mveer-agarwal
Copy link

mveer-agarwal commented Jun 12, 2018

I have modified the firePopState method by adding a Map, which keeps the URL and state of object in case of IE/Edge.

function firePopState(currentUrl) {
        var o = document.createEvent ? document.createEvent('Event') : document.createEventObject();
        var currentUrl = currentUrl;
        var NextUrl = windowLocation.href;

        if (o.initEvent) {
            o.initEvent('popstate', false, false);
        } else {
            o.type = 'popstate';
        }

        if (historyMap[NextUrl]) {
            o.state = historyMap[NextUrl];
            delete historyMap[NextUrl];
            historyObject.replaceState(null, "", NextUrl);
        } else {
            historyMap[currentUrl] = historyObject.state;
        }
        // o.state = historyObject.state;
        // send a newly created events to be processed
        dispatchEvent(o);
    }

Please suggest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant