Skip to content

Live components: A html comment before the first static html element gives an error #4144

@Terbium-135

Description

@Terbium-135

Environment

  • Elixir version (please paste the output of elixir -v):
Erlang/OTP 28 [erts-16.1.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]
Elixir 1.20.0-rc.1 (3bb5f92) (compiled with Erlang/OTP 28)
  • Phoenix and LiveView versions (mix deps | grep -w 'phoenix\|phoenix_live_view'):
* phoenix 1.8.3 (https://github.com/phoenixframework/phoenix.git) (mix)
* phoenix_live_view 1.2.0-dev (https://github.com/phoenixframework/phoenix_live_view.git) (mix)
  • Operating system:
  • Windows
  • MacOS
  • Linux
  • Other (please specify):

Actual behavior

def render(assigns) do
  ~H"""
  <%!-- This comment gives an error <div class="flex justify-center"> --%>
  <div class="flex justify-center">
  </div>
  """
end

Having a HTML comment before the first static element in a live component gives:

(ArgumentError) error on BackendWeb.Components.MultiSelectComponent.render/1 with id of "nuts". Stateful components must have a single static HTML tag at the root

Expected behavior

Comments are ignored and no error is triggered

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions