Avoid race in jem-view when scope is destroyed before template is loaded #130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We ran into this in our application when we redefined a mid level view for a state to use a custom controller, but the same template. I think there is a transition in effect that could be playing a part in the timing.
The following is pseudo-code that attempts to describe the situation. I'll work on getting a working demonstration and/or test case.
<!-- foo.html --> Welcome to foo
<!-- bar.html --> Welcome to bar
top.foo
totop.bar
there is an oldjem-view=middle
and a newjem-view=middle
, each contain ajem-view=main
.jem-view=main
observes a view event and it'supdate()
requests the template. At this point thejem-view
is still a descendant of the root element and its scope is still valid.jem-view=middle
scope is destroyed and detached from it's parent.jem-view=main
proceeds to compile and link the template contents against a new child scope.Directives in the template will not see a
$destroy
event (it already fired), and can therefore leak resources.