Sha256: bf778e98646e482ddba043f29dbf852d16ad683f0ec4d8f4ee78671295198613
Contents?: true
Size: 781 Bytes
Versions: 73
Compression:
Stored size: 781 Bytes
Contents
function registerComponents(components) { document.addEventListener("alpine:init", () => { components.forEach((module) => { if (module.default && module.default.component === true) { Alpine.data(module.default.name, module.default); } }); }); return components; } function getComponent(el, throwOnError = false) { try { return Alpine.$data(el); } catch (error) { if (throwOnError) { throw error; } else { return null; } } } function getData(el) { const root = Alpine.closestRoot(el); return root ? Alpine.$data(root) : null; } function setData(el, newData) { const data = getData(el); return data ? Object.assign(data, newData) : null; } export { registerComponents, getComponent, getData, setData };
Version data entries
73 entries across 73 versions & 1 rubygems