Commit de1cc396 authored by JC Brand's avatar JC Brand

registry: avoid registering already registered custom elements

which throws and error and causes tests to fail
parent 82357f7d
import { _converse } from "@converse/headless/converse-core"; import { api } from "@converse/headless/converse-core";
const registry = {}; const registry = {};
function define (componentName, componentClass) { function define (name, constructor) {
this.registry[componentName] = componentClass; this.registry[name] = constructor;
} }
function register () { function register () {
Object.keys(registry).map(componentName => Object.keys(registry).forEach(name => {
window.customElements.define(componentName, registry[componentName]) if (!customElements.get(name)) {
); customElements.define(name, registry[name])
}
});
} }
_converse.api.elements = { api.elements = {
registry, registry,
define, define,
register register
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment