Add data-elm attributes to prerendered HTML for virtualization #519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followup on #512.
In the latest version of my fork of elm/virtual-dom, I add
data-elm
to all elements created by Elm, which means that elm-pages is going to render them as for example<div data-elm other-attribute="stuff">
. I don’t renderdata-elm
client-side, though, to avoid cluttering the browser dev tools.Marking the elements created by Elm with
data-elm
is needed for better virtualization. Only text nodes, and elements withdata-elm
, are virtualized. This allows for example third-party scripts to insert extra elements in<body>
while the Elm JS is loading, without having Elm blow those elements away when it initializes.Two of the elements rendered by Elm via elm-pages (the
data-url
element, and thearia-live
announcer) are hardcoded-ly rendered on the server, so there we need to adddata-url
manually. That’s what this PR does.Without
data-elm
on those two elements, we end up with twodata-url
divs, and twoaria-live
announcers, on the page (the original ones from the HTML, that Elm then ignores, and new ones rendered by Elm client-side).