@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)
31 lines (30 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.unmountRoot = exports.unmountFiber = void 0;
const constants_1 = require('../constants');
const scope_1 = require('../scope');
const utils_1 = require('../utils');
const platform_1 = require('../platform');
const walk_1 = require('../walk');
const mask = constants_1.EFFECT_HOST_MASK | constants_1.CLEANUP_HOST_MASK;
function unmountFiber(fiber) {
if (!(fiber.mask & mask)) return;
(0, walk_1.walk)(fiber, onWalk);
}
exports.unmountFiber = unmountFiber;
function onWalk(fiber, skip) {
const { hook } = fiber;
if (!(fiber.mask & mask)) return skip();
hook?.drop();
}
function unmountRoot(rootId) {
if ((0, utils_1.detectIsUndefined)(rootId)) return;
const $scope = (0, scope_1.$$scope)(rootId);
if (platform_1.platform.detectIsDynamic()) {
unmountFiber($scope.getRoot());
$scope.off();
}
(0, scope_1.removeScope)(rootId);
}
exports.unmountRoot = unmountRoot;
//# sourceMappingURL=unmount.js.map