-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngMessages): prevent race condition with ngAnimate #12903
Conversation
@petebacondarwin - this fixes the issues of destroying/removing the appropriate node(s). Should we also think about reusing node elements that will be destroyed and re-added? Perhaps this is an optimization that is not worth the complexity? |
So we are currently reusing the message controller objects but not the message nodes. This was the main cause for the problem since we would associate both the node that was being removed and the node that was being added with the same message controller object. The trouble is that the old node has been already scheduled for removal ("leave") via |
@petebacondarwin Just tested and this does appear to fix the issue in material. Thanks so much! |
@petebacondarwin - thx for the explanation. |
@matsko can you cast your eye over this fix before I merge, please? |
If `ngMessage` tried to add a message back in that was about to be removed after an animation, the NgMessageController got confused and tried to detach the newly added message, when the pending node was destroyed. This change applies a unique `attachId` to the message object and its DOM node when it is attached. This is then checked when a DOM node is being destroyed to prevent unwanted calls to `detach`. Closes angular#12856 Closes angular#12903
fc82c49
to
8366622
Compare
If `ngMessage` tried to add a message back in that was about to be removed after an animation, the NgMessageController got confused and tried to detach the newly added message, when the pending node was destroyed. This change applies a unique `attachId` to the message object and its DOM node when it is attached. This is then checked when a DOM node is being destroyed to prevent unwanted calls to `detach`. Closes #12856 Closes #12903
Cherry-picked to 1.4.x too |
If
ngMessage
tried to add a message back in that was about to be removedafter an animation, the NgMessageController got confused and tried to detach
the newly added message, when the pending node was destroyed.
This change applies a unique
attachId
to the message object and its DOMnode when it is attached. This is then checked when a DOM node is being
destroyed to prevent unwanted calls to
detach
.Closes #12856