plugin
Plugin system for extending VoltX.js with custom bindings
registerPlugin
Register a custom plugin with a given name. Plugins extend VoltX.js with custom data-volt-* attribute bindings.
typescript
export function registerPlugin(name: string, handler: PluginHandler): voidExample:
typescript
registerPlugin('tooltip', (context, value) => {
const tooltip = document.createElement('div');
tooltip.className = 'tooltip';
tooltip.textContent = value;
context.element.addEventListener('mouseenter', () => {
document.body.appendChild(tooltip);
});
context.element.addEventListener('mouseleave', () => {
tooltip.remove();
});
context.addCleanup(() => tooltip.remove());
});getPlugin
Get a plugin handler by name.
typescript
export function getPlugin(name: string): PluginHandler | undefinedhasPlugin
Check if a plugin is registered.
typescript
export function hasPlugin(name: string): booleanunregisterPlugin
Unregister a plugin by name.
typescript
export function unregisterPlugin(name: string): booleangetRegisteredPlugins
Get all registered plugin names.
typescript
export function getRegisteredPlugins(): string[]clearPlugins
Clear all registered plugins.
typescript
export function clearPlugins(): void