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

Catch error in case $destroy is called twice #539

Closed
wants to merge 1 commit into from

Conversation

wylieconlon
Copy link

This error can happen when using ui-router, as ui-router will manage
your application lifecycle incorrectly. See this issue for more
information:

angular-ui/ui-router#881

I have not managed to create a reproducible test case for the bug, but the error message that this prevents is:

Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

I will provide a test case if possible.

This error can happen when using ui-router, as ui-router will manage
your application lifecycle incorrectly. See this issue for more
information:

angular-ui/ui-router#881
@wylieconlon
Copy link
Author

I've discovered the cause of the error is this bug: angular/angular.js#9281

I also have a jsbin of the bug, which notably has nothing to do with angular-leaflet-directive. http://jsbin.com/kusexa/1/edit

If you upgrade the version of angular in the jsbin to 1.3.3, the problem disappears. Since it's not actually related to this project, I will close this request.

@tombatossals
Copy link
Owner

Thanks so much for reporting and share your conclusions.

@khfayzullaev
Copy link
Contributor

@wylieconlon With AngularJS v.1.3.6, I still see this issue. Any ideas?

@wylieconlon
Copy link
Author

@khfayzullaev I'm not sure, my issue was fixed completely because of the fix contained in angular/angular.js#9281

@khfayzullaev
Copy link
Contributor

@wylieconlon @tombatossals Using this 380b039 solved my issue. Basically, it seems that leafletData.getMap() guarantees that the map is deleted once! Or can we just listen for element.on($destroy)? Like:

element.on('$destroy', function() {
    map.remove();
    leafletData.unresolveMap(attrs.id);
});

It is triggered when the map is removed from the DOM. And we are not creating any new scope in the directive, so we do not have to worry about that.

@tombatossals
Copy link
Owner

👍 Totally right, thanks @khfayzullaev

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

Successfully merging this pull request may close these issues.

3 participants