-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Environment
- Elixir version (elixir -v):
N/A - Phoenix version (mix deps):
Latest (release candidate):
* phoenix 1.8.0-rc.4 (Hex package) (mix)
locked at 1.8.0-rc.4 (phoenix) 754c8caf
ok
- Phoenix LiveView version (mix deps):
Latest (stable):
* phoenix_live_view 1.1.2 (Hex package) (mix)
locked at 1.1.2 (phoenix_live_view) 54b2e4a3
ok
- Operating system:
N/A - Browsers you attempted to reproduce this bug on (the more the merrier):
ChromiumandFirefox - Does the problem persist after removing "assets/node_modules" and trying again? Yes/no:
No, the directory does not exists
Actual behavior
With below code:
use Phoenix.LiveView, container: {:body, id: "example"}
there are 2 bugs:
- The empty
headis added as a first child of abodywrapper and the contents are wrapped in then 2ndbodyelement that does not have any attributes. - The
idis not set
Note: I have reproduced it also in new example app (mix phx.new example). Nothing "fancy" was added except that simplest live page, removing body from root.html.heex layout and of course adding container option.
The simplest example with mix phx.gen.live Accounts User users --no-context name:string just to quickly get a live page. Made on Firefox (to be precise zen browser that is Firefox fork).
The same page on `Chromium` just to be sure that it's not browser/web engine related bug.
In both cases in DevTools you can see a huge body tag (with a lot of attributes) that contain empty head and another body (without attributes) as described above.
Expected behavior
Setting :body as tag and id attribute are documented in Containers section | Phoenix.Component.
use Phoenix.LiveView, container: {:tr, id: "foo-bar"}
and
Beware if you set this to :body, as any content injected inside the body (such as Phoenix.LiveReload features) will be discarded once the LiveView connects
So except Phoenix.LiveReload known issue it's supposed to be fully supported, but none of those works properly. For sure other tags and their attributes (like class for example) works without a problem. I would simply like to have a semantically valid HTML5 document (with header, main, footer and other HTML5 elements) without a weird div wrapper. id is not so important as I simply can use body in CSS.