bimba-cli 0.5.2 → 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 -34
package/package.json
CHANGED
package/serve.js
CHANGED
|
@@ -67,48 +67,32 @@ const hmrClient = `
|
|
|
67
67
|
_hotTags = [];
|
|
68
68
|
|
|
69
69
|
import('/' + file + '?t=' + Date.now()).then(() => {
|
|
70
|
-
const updatedTags = _hotTags.slice();
|
|
71
70
|
_hotTags = [];
|
|
72
71
|
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
72
|
+
// Let Imba re-render in place from the patched prototypes. We do NOT
|
|
73
|
+
// touch instance DOM (no innerHTML reset, no symbol cleanup) — that
|
|
74
|
+
// would destroy rendered children like open popups / dropdowns and
|
|
75
|
+
// collapse any transient UI state. Prototype patching already makes
|
|
76
|
+
// the next render use the new methods; imba.commit() triggers it.
|
|
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.
|
|
76
90
|
const seen = new Set();
|
|
77
91
|
[...document.body.children].forEach(el => {
|
|
78
92
|
const tag = el.tagName.toLowerCase();
|
|
79
93
|
if (seen.has(tag)) el.remove();
|
|
80
94
|
else seen.add(tag);
|
|
81
95
|
});
|
|
82
|
-
|
|
83
|
-
// JS changed: find all instances of the updated tag types, reset their
|
|
84
|
-
// render output (innerHTML), then let imba re-render from current state.
|
|
85
|
-
//
|
|
86
|
-
// innerHTML = '' removes rendered DOM children but does NOT touch instance
|
|
87
|
-
// properties — so el.active, el.selectedTab etc. survive.
|
|
88
|
-
//
|
|
89
|
-
// We also clear any symbol keys that point to DOM Nodes (Imba's render
|
|
90
|
-
// cache) so the new render method (which uses new module-scoped symbols)
|
|
91
|
-
// starts clean and doesn't leave orphaned nodes.
|
|
92
|
-
|
|
93
|
-
const toReset = new Set();
|
|
94
|
-
|
|
95
|
-
updatedTags.forEach(tagName => {
|
|
96
|
-
document.querySelectorAll(tagName).forEach(el => {
|
|
97
|
-
toReset.add(el);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
toReset.forEach(el => {
|
|
102
|
-
// Clear Imba render cache (symbol → Node mappings)
|
|
103
|
-
Object.getOwnPropertySymbols(el).forEach(s => {
|
|
104
|
-
try { if (el[s] instanceof Node) el[s] = undefined; } catch(_) {}
|
|
105
|
-
});
|
|
106
|
-
el.innerHTML = '';
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
if (toReset.size > 0 && typeof imba !== 'undefined') {
|
|
110
|
-
imba.commit();
|
|
111
|
-
}
|
|
112
96
|
});
|
|
113
97
|
}
|
|
114
98
|
|