From 83f61bec19ea2e4571824a919d466ff2a6ff89a0 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 25 Dec 2021 22:08:39 +0000 Subject: [PATCH] :adhesive_bandage: Waits for document to render before embeding --- src/components/Widgets/EmbedWidget.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Widgets/EmbedWidget.vue b/src/components/Widgets/EmbedWidget.vue index 949197ed..ffcffe70 100644 --- a/src/components/Widgets/EmbedWidget.vue +++ b/src/components/Widgets/EmbedWidget.vue @@ -10,18 +10,23 @@ import WidgetMixin from '@/mixins/WidgetMixin'; export default { mixins: [WidgetMixin], computed: { + /* Optional HTML markup to be rendered */ html() { return this.options.html || ''; }, + /* Optional CSS styles to be applied */ css() { return this.options.css || ''; }, + /* Optional raw JavaScript to be executed */ script() { return this.options.script || ''; }, + /* Optional path to JS script to be fetched */ scriptSrc() { return this.options.scriptSrc || ''; }, + /* Unique element ID */ elementId() { return `elem-${Math.round(Math.random() * 10000)}`; }, @@ -65,7 +70,7 @@ export default { if (document.readyState === 'complete' || document.readyState === 'loaded') { this.injectHtml(); } else { - this.eventListener = document.addEventListener('DOMContentLoaded', () => { + this.eventListener = window.addEventListener('load', () => { this.injectHtml(); }); }