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

Elm.embed should accept a div with children. #47

Closed
laszlopandy opened this Issue Dec 13, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@laszlopandy
Contributor

laszlopandy commented Dec 13, 2014

Currently if you try to embed Elm on a div with children it fails with:
Error: Elm.node must be given an empty DIV. No children allowed!

However there is a valid use case when this should be allowed. I am porting a mobile web app from React, which needs to start up as quickly as possible. My React version did something like this:

<div id='react_container'>
    <div class="spinner">
        <div class="bounce1"></div>
        <div class="bounce2"></div>
        <div class="bounce3"></div>
    </div>
</div>
<script src="myapp.js"></script>
<script>
React.renderComponent(MyApp(), document.getElementById('react_container'));
</script>

The spinner div has some CSS animation applied to it, and starts animating immediately while the scripts are loading. Once React has booted up, the first render will replace the children (including spinner) with the real app (or with the same spinner div if the app is still waiting for data). This is a very useful way to lower the perceived loading time.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Dec 14, 2014

Member

Makes sense. Is the intended behavior that instantiating the component destroys all the existing children?

Member

evancz commented Dec 14, 2014

Makes sense. Is the intended behavior that instantiating the component destroys all the existing children?

@laszlopandy

This comment has been minimized.

Show comment
Hide comment
@laszlopandy

laszlopandy Dec 14, 2014

Contributor

Yes, on the first render the component should delete all children.

On Sunday, December 14, 2014, Evan Czaplicki notifications@github.com
wrote:

Makes sense. Is the intended behavior that instantiating the component
destroys all the existing children?


Reply to this email directly or view it on GitHub
https://github.com/elm-lang/core/issues/47#issuecomment-66899024.

Contributor

laszlopandy commented Dec 14, 2014

Yes, on the first render the component should delete all children.

On Sunday, December 14, 2014, Evan Czaplicki notifications@github.com
wrote:

Makes sense. Is the intended behavior that instantiating the component
destroys all the existing children?


Reply to this email directly or view it on GitHub
https://github.com/elm-lang/core/issues/47#issuecomment-66899024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment