-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
defer-hydration
to ssr renderer (#6492)
* yield defer-hydration attribute when configured * Make defer-hydration the default behavior, fixing tests * adding disable deferHydration test * update readme * update config comments * fixing documentation * Change files * update API report * make deferHydration false by default Co-authored-by: nicholasrice <nicholasrice@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
123 additions
and
24 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-ssr-749d9ba6-9033-4475-8641-55e0cd3b14cc.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Adds `defer-hydration` attribute emission during rendering", | ||
"packageName": "@microsoft/fast-ssr", | ||
"email": "nicholasrice@users.noreply.github.com", | ||
"dependentChangeType": "prerelease" | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { | ||
Compiler, | ||
ElementController, | ||
ElementStyles, | ||
Updates, | ||
ViewBehaviorFactory, | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
import "./install-dom-shim.js"; | ||
import fastSSR from "./exports.js"; | ||
import { test, expect } from "@playwright/test"; | ||
import { uniqueElementName } from "@microsoft/fast-element/testing"; | ||
import { FASTElement } from "@microsoft/fast-element"; | ||
import { consolidate } from "./test-utilities/consolidate.js"; | ||
|
||
|
||
test.describe("fastSSR default export", () => { | ||
test("should return a TemplateRenderer configured to create a RenderInfo object using the returned ElementRenderer", () => { | ||
const { templateRenderer, ElementRenderer } = fastSSR(); | ||
expect(templateRenderer.createRenderInfo().elementRenderers.includes(ElementRenderer)).toBe(true) | ||
}) | ||
|
||
test("should render FAST elements without the `defer-hydration` attribute by default", () => { | ||
const { templateRenderer } = fastSSR(); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name}><template shadowroot="open"></template></${name}>`) | ||
}); | ||
test("should render FAST elements with the `defer-hydration` attribute when deferHydration is configured to be true", () => { | ||
const { templateRenderer } = fastSSR({deferHydration: true}); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name} defer-hydration><template shadowroot="open"></template></${name}>`) | ||
}); | ||
test("should not render FAST elements with the `defer-hydration` attribute when deferHydration is configured to be false", () => { | ||
const { templateRenderer } = fastSSR({deferHydration: false}); | ||
const name = uniqueElementName(); | ||
FASTElement.define(name); | ||
|
||
expect(consolidate(templateRenderer.render(`<${name}></${name}>`))).toBe(`<${name}><template shadowroot="open"></template></${name}>`) | ||
}); | ||
}); |
This file contains 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
This file contains 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