You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to make sure no-one else has to chase down this issue.
I'm not sure that I can quite explain the exact circumstances that phx-remove will fire/not fire, but I think that making sure the parent has a DOM ID is a good practice to make sure you don't have any problems.
I'm not sure if this is a good clarification. phx-remove is a bit tricky, since it is only executed when morphdom decides to remove a node and that node also has phx-remove set. This means that:
a node that is updated into another one is not removed, therefore phx-remove is not called:
We might say that we removed the B node and added a D node, but for morphdom it would be an update of the innerText of the second child from B to C and the third child from C to D. A good way to ensure that nodes are discarded is to give them unique IDs:
If we now update this to A, C, D, morphdom would be forced to remove B.
phx-remove is only called on the removed element, not on children. So even when we have the example from above, if the whole <ul> is removed, phx-remove on an individual <li> would not be called.
Do you have a code example for the case you described?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
I would like to make sure no-one else has to chase down this issue.
I'm not sure that I can quite explain the exact circumstances that phx-remove will fire/not fire, but I think that making sure the parent has a DOM ID is a good practice to make sure you don't have any problems.