safe register element

This commit is contained in:
Pete Matsyburka committed 2024-05-23 14:02:48 +03:00
1 parent d6893079f7
commit b2c8667c53
2 files changed
+28 -24

No files matched your search

+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')