Skip to content

Commit f3e2b55

Browse files
authored
Merge pull request #4 from flotiq/feature/add-detached-event-listener
add detached event listener
2 parents 5cf4f92 + bd2edbd commit f3e2b55

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed
File renamed without changes.

common/plugin-element-cache.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
const appRoots = {};
22

3-
export const onElementRemoved = (element, callback) => {
4-
new MutationObserver(function () {
5-
if (!document.contains(element)) {
6-
callback();
7-
this.disconnect();
8-
}
9-
}).observe(element.parentElement, { childList: true });
10-
};
11-
123
export const addElementToCache = (element, key, data = {}) => {
134
appRoots[key] = {
145
element,
156
data,
167
};
178

18-
element.addEventListener(
19-
'flotiq.attached',
20-
() => onElementRemoved(element, () => delete appRoots[key]),
21-
true,
9+
setTimeout(
10+
() =>
11+
element.addEventListener('flotiq.detached', () => {
12+
delete appRoots[key];
13+
}),
14+
50,
2215
);
2316
};
2417

2518
export const getCachedElement = (key) => {
2619
return appRoots[key];
2720
};
2821

29-
export const removeCachedElement = (key) => {
30-
delete appRoots[key];
31-
};
32-
3322
export const registerFn = (pluginInfo, callback) => {
3423
if (window.FlotiqPlugins?.add) {
3524
window.FlotiqPlugins.add(pluginInfo, callback);

plugin-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "flotiq.deploy-netlify",
33
"name": "Deploy Netlify",
44
"description": "Integration with Netlify deploy. With this plugin, you can easily trigger Netlify builds within Content Object changes on form submission. You will also be able to quickly navigate to your Netlify pages from the Flotiq content editor.",
5-
"version": "1.1.1",
5+
"version": "1.1.2",
66
"repository": "https://github.com/flotiq/flotiq-ui-plugin-deploy-netlify",
77
"url": "https://localhost:3053/index.js",
88
"permissions": []

0 commit comments

Comments
 (0)