Skip to content

Commit b59bede

Browse files
committed
Fix undefined LiveComponent statics reference.
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
1 parent 524ce5e commit b59bede

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/phoenix_live_view/diff.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,11 @@ defmodule Phoenix.LiveView.Diff do
871871
case :maps.next(iterator) do
872872
{_, cid, iterator} ->
873873
case old_cids do
874-
%{^cid => {_, _, _, _, {^print, _} = tree}} ->
874+
# if a component is marked for deletion, we cannot share its statics since it may be removed
875+
%{^cid => {_, _, _, %{@marked_for_deletion => true}, {^print, _} = _tree}} ->
876+
find_same_component_print(print, iterator, old_cids, new_cids, attempts - 1)
877+
878+
%{^cid => {_, _, _, _private, {^print, _} = tree}} ->
875879
{-cid, tree}
876880

877881
%{} ->

0 commit comments

Comments
 (0)