Vanilla ES module mount and destroy
experimental
Mount a grid into a container with no framework and destroy it without leaks.
Live example
Expected behavior
Mount renders the grid. Destroy removes its DOM and listeners and the counter returns to 0. API calls after destroy report GRID_DESTROYED.
Source
import { mountGrid } from '@warlockcode/warui-core';
const mounted = mountGrid(document.getElementById('grid'), { columns, rowData });
mounted.updateConfig({ columns: columns.slice(0, 3) });
mounted.destroy(); // idempotent
mounted.getGrid(); // throws GRID_DESTROYEDimport { mountGrid } from '@warlockcode/warui-core';
const mounted = mountGrid(document.getElementById('grid'), { columns, rowData });
mounted.updateConfig({ columns: columns.slice(0, 3) });
mounted.destroy(); // idempotent
mounted.getGrid(); // throws GRID_DESTROYEDimport { mountGrid } from '@warlockcode/warui-core';
const mounted = mountGrid(document.getElementById('grid'), { columns, rowData });
mounted.updateConfig({ columns: columns.slice(0, 3) });
mounted.destroy(); // idempotent
mounted.getGrid(); // throws GRID_DESTROYEDimport { mountGrid } from '@warlockcode/warui-core';
const mounted = mountGrid(document.getElementById('grid'), { columns, rowData });
mounted.updateConfig({ columns: columns.slice(0, 3) });
mounted.destroy(); // idempotent
mounted.getGrid(); // throws GRID_DESTROYED// JavaScript interop module
import { mountGrid } from '@warlockcode/warui-core';
const mounted = mountGrid(document.getElementById('grid'), { columns, rowData });
mounted.updateConfig({ columns: columns.slice(0, 3) });
mounted.destroy(); // idempotent
mounted.getGrid(); // throws GRID_DESTROYEDAPI reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Function | mountGrid | — | Mounts a grid into a container and returns a MountedGrid. |
| Method | destroy | — | Releases DOM and listeners. Safe to call twice. |
| Method | isDestroyed | — | Reports the destroyed state without throwing. |
| Method | updateConfig | — | Merges columns or rowData and re-renders. |
| Error | GridDestroyedError | — | Has code GRID_DESTROYED. |