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 = {};
function define (componentName, componentClass) {
this.registry[componentName] = componentClass;
function define (name, constructor) {
this.registry[name] = constructor;
}
function register () {
Object.keys(registry).map(componentName =>
window.customElements.define(componentName, registry[componentName])
);
Object.keys(registry).forEach(name => {
if (!customElements.get(name)) {
customElements.define(name, registry[name])
}
});
}
_converse.api.elements = {
api.elements = {
registry,
define,
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