@financial-times/custom-code-component 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/custom-code-component.ts +15 -2
package/package.json
CHANGED
|
@@ -58,23 +58,36 @@ class FTCustomCodeComponent extends HTMLElement {
|
|
|
58
58
|
const mountPoint = document.createElement("iframe");
|
|
59
59
|
|
|
60
60
|
mountPoint.addEventListener("load", () => {
|
|
61
|
-
App.default(
|
|
61
|
+
const unmount = App.default(
|
|
62
62
|
mountPoint.contentDocument,
|
|
63
63
|
{ ...extraProps, data },
|
|
64
64
|
...this.children
|
|
65
65
|
);
|
|
66
|
+
|
|
67
|
+
if (unmount) this.disconnectedCallback = unmount;
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
this.attachShadow({ mode }).append(mountPoint);
|
|
69
71
|
} else {
|
|
70
72
|
const shadowRoot = this.attachShadow({ mode });
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
const unmount = await App.default(
|
|
75
|
+
shadowRoot,
|
|
76
|
+
{ ...extraProps, data },
|
|
77
|
+
...this.children
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (unmount) this.disconnectedCallback = unmount;
|
|
73
81
|
}
|
|
74
82
|
} catch (e) {
|
|
75
83
|
console.info(`<custom-code-component> uncaught error from ${path}: `, e);
|
|
76
84
|
}
|
|
77
85
|
}
|
|
86
|
+
|
|
87
|
+
async disconnectedCallback() {
|
|
88
|
+
const path = this.getAttribute("path");
|
|
89
|
+
console.info(`<custom-code-component:${path}> disconnected`);
|
|
90
|
+
}
|
|
78
91
|
}
|
|
79
92
|
|
|
80
93
|
// Register the custom element
|