-
Notifications
You must be signed in to change notification settings - Fork 587
/
element-renderer.ts
41 lines (33 loc) · 1.28 KB
/
element-renderer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint-disable */
import { ElementRenderer, RenderInfo } from "@lit-labs/ssr";
import { FASTElement } from "@microsoft/fast-element";
import { render } from "./render";
export class FASTElementRenderer extends ElementRenderer {
public readonly element!: HTMLElement & FASTElement;
static matchesClass(ctor: typeof HTMLElement): boolean {
return ctor.prototype instanceof FASTElement;
}
connectedCallback(): void {
this.element.connectedCallback();
}
constructor(tagName: string) {
super(tagName);
this.element = new (customElements.get(this.tagName)! as typeof FASTElement &
typeof HTMLElement)();
}
*renderLight(renderInfo: RenderInfo): IterableIterator<string> {
// This is for rendering to the custom element's host DOM instead of
// to a shadow-root attached to the host element. no-op this for now.
}
*renderShadow(renderInfo: RenderInfo): IterableIterator<string> {
const { $fastController } = this.element;
yield* render($fastController.getShadowRoot()!, renderInfo);
}
attributeChangedCallback(
name: string,
old: string | null,
value: string | null
): void {
this.element.attributeChangedCallback(name, old!, value!);
}
}