bimba-cli 0.5.3 → 0.5.4
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/serve.js +18 -10
package/package.json
CHANGED
package/serve.js
CHANGED
|
@@ -69,22 +69,30 @@ const hmrClient = `
|
|
|
69
69
|
import('/' + file + '?t=' + Date.now()).then(() => {
|
|
70
70
|
_hotTags = [];
|
|
71
71
|
|
|
72
|
-
// Remove duplicate root elements. Re-importing a module with a fresh
|
|
73
|
-
// ?t= query causes top-level code (e.g. imba.mount()) to run again,
|
|
74
|
-
// which can append a second copy of the root tag to body.
|
|
75
|
-
const seen = new Set();
|
|
76
|
-
[...document.body.children].forEach(el => {
|
|
77
|
-
const tag = el.tagName.toLowerCase();
|
|
78
|
-
if (seen.has(tag)) el.remove();
|
|
79
|
-
else seen.add(tag);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
72
|
// Let Imba re-render in place from the patched prototypes. We do NOT
|
|
83
73
|
// touch instance DOM (no innerHTML reset, no symbol cleanup) — that
|
|
84
74
|
// would destroy rendered children like open popups / dropdowns and
|
|
85
75
|
// collapse any transient UI state. Prototype patching already makes
|
|
86
76
|
// the next render use the new methods; imba.commit() triggers it.
|
|
87
77
|
if (typeof imba !== 'undefined') imba.commit();
|
|
78
|
+
|
|
79
|
+
// Dedupe direct body children by tag — runs AFTER commit so it
|
|
80
|
+
// catches both:
|
|
81
|
+
// 1) Re-importing top-level code that calls imba.mount() again
|
|
82
|
+
// (appends a second root tag to body).
|
|
83
|
+
// 2) Detached popups: a popup uses imba.mount(self) to reparent
|
|
84
|
+
// itself to body, so on commit the parent re-renders, doesn't
|
|
85
|
+
// see the popup among its children, and creates a brand-new
|
|
86
|
+
// instance which gets appended to body. The original (with
|
|
87
|
+
// its state) is first in body.children; the freshly-created
|
|
88
|
+
// duplicate is last — removing later occurrences preserves
|
|
89
|
+
// state.
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
[...document.body.children].forEach(el => {
|
|
92
|
+
const tag = el.tagName.toLowerCase();
|
|
93
|
+
if (seen.has(tag)) el.remove();
|
|
94
|
+
else seen.add(tag);
|
|
95
|
+
});
|
|
88
96
|
});
|
|
89
97
|
}
|
|
90
98
|
|