Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

actually warn, don't raise on duplicate ids in LiveViewTest #3603

Merged
merged 1 commit into from
Dec 26, 2024

Conversation

SteffenDE
Copy link
Collaborator

@SteffenDE SteffenDE commented Dec 26, 2024

Relates to #3588.
Relates to: #3560.

cc @josevalim

"""
else
detect_duplicate_ids(children, MapSet.put(ids, id))
""")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to pass [] as second argument? We don't have a useful stacktrace here, do we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly no good stacktrace. Changed!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, at least it contains the test, so maybe we should keep it?

warning: Duplicate id found while testing LiveView: foo

    <div id="foo"></div>


LiveView requires that all elements have unique ids, duplicate IDs will cause
undefined behavior at runtime, as DOM patching will not be able to target the correct
elements.

  (phoenix_live_view 1.0.1) lib/phoenix_live_view/test/dom.ex:47: Phoenix.LiveViewTest.DOM.detect_duplicate_ids/2
  (phoenix_live_view 1.0.1) lib/phoenix_live_view/test/dom.ex:36: Phoenix.LiveViewTest.DOM.detect_duplicate_ids/2
  (phoenix_live_view 1.0.1) lib/phoenix_live_view/test/dom.ex:28: Phoenix.LiveViewTest.DOM.parse/1
  test/phoenix_live_view/test/dom_warn_test.exs:10: Phoenix.LiveViewTest.DOMWarnTest."test parse detects duplicate ids"/1
  (ex_unit 1.19.0-dev) lib/ex_unit/runner.ex:511: ExUnit.Runner.exec_test/2
  (stdlib 6.1.2) timer.erl:590: :timer.tc/2
  (ex_unit 1.19.0-dev) lib/ex_unit/runner.ex:433: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we keep it!

@SteffenDE SteffenDE force-pushed the sd-warn-duplicate-ids-warn branch from f3ab0e5 to ea68eda Compare December 26, 2024 21:24
@SteffenDE SteffenDE force-pushed the sd-warn-duplicate-ids-warn branch from ea68eda to 84c8cbf Compare December 26, 2024 23:06
@SteffenDE SteffenDE merged commit f5c4635 into main Dec 26, 2024
14 checks passed
@SteffenDE SteffenDE deleted the sd-warn-duplicate-ids-warn branch December 26, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants