Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: IE 11 and older do not trigger popstate, use hashchange for chec… #11006

Closed
wants to merge 1 commit into from
Closed

Conversation

DanielRuf
Copy link
Contributor

IE 11 and older do not trigger the popstate event when the hash changes.
We have to use hashchange in this case.

It is a bug that will not be fixed. See https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/3740423/

Closes #10771

Copy link
Contributor

@ncoden ncoden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for others PRs: popstate is used a lot within the framework (Tabs, Accordion, Magellan, Reveal).

Please add an utility in foundation.util.core (or an other utility file if you think it is more appropriate) and avoid code duplication.

@DanielRuf
Copy link
Contributor Author

Same as for others PRs: popstate is used a lot within the framework (Tabs, Accordion, Magellan, Reveal).

Please add an utility in foundation.util.core (or an other utility file if you think it is more appropriate) and avoid code duplication.

Good suggestion. Similar to the load utility method that you suggested?

@ncoden
Copy link
Contributor

ncoden commented Mar 2, 2018

@DanielRuf Exactly (with a better name, specific enough to Foundation)

@ncoden ncoden self-assigned this Mar 3, 2018
@ncoden
Copy link
Contributor

ncoden commented Mar 4, 2018

@DanielRuf I started implemented a generic popstateEvent method and made some research:

  • hashchange is triggered only when the hash change. It is not similar to popstate as it will not be triggered when the url change. IE 8+.
  • popstate is triggered when the history state is changed. Edge 14+.

But none of these events will not being triggerd by history.pushState() (see https://codepen.io/ncoden/pen/ddLQmN). Only backward/forward history manipulations will (like clicking on a link or called history.back()). There is a good polyfill here but it works by overriding history.pushState.

The thing is: we do not even need to listen on all history change. We currently use popstate (checked for Accordion, Magellan, Reveal and Tabs) only for window.location.hash, and could rely on hashchange instead without any problems. No need for a polyfill.

@ncoden
Copy link
Contributor

ncoden commented Mar 4, 2018

Closing this in favor of #11011

@ncoden ncoden closed this Mar 4, 2018
@DanielRuf DanielRuf deleted the fix/tabs-checkdeeplink-ie-hashchange-10771 branch March 4, 2018 16:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deep linking to tabs seems not to work in MSIE 11
2 participants