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

Document fragments in template! macro #52

Closed
3 tasks
lukechu10 opened this issue Mar 24, 2021 · 0 comments · Fixed by #89
Closed
3 tasks

Document fragments in template! macro #52

lukechu10 opened this issue Mar 24, 2021 · 0 comments · Fixed by #89
Assignees
Labels
A-ergonomics Area: API ergonomics A-macro Area: macros C-bug Category: bug, something isn't working C-enhancement Category: new feature or improvement to existing feature
Milestone

Comments

@lukechu10
Copy link
Member

lukechu10 commented Mar 24, 2021

Describe the solution you'd like
The template! macro should allow document fragments without the <></> JSX syntax.
The following should be accepted by the template! macro:

// multiple children
template! {
    p { ... }
    a { ... }
};

// empty fragment
template! {}

The TemplateResult struct should be converted into an enum with the variants Single and List where the second variant is used for document fragments (including empty fragments). This should not use the DocumentFragment under the hood as it behaves somewhat differently from Nodes. For one thing, when appending a DocumentFragment to the DOM, the elements are moved out of the fragment and no longer accessible. Instead, TemplateResult::List should use a Vec or other collection under the hood.

Questionnaire

  • I would like to implement this feature but I don't know where to start
  • I would like to implement this feature and I have a solution
  • I don't have time to implement this / I don't want to implement this

Edit
The current way Keyed and Indexed are a bit buggy. They return DocumentFragments which, as described above, have certain differences from other html nodes. This results in a panic when updating Keyed and Indexed at the top level of a template!, e.g.

template! {
    Keyed {..} // panics when iterable is updated
}
@lukechu10 lukechu10 added C-enhancement Category: new feature or improvement to existing feature A-macro Area: macros A-ergonomics Area: API ergonomics difficulty: some labels Mar 24, 2021
@lukechu10 lukechu10 self-assigned this Mar 24, 2021
@lukechu10 lukechu10 added the C-bug Category: bug, something isn't working label Mar 26, 2021
@lukechu10 lukechu10 added this to the 0.5 milestone Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ergonomics Area: API ergonomics A-macro Area: macros C-bug Category: bug, something isn't working C-enhancement Category: new feature or improvement to existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant