-
Notifications
You must be signed in to change notification settings - Fork 1k
[lit-html][labs/ssr-client] Fix compiled template support #3993
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
Conversation
This commit fixes the type of `isTemplateResult` to return the correct type as the current implementation: a `TemplateResult` and a `CompiledTemplateResult`. Then I fixed the cache directive to work with both template types, and hydration to only work with uncompiled templates. Added a unit test for the compiled template case with the cache directive. An alternative I considered: - Make `isTemplateResult` stricter such that the type is only a `TemplateResult`. That is technically a breaking change (although people should not be depending on `CompiledTemplateResult`s) - And add the following helpers: `isCompiledTemplateResult` and `getTemplateStringsArray`.
🦋 Changeset detectedLatest commit: 089e81a The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
rictic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
augustjk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to push back on any requested changes.
|
I added two more small cleanup commits. 1. Use the PTAL |
ffefb27 to
089e81a
Compare
Change is an independent part of #3984
Summary
Fix
isTemplateResultreturn type to includeCompiledTemplateResults, and then fix locations inlitthat didn't handleCompiledTemplates. Primarily thecachedirective.Changes
isTemplateResultto return the correct type (as per current implementation): aTemplateResultor aCompiledTemplateResult.hydrationandexperimental-hydrationdo not work with compiled templates by making the check more strict. Maybe could add a dev mode error?isTemplateResulttype tests.Considerations
I marked this as a minor change, however it is a breaking change in terms of TypeScript types. The return type of
isTemplateResultwithout a second argument now has an additional consideration and could break users ofisTemplateResult. However the type now more truthfully conveys whatisTemplateResultis asserting.Alternative considered:
isTemplateResultstricter such that the type is only aTemplateResult. A breaking change (although people should realistically not be depending onCompiledTemplateResults yet)isCompiledTemplateResultto check for CompiledTemplates, andgetTemplateStringsArrayto generically retrieve the template strings array from either a compiled or uncompiled template result.Test plan
Unit tests and type only tests added.