UNPKG

svelte-search-engine

Version:

A wrapper for Google's Programmable Search Engine, providing a Svelte-friendly interface.

18 lines (17 loc) 565 B
export const destroyRegistry = new Map(); export const createDestroyObserver = () => new MutationObserver((mutationsList) => { if (!destroyRegistry.size) { return; } mutationsList.forEach((mutation) => { if (mutation.type === 'childList') { mutation.removedNodes.forEach((node) => { const component = destroyRegistry.get(node); if (component) { destroyRegistry.delete(node); component.$destroy(); } }); } }); });