Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

Now that InnerTemplatePart exists, the Node walker should yield instances of InnerTemplatePart instead of collecting nested <template> elements based on their attributes.

Consumers are free to override the TemplateInstance processor to handle <template> elements in whichever way they please, while still being able to fall back to the built-in behavior.

@seanpdoyle seanpdoyle requested a review from a team as a code owner December 13, 2024 16:36
part.value = value instanceof Node ? value : String(value)
export function processPropertyIdentity(part: TemplatePart, value: unknown, state: unknown): void {
if (part instanceof InnerTemplatePart) {
part.template.content.replaceChildren(new TemplateInstance(part.template, state))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the weight-bearing portion of this diff.

I don't like how much is going on in this line, I wish it were conceptually simpler.

Also, the current type signatures don't afford consumers to forward along their processor, so the default behavior wouldn't work for consumers that rely on propertyIdentityOrBooleanAttribute behavior instead of (the default) propertyIdentity behavior.

I'm exploring a more flexible change.

@seanpdoyle seanpdoyle marked this pull request as draft December 13, 2024 17:05
@seanpdoyle seanpdoyle force-pushed the inner-template-part-custom-processing branch 2 times, most recently from e1a8a09 to 34c3e25 Compare December 13, 2024 17:58
Now that `InnerTemplatePart` exists, the Node walker should yield
instances of `InnerTemplatePart` instead of collecting nested
`<template>` elements based on their attributes.

Consumers are free to override the `TemplateInstance` processor to
handle `<template>` elements in whichever way they please, while still
being able to fall back to the built-in behavior.
@seanpdoyle seanpdoyle force-pushed the inner-template-part-custom-processing branch from 34c3e25 to 2c723d4 Compare December 15, 2024 16:17
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.

1 participant