2020-12-03 13:40:30 +01:00
|
|
|
import { api } from "@converse/headless/core";
|
2020-07-01 21:45:18 +02:00
|
|
|
|
|
|
|
const registry = {};
|
|
|
|
|
2020-07-07 13:18:47 +02:00
|
|
|
function define (name, constructor) {
|
|
|
|
this.registry[name] = constructor;
|
2020-07-01 21:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function register () {
|
2020-07-07 13:18:47 +02:00
|
|
|
Object.keys(registry).forEach(name => {
|
|
|
|
if (!customElements.get(name)) {
|
|
|
|
customElements.define(name, registry[name])
|
|
|
|
}
|
|
|
|
});
|
2020-07-01 21:45:18 +02:00
|
|
|
}
|
|
|
|
|
2020-07-07 13:18:47 +02:00
|
|
|
api.elements = {
|
2020-07-01 21:45:18 +02:00
|
|
|
registry,
|
|
|
|
define,
|
|
|
|
register
|
|
|
|
}
|