diff --git a/lib/phoenix_live_view/test/dom.ex b/lib/phoenix_live_view/test/dom.ex index 6344708bc0..9064f7dde6 100644 --- a/lib/phoenix_live_view/test/dom.ex +++ b/lib/phoenix_live_view/test/dom.ex @@ -37,6 +37,9 @@ defmodule Phoenix.LiveViewTest.DOM do detect_duplicate_ids(rest, ids) end + # ignore declarations + defp detect_duplicate_ids({:pi, _type, _attrs}, seen_ids), do: seen_ids + defp detect_duplicate_ids({_tag_name, _attrs, children} = node, ids) do case Floki.attribute(node, "id") do [id] -> diff --git a/test/phoenix_live_view/test/dom_test.exs b/test/phoenix_live_view/test/dom_test.exs index aa1d48143d..142eefaa43 100644 --- a/test/phoenix_live_view/test/dom_test.exs +++ b/test/phoenix_live_view/test/dom_test.exs @@ -292,4 +292,24 @@ defmodule Phoenix.LiveViewTest.DOMTest do %{s: "bar", streams: []} end end + + describe "parse" do + test "detects duplicate ids" do + assert_raise RuntimeError, fn -> + DOM.parse(""" +