This repository was archived by the owner on Feb 10, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Upgrade to LiveView 1.1 #243
Open
pinetops
wants to merge
11
commits into
liveview-native:main
Choose a base branch
from
pinetops:fix-template-position-collision
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5ce723f
Upgrade to Phoenix LiveView 1.1
pinetops 974458d
Add Phoenix LiveView 1.1 API compatibility
pinetops 4db77c1
Fix template position collision in diff merging
pinetops 8e1809b
Reverted unnecessary change to client proxy
pinetops 6735db1
Reverted unnecessary change to client proxy
pinetops d23ca82
Add diff merge tests and improve keyed comprehension handling
pinetops 3fbc055
Achieve full test parity with Phoenix LiveView 1.1
pinetops fb23ccd
Remove override flag from phoenix_live_view dependency
pinetops 594adde
Match tests more closely
pinetops f4b3b71
Match LV structure better
pinetops 917fbe8
Some missed changes 1.1.0 -> 1.1.14
pinetops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| defmodule LiveViewNative.DiffTest do | ||
| use ExUnit.Case, async: true | ||
|
|
||
| alias LiveViewNativeTest.ViewTree | ||
|
|
||
| defstruct [:foo] | ||
|
|
||
| describe "merge_diff" do | ||
| test "merges unless static" do | ||
| assert ViewTree.merge_diff(%{0 => "bar", s: "foo"}, %{0 => "baz"}) == | ||
| %{0 => "baz", s: "foo", streams: []} | ||
|
|
||
| assert ViewTree.merge_diff(%{s: "foo", d: []}, %{s: "bar"}) == | ||
| %{s: "bar", streams: []} | ||
| end | ||
|
|
||
| test "resolves moved comprehensions" do | ||
| base = %{ | ||
| k: %{ | ||
| 0 => %{0 => "A"}, | ||
| 1 => %{0 => "B"}, | ||
| 2 => %{0 => "C", 1 => %{0 => "var1", :s => ["", ""]}}, | ||
| kc: 3 | ||
| } | ||
| } | ||
|
|
||
| diff = %{ | ||
| k: %{ | ||
| 0 => 1, | ||
| 1 => [2, %{1 => %{0 => "var2"}}], | ||
| kc: 2 | ||
| } | ||
| } | ||
|
|
||
| result = %{ | ||
| k: %{ | ||
| 0 => %{0 => "B"}, | ||
| 1 => %{0 => "C", 1 => %{0 => "var2", :s => ["", ""]}}, | ||
| kc: 2 | ||
| }, | ||
| streams: [] | ||
| } | ||
|
|
||
| assert ViewTree.merge_diff(base, diff) == result | ||
| end | ||
|
|
||
| test "no warning when keyed count is 0" do | ||
| base = %{ | ||
| k: %{ | ||
| 0 => %{0 => "A"}, | ||
| 1 => %{0 => "B"}, | ||
| 2 => %{0 => "C", 1 => %{0 => "var1", :s => ["", ""]}}, | ||
| :kc => 3 | ||
| } | ||
| } | ||
|
|
||
| diff = %{ | ||
| k: %{kc: 0} | ||
| } | ||
|
|
||
| result = %{ | ||
| k: %{kc: 0}, | ||
| streams: [] | ||
| } | ||
|
|
||
| assert ViewTree.merge_diff(base, diff) == result | ||
| end | ||
|
|
||
| test "ignores structs when resolving templates" do | ||
| assert ViewTree.merge_diff(%{0 => %{}}, %{ | ||
| 0 => %{:s => 1, 0 => %__MODULE__{foo: :bar}}, | ||
| :p => %{1 => ["foo", "bar"]} | ||
| }) == %{0 => %{0 => %__MODULE__{foo: :bar}, :s => ["foo", "bar"]}, :streams => []} | ||
| end | ||
|
|
||
| test "copies streams" do | ||
| base = %{ | ||
| k: %{ | ||
| 0 => %{0 => "A"}, | ||
| 1 => %{0 => "B"}, | ||
| 2 => %{0 => "C", 1 => %{0 => "var1", :s => ["", ""]}}, | ||
| kc: 3 | ||
| }, | ||
| stream: "foo" | ||
| } | ||
|
|
||
| diff = %{ | ||
| k: %{ | ||
| 0 => 1, | ||
| 1 => [2, %{1 => %{0 => "var2"}}], | ||
| kc: 2 | ||
| }, | ||
| stream: "bar" | ||
| } | ||
|
|
||
| result = %{ | ||
| k: %{ | ||
| 0 => %{0 => "B"}, | ||
| 1 => %{0 => "C", 1 => %{0 => "var2", :s => ["", ""]}}, | ||
| kc: 2 | ||
| }, | ||
| stream: "bar", | ||
| streams: ["bar"] | ||
| } | ||
|
|
||
| assert ViewTree.merge_diff(base, diff) == result | ||
| end | ||
| end | ||
| end |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the override?