Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Accept Node values as Template Parts #73

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

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Dec 9, 2024

Related to github/template-parts#62 (see 3.2. Template Parts and Custom Template Process Callback)
Follow-up to github/template-parts#65

While the changes made in github/template-parts#65 improved support for Element parts, the expansion from string to Element | string was not broadened enough. While all Element instances are DOM Nodes, not all DOM Nodes are Element instances.

For example, this change enables support for DocumentFragment instances (generated from classes like Range or properties like HTMLTemplateElement.content), where prior support resulted in templating the [object DocumentFragment] text string instead of the fragment's Node instances.

Related to [github#62][] (see [3.2. Template Parts and Custom Template Process Callback][])
Follow-up to [github#65][]

While the changes made in [github#65][] improved support for `Element` parts,
the expansion from `string` to `Element | string` was not broadened
enough. While all `Element` instances are DOM Nodes, not all DOM Nodes
are `Element` instances.

For example, this change enables support for [DocumentFragment][]
instances (generated from classes like [Range][] or properties like
[HTMLTemplateElement.content][]), where prior support resulted in
templating the `[object DocumentFragment]` text string instead of the
fragment's `Node` instances.

[github#62]: github#62
[3.2. Template Parts and Custom Template Process Callback]: https://github.com/WICG/webcomponents/blob/159b1600bab02fe9cd794825440a98537d53b389/proposals/Template-Instantiation.md#32-template-parts-and-custom-template-process-callback
[github#65]: github#65
[DocumentFragment]: https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment
[HTMLTemplateElement.content]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/content
Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff. Keep up the awesome patches!

@keithamus keithamus merged commit 0678eb7 into github:main Dec 9, 2024
@seanpdoyle seanpdoyle deleted the accept-node-template-parts branch December 13, 2024 21:57
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.

2 participants