Skip to content

Commit

Permalink
code docs
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Oct 7, 2024
1 parent 7904713 commit f907646
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/hydrate/runner/window-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { STENCIL_DOC_DATA } from 'src/runtime/runtime-constants';
import type * as d from '../../declarations';
import { runtimeLogging } from './runtime-log';

const docData = {
/**
* Maintain a unqiue `docData` object across multiple hydration runs
* to ensure that host ids remain unique.
*/
const docData: d.DocData = {
hostIds: 0,
rootLevelIds: 0,
staticComponents: new Set<string>(),
Expand Down Expand Up @@ -65,9 +69,6 @@ export function initializeWindow(

runtimeLogging(win, opts, results);

/**
* apply the hydrate host id so that
*/
(doc as d.StencilDocument)[STENCIL_DOC_DATA] = docData;

return win;
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/vdom/vdom-annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import { insertBefore } from './vdom-render';
*/
export const insertVdomAnnotations = (doc: Document, staticComponents: string[]) => {
if (doc != null) {
/**
* Initiated `docData` object from the document if it exists to ensure we
* maintain the same `docData` object across multiple hydration hydration runs.
*/
const docData: d.DocData = STENCIL_DOC_DATA in doc ? (doc[STENCIL_DOC_DATA] as d.DocData) : { ...DEFAULT_DOC_DATA };
docData.staticComponents = new Set(staticComponents);
const orgLocationNodes: d.RenderNode[] = [];
Expand Down

0 comments on commit f907646

Please sign in to comment.