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

use other selector syntax in by_id (fixes #3144) #3145

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

SteffenDE
Copy link
Collaborator

Fixes #3144

@SteffenDE SteffenDE marked this pull request as draft March 1, 2024 17:33
@SteffenDE
Copy link
Collaborator Author

Waiting for philss/floki#548.

@philss
Copy link

philss commented Mar 1, 2024

@SteffenDE the new feature (from your PR) is available in Floki v0.36 now :)

@SteffenDE SteffenDE marked this pull request as ready for review March 1, 2024 21:46
@SteffenDE
Copy link
Collaborator Author

@josevalim I added a TODO to change by_id! as well, but I'm not sure because the current implementation raises when multiple elements are found, while Floki.get_by_id/2 just returns the first one:

many ->
{:error, :many,
"expected #{type} #{inspect(selector)} to return a single element, " <>
"but got #{length(many)}: \n\n" <> inspect_html(many)}

Let me know what you think.

@josevalim
Copy link
Member

So ironically we also needed a find_by_id? :D I am fine with dropping the by_id! but maybe we should get @chrismccord's opinion.

@SteffenDE
Copy link
Collaborator Author

There's one test that relies on it:

  1) test raises on duplicate child LiveView id (Phoenix.LiveView.NestedTest)
     test/phoenix_live_view/integrations/nested_test.exs:137
     Expected to catch exit, got nothing
     code: assert Exception.format(:exit, catch_exit(render(view))) =~
     stacktrace:
       test/phoenix_live_view/integrations/nested_test.exs:147: (test)

@josevalim
Copy link
Member

Yeah, we would have to nuke it, but that’s fine. We do the check for the users convenience.

@josevalim josevalim merged commit 0c16677 into phoenixframework:main Mar 4, 2024
5 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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.

Combining div with ID containing '?' and phx-update="ignore" throughs Floki error
3 participants