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

Allow multiple elements in root with Fragments #118

Merged
merged 7 commits into from
Dec 13, 2018

Conversation

finnp
Copy link
Contributor

@finnp finnp commented Mar 16, 2018

This will allow

html`
  <div>Hallo</div>
  <div>Welt</div>
`

This will return a DocumentFragment with the children <div>Hello</div> and <div>Welt</div>

Also see choojs/hyperx#65
Depends on choojs/hyperx#66

  • browser
  • babel
  • server
  • transform

@finnp finnp changed the title WIP: Allow multiple elements in root with Fragments Allow multiple elements in root with Fragments Mar 20, 2018
@bcomnes
Copy link
Collaborator

bcomnes commented Mar 20, 2018

Does this work?

html`
<div>
${() => {
  return html`
    <div>Hallo</div>
    <div>Welt</div>
  `
  }()}
</div>
`

Or do you have to move the contents of the fragment out of the fragment?

@finnp
Copy link
Contributor Author

finnp commented Mar 20, 2018

@bcomnes Yes this should work. When doing div.appendChild(fragment) the fragment will be discarded. So the div will have the two children <div>Hallo</div> and <div>Welt</div>

@AndyOGo
Copy link
Contributor

AndyOGo commented Mar 22, 2018

I really like this 👍

@finnp
Copy link
Contributor Author

finnp commented Dec 8, 2018

@goto-bus-stop I've seen that you merged the createFragment PR on hyperx. I've updated this PR to the latest master. Do you want to merge this in? I could also add something for the documentation.

@goto-bus-stop
Copy link
Member

yea a docs example would be nice!

@finnp
Copy link
Contributor Author

finnp commented Dec 11, 2018

@goto-bus-stop I added a section for this. Tried to add a nice explanation, but couldn't come up with any. I think it works this way though. What do you think?

@goto-bus-stop goto-bus-stop merged commit 39831aa into choojs:master Dec 13, 2018
@finnp finnp deleted the fragments branch December 13, 2018 19:25
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.

4 participants