Skip to content

Commit

Permalink
Fix undefined LiveComponent statics reference.
Browse files Browse the repository at this point in the history
When we share a statics from a LiveComponent with matching
fingerprint, we must ensure we don't share statics for a
component that has been marked for deletion by the client,
since the component may be removed by the client and the diff
about to be sent will contain a reference to the now undefined
statics. Continue down the tree to find other shared statics, or
fallback to generating own statics
  • Loading branch information
chrismccord committed Oct 24, 2024
1 parent 524ce5e commit b59bede
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/phoenix_live_view/diff.ex
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,11 @@ defmodule Phoenix.LiveView.Diff do
case :maps.next(iterator) do
{_, cid, iterator} ->
case old_cids do
%{^cid => {_, _, _, _, {^print, _} = tree}} ->
# if a component is marked for deletion, we cannot share its statics since it may be removed
%{^cid => {_, _, _, %{@marked_for_deletion => true}, {^print, _} = _tree}} ->
find_same_component_print(print, iterator, old_cids, new_cids, attempts - 1)

%{^cid => {_, _, _, _private, {^print, _} = tree}} ->
{-cid, tree}

%{} ->
Expand Down

0 comments on commit b59bede

Please sign in to comment.