Remove special treatment for HTMLTemplateElement#76
Draft
seanpdoyle wants to merge 2 commits intogithub:mainfrom
Draft
Remove special treatment for HTMLTemplateElement#76seanpdoyle wants to merge 2 commits intogithub:mainfrom
HTMLTemplateElement#76seanpdoyle wants to merge 2 commits intogithub:mainfrom
Conversation
seanpdoyle
commented
Dec 13, 2024
src/processors.ts
Outdated
| 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)) |
Contributor
Author
There was a problem hiding this comment.
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.
e1a8a09 to
34c3e25
Compare
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.
34c3e25 to
2c723d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that
InnerTemplatePartexists, the Node walker should yield instances ofInnerTemplatePartinstead of collecting nested<template>elements based on their attributes.Consumers are free to override the
TemplateInstanceprocessor to handle<template>elements in whichever way they please, while still being able to fall back to the built-in behavior.