Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Remove popstate/hashchange event handler when app is torn down #9897

Closed
randombk opened this issue Nov 4, 2014 · 1 comment
Closed

Remove popstate/hashchange event handler when app is torn down #9897

randombk opened this issue Nov 4, 2014 · 1 comment

Comments

@randombk
Copy link
Contributor

randombk commented Nov 4, 2014

When bootstrapping an app, angularjs adds an event listener to window to handle popstate and hashchange events (File /src/ng/browser.js on lines 285 and 287). This is not removed during teardown of the app, meaning that a later instance will be affected by the route/state configuration of the previous app (See issue #9877).

These handlers should be deregistered when the app's root DOM element is removed, or when $destroy() is called on an app's $rootScope. For the most part, this looks to be the only handler not attached to the app's DOM root, judging by a quick search for "jqLite(window).on", so fixing this should go a long way towards being able to fully tear down and remove every part of an angular application without requiring a page refresh.

randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
@randombk
Copy link
Contributor Author

randombk commented Nov 4, 2014

I opened a pull request for a fix. I've already signed the CLA.

randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
randombk added a commit to randombk/angular.js that referenced this issue Nov 4, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
@caitp caitp added this to the 1.3.x milestone Nov 11, 2014
randombk added a commit to randombk/angular.js that referenced this issue Dec 3, 2014
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Remember the popstate and hashchange handler registered with window
when the application bootstraps, and remove it when the application
is torn down

Closes angular#9897
Closes angular#9905
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants