registry: avoid registering already registered custom elements
which throws and error and causes tests to fail
This commit is contained in:
parent
82357f7d97
commit
de1cc396bb
@ -1,18 +1,20 @@
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user