feat: Prerendered content binding optimization#7456
Draft
janechu wants to merge 5 commits intoreleases/fast-element-v3from
Draft
feat: Prerendered content binding optimization#7456janechu wants to merge 5 commits intoreleases/fast-element-v3from
janechu wants to merge 5 commits intoreleases/fast-element-v3from
Conversation
Update DESIGN.md and README.md for fast-element and fast-html packages to reflect the replacement of HydratableElementController with automatic prerendered content detection in ElementController. fast-element changes: - Document isPrerendered flag on ElementController and ViewController - Document template-pending guard in connect() - Document attribute skip during initial upgrade for prerendered elements - Update FASTElement lifecycle diagram with prerendered content flow - Remove hydration.ts from package layout (consolidated into ElementController) - Add Prerendered Content Optimization section to README fast-html changes: - Remove RenderableFASTElement mixin references (components extend FASTElement directly) - Remove prepare() lifecycle hook documentation - Remove defer-hydration and needs-hydration attribute references from markup examples - Update lifecycle diagram to show ElementController instead of HydratableElementController - Update integration table to reflect new ElementController hydration path - Update RENDERING.md initial state example and hydration description - Update RENDERING_LIFECYCLE.md Phase 5 for new prerendered content flow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…plete Fire hydrationComplete via queueMicrotask after the last pending template is processed, instead of polling with requestIdleCallback. This is simpler, more portable, and deterministic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Separate prerendered and client-side render paths into a single if/else block instead of three separate isPrerendered checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Pull Request
📖 Description
Replace
HydratableElementControllerwith an automatic prerendered content optimization built intoElementController. When a component connects and already has an existing shadow root (from SSR or declarative shadow DOM), the system automatically:@click)when,repeat,ref,children,slotted)attributeandbooleanAttributebinding expressions (DOM already has correct values)No explicit configuration from component authors is required. The presence of an existing shadow root signals prerendered content.
This is a breaking change for both
@microsoft/fast-elementand@microsoft/fast-html. See the migration docs inpackages/fast-element/MIGRATION.mdandpackages/fast-html/MIGRATION.md.👩💻 Reviewer Notes
Breaking changes (
@microsoft/fast-element)Removed exports:
HydratableElementController→ useElementController(prerendered path built in)HydrationControllerCallbacks→ useTemplateElement.config()in@microsoft/fast-htmlneedsHydrationAttribute→ useElementController.isPrerenderedNew APIs:
ElementController.isPrerendered(readonly boolean) — true when an existing shadow root was detectedViewController.isPrerendered(readonly boolean?) — available to directives duringbind()Changed behavior:
ElementController.connect()adds a template-pending guard fordefineAsync()flowElementController.onAttributeChangedCallback()skips during initial upgrade when prerenderedHTMLBindingDirective.bind()skipsattribute/booleanAttributeupdateTargetcalls whencontroller.isPrerenderedViewTemplate.render()signature adds optionalisPrerenderedparameterBreaking changes (
@microsoft/fast-html)Removed exports:
RenderableFASTElement→ extendFASTElementdirectlyRemoved concepts:
prepare()lifecycle hook → set state inconnectedCallbackdefer-hydration/needs-hydrationattributes → automatic detectionwaitForAncestorHydration()→ not neededMigration
See
packages/fast-element/MIGRATION.mdandpackages/fast-html/MIGRATION.mdfor detailed migration steps.Quick summary:
RenderableFASTElement(MyComponent).defineAsync({...})withMyComponent.defineAsync({...})HydratableElementController.install()callsdefer-hydrationandneeds-hydrationfrom server-rendered markup$fastController.isPrerenderedto detect prerendered components📑 Test Plan
@microsoft/fast-elementtests pass@microsoft/fast-htmltests passisPrerenderedflag detection (CSR vs DSD) and template-pending guardmain.tsfiles updated to useFASTElementdirectly✅ Checklist
General
$ npm run change⏭ Next Steps
@microsoft/fast-build/@microsoft/fast-ssrto stop emittingdefer-hydration/needs-hydrationattributes