Skip to content

Commit

Permalink
fix: add support for hiding instances
Browse files Browse the repository at this point in the history
  • Loading branch information
trezy committed Jul 7, 2024
1 parent 52e6b42 commit 6b268b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getInstanceFromNode } from '../helpers/getInstanceFromNode.js';
import { getInstanceFromScope } from '../helpers/getInstanceFromScope.js';
import { getPublicInstance } from '../helpers/getPublicInstance.js';
import { getRootHostContext } from '../helpers/getRootHostContext.js';
import { hideInstance } from '../helpers/hideInstance.js';
import { insertBefore } from '../helpers/insertBefore.js';
import { prepareForCommit } from '../helpers/prepareForCommit.js';
import { preparePortalMount } from '../helpers/preparePortalMount.js';
Expand All @@ -25,6 +26,7 @@ import { prepareUpdate } from '../helpers/prepareUpdate.js';
import { removeChild } from '../helpers/removeChild.js';
import { resetAfterCommit } from '../helpers/resetAfterCommit.js';
import { shouldSetTextContent } from '../helpers/shouldSetTextContent.js';
import { unhideInstance } from '../helpers/unhideInstance.js';

/** @typedef {import('../typedefs/HostConfig.ts').HostConfig} HostConfig */
/** @typedef {import('../typedefs/Instance.ts').Instance} Instance */
Expand Down Expand Up @@ -71,6 +73,7 @@ const reconcilerConfig = {
getInstanceFromScope,
getPublicInstance,
getRootHostContext,
hideInstance,
insertBefore,
insertInContainerBefore: insertBefore,
prepareForCommit,
Expand All @@ -82,6 +85,7 @@ const reconcilerConfig = {
resetAfterCommit,
scheduleTimeout: setTimeout,
shouldSetTextContent,
unhideInstance,
};

const reconciler = Reconciler(reconcilerConfig);
Expand Down
9 changes: 9 additions & 0 deletions src/helpers/hideInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @typedef {import('../typedefs/Instance.ts').Instance} Instance */

/**
* @param {Instance} instance
*/
export function hideInstance(instance)
{
instance.visible = false;
}
9 changes: 9 additions & 0 deletions src/helpers/unhideInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @typedef {import('../typedefs/Instance.ts').Instance} Instance */

/**
* @param {Instance} instance
*/
export function unhideInstance(instance)
{
instance.visible = true;
}

0 comments on commit 6b268b5

Please sign in to comment.