safe register element

This commit is contained in:
Pete Matsyburka
2024-05-23 13:44:00 +03:00
parent d6893079f7
commit b2c8667c53
2 changed files with 28 additions and 24 deletions
+4 -2
View File
@@ -3,8 +3,10 @@ import { createApp, reactive } from 'vue'
import Form from './submission_form/form'
import DownloadButton from './elements/download_button'
window.customElements.define('download-button', DownloadButton)
window.customElements.define('submission-form', class extends HTMLElement {
const safeRegisterElement = (name, element, options = {}) => !window.customElements.get(name) && window.customElements.define(name, element, options)
safeRegisterElement('download-button', DownloadButton)
safeRegisterElement('submission-form', class extends HTMLElement {
connectedCallback () {
this.appElem = document.createElement('div')