bonfire-app/assets/js/bonfire_basic.js
Mayel de Borniol 471b45128b misc
2022-07-29 12:47:21 +12:00

22 lines
608 B
JavaScript
Executable file

import "./common"
let Hooks = {};
// TODO: put this in something similar to /config/deps_hooks.js and/or make it extensible/configurable
import { ImageHooks } from "./../../deps/bonfire_ui_common/assets/js/image"
Object.assign(Hooks, ImageHooks);
// run LiveView hooks without LiveView
(function () {
[...document.querySelectorAll("[phx-hook]")].map((hookEl) => {
let hookName = hookEl.getAttribute("phx-hook");
let hook = Hooks[hookName];
if (hook) {
let mountedFn = hook.mounted.bind({ ...hook, el: hookEl });
mountedFn();
}
});
}) ();