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

Forcibly firing popstate event when pushState is called. Resolves #224. #291

Merged
merged 2 commits into from
Apr 9, 2019

Conversation

joeldenning
Copy link
Member

@joeldenning joeldenning commented Apr 9, 2019

Resolves #224 and resolves single-spa/single-spa-angular#49

// https://github.com/CanopyTax/single-spa/issues/224 and https://github.com/CanopyTax/single-spa-angular/issues/49
// We need a popstate event even though the browser doesn't do one by default when you call pushState, so that
// all the applications can reroute.
urlReroute(new PopStateEvent('popstate'));
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the two options are two do it this way (which violates the browser spec for pushState) or alter all of the single-spa helper libraries to listen to single-spa's routing event listener and forcibly update when it happens

Copy link
Member

Choose a reason for hiding this comment

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

That’s a good point, and may warrant a bigger discussion?

I almost lean towards not doing things that are different than the spec, because it opens the door to future bugs when we’re firing that event and it shouldn’t be

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree -- lets add this to the next core team meeting agenda?

I think i'll merge this in for now since. I really do think the chance of breaking people's app is pretty small ("what's one more re-render?" famous last words), but am open to reversing this decision and code later if we as a core team decided on a different approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

Bad news: I think the alternative implementation doesn't work, although I'm not sure why. Just tried it out with single-spa-angular

@frehner
Copy link
Member

frehner commented Apr 9, 2019

code looks good to me.

I do wonder if this has potential side effects that may affect production apps out there that have workarounds in place for this? or could potentially cause something to render twice? I don't know. Just throwing ideas out there

Copy link
Contributor

@TheMcMurder TheMcMurder left a comment

Choose a reason for hiding this comment

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

🐙

@joeldenning
Copy link
Member Author

Yeah I do think that it could have some side effects -- and might cause double render. The only alternative I know of is the one i put above, though, and it causes a double render too.

Do you have any ideas about another way? I think canopy has been "double rendering" because hashchange always fires, and it has been fine

@frehner
Copy link
Member

frehner commented Apr 9, 2019

Commented above about the options

@joeldenning joeldenning merged commit a00d25d into master Apr 9, 2019
@joeldenning joeldenning deleted the issue-224 branch April 9, 2019 23:39
joeldenning added a commit to single-spa/single-spa-angular that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants