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

Template tags don't compile into a proper DocumentFragment #1169

Closed
bitingmidge opened this issue Oct 22, 2018 · 1 comment
Closed

Template tags don't compile into a proper DocumentFragment #1169

bitingmidge opened this issue Oct 22, 2018 · 1 comment
Labels
ionitron: stale issue This issue has not seen any activity for a long period of time

Comments

@bitingmidge
Copy link

Stencil version:

 @stencil/core@0.14.1

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

When using a <template> tag inside of a component, the template's content gets created as a a sibling of the #document-fragment instead of as a child. As a result, you cannot attach the <template> content somewhere else in the DOM.

Below is a console screenshot of what (1) the <template> object should look like and (2) what it looks like in the component that Stencil has compiled.

screenshot 2018-10-22 13 33 40

Expected behavior:

The content inside of a <template> tag doesn't get rendered to the screen but instead creates a DocumentFragment that can be attached elsewhere in the DOM using javascript. This would allow you to create some content inside of a component that could then be dynamically rendered somewhere else in the DOM outside of the component. Sort of the opposite idea of passing in dynamic content and placing it using a <slot> tag in your JSX.

Steps to reproduce:

The result will be:

  • A grey block of standard component content (nothing special here, this works as you would expect)
  • There should be a yellow block of content next but it isn't there because of the bug
  • A cyan block of content that is coming from a <template> tag in the index.html file (just to prove that it can work when the DocumentFragment is formed properly).

To monkey patch it:

Related code:
This is the monkey patch that just makes a rough copy of the sibling node and copies it as a child node of the DocumentFragment:

_fixupTemplate() {
    var frag: DocumentFragment = this.template.content
    frag.appendChild(this.template.firstChild.cloneNode(true))
  }

Other information:

@ionitron-bot ionitron-bot bot added the triage label Oct 22, 2018
@ionitron-bot ionitron-bot bot added the ionitron: stale issue This issue has not seen any activity for a long period of time label Nov 22, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 22, 2018

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil!

@ionitron-bot ionitron-bot bot closed this as completed Nov 22, 2018
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ionitron: stale issue This issue has not seen any activity for a long period of time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants