UNPKG

@dark-engine/core

Version:

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript (Browser, Node.js, Android, iOS, Windows, Linux, macOS)

27 lines (26 loc) 795 B
import { CLEANUP_HOST_MASK, EFFECT_HOST_MASK } from '../constants'; import { removeScope, $$scope } from '../scope'; import { detectIsUndefined } from '../utils'; import { platform } from '../platform'; import { walk } from '../walk'; const mask = EFFECT_HOST_MASK | CLEANUP_HOST_MASK; function unmountFiber(fiber) { if (!(fiber.mask & mask)) return; walk(fiber, onWalk); } function onWalk(fiber, skip) { const { hook } = fiber; if (!(fiber.mask & mask)) return skip(); hook?.drop(); } function unmountRoot(rootId) { if (detectIsUndefined(rootId)) return; const $scope = $$scope(rootId); if (platform.detectIsDynamic()) { unmountFiber($scope.getRoot()); $scope.off(); } removeScope(rootId); } export { unmountFiber, unmountRoot }; //# sourceMappingURL=unmount.js.map