Skip to content

Commit 17f5fc3

Browse files
committed
Oembed load provider javascript to fully render widget
1 parent e24a2eb commit 17f5fc3

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

public/js/vvvebjs/components-embeds.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,27 @@ Vvveb.Components.extend("_base", "embeds/embed", {
3737
htmlAttr: "data-url",
3838
inputtype: TextInput,
3939
onChange: function(node, value) {
40-
let element = node[0];
41-
42-
element.innerHTML = `<div class="alert alert-light d-flex justify-content-center">
40+
node.innerHTML = `<div class="alert alert-light d-flex justify-content-center">
4341
<div class="spinner-border m-5" role="status">
4442
<span class="visually-hidden">Loading...</span>
4543
</div>
4644
</div>`;
4745

4846
getOembed(value).then(response => {
49-
element.innerHTML = response.html;
47+
node.innerHTML = response.html;
5048
let containerW = node.offsetWidth;
51-
let iframe = element.querySelector("iframe");
52-
let ratio = containerW / iframe.offsetWidth;
53-
54-
iframe.setAttribute("width", (width * ratio));
55-
iframe.setAttribute("height", (height * ratio));
49+
let iframe = node.querySelector("iframe");
50+
if (iframe) {
51+
let ratio = containerW / iframe.offsetWidth;
52+
iframe.setAttribute("width", (width * ratio));
53+
iframe.setAttribute("height", (height * ratio));
54+
}
55+
56+
let arr = node.querySelectorAll('script').forEach(script => {
57+
let newScript = Vvveb.Builder.frameDoc.createElement("script");
58+
newScript.src = script.src;
59+
script.replaceWith(newScript);
60+
});
5661

5762
}).catch(error => console.log(error));
5863

0 commit comments

Comments
 (0)