Skip to content

Commit

Permalink
perf: optimize isHydrating (#2562)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Nov 3, 2021
1 parent 4420492 commit 8e9c84d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/@lwc/engine-core/src/framework/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type HostElement = any;

export interface Renderer<N = HostNode, E = HostElement> {
ssr: boolean;
readonly isHydrating: boolean;
isHydrating(): boolean;
isNativeShadowDefined: boolean;
isSyntheticShadowDefined: boolean;
insert(node: N, parent: E, anchor: N | null): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/engine-core/src/framework/stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function createStylesheet(vm: VM, stylesheets: string[]): VNode | null {
for (let i = 0; i < stylesheets.length; i++) {
renderer.insertGlobalStylesheet(stylesheets[i]);
}
} else if (renderer.ssr || renderer.isHydrating) {
} else if (renderer.ssr || renderer.isHydrating()) {
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
// This works in the client, because the stylesheets are created, and cached in the VM
// the first time the VM renders.
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/engine-dom/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function setIsHydrating(v: boolean) {

export const renderer: Renderer<Node, Element> = {
ssr: false,
get isHydrating(): boolean {
isHydrating(): boolean {
return isHydrating;
},

Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/engine-server/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HTMLElement {

export const renderer: Renderer<HostNode, HostElement> = {
ssr: true,
get isHydrating(): boolean {
isHydrating(): boolean {
return false;
},

Expand Down

0 comments on commit 8e9c84d

Please sign in to comment.