bimba-cli 0.5.16 → 0.5.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/serve.js +22 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimba-cli",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/bimba.git"
package/serve.js CHANGED
@@ -135,23 +135,27 @@ const hmrClient = `
135
135
  _oldNs.delete(tag);
136
136
  }
137
137
 
138
- // Destructive HMR: wipe inner DOM and re-render each collected tag
139
- for (const tag of collected) {
140
- const els = document.querySelectorAll(tag);
141
- els.forEach(el => {
142
- const state = {};
143
- for (const k of Object.keys(el)) state[k] = el[k];
144
- _disconnectDescendants(el);
145
- for (const sym of Object.getOwnPropertySymbols(el)) {
146
- if (Symbol.keyFor(sym) !== undefined) continue;
147
- try { delete el[sym]; } catch(_) {}
148
- }
149
- el.innerHTML = '';
150
- Object.assign(el, state);
151
- try { el.render && el.render(); } catch(e) { console.error('[bimba] render error:', e); }
152
- try { el.connectedCallback && el.connectedCallback(); } catch(_) {}
153
- try { el.mount && el.mount(); } catch(_) {}
154
- });
138
+ // Destructive HMR: wipe inner DOM and re-render each collected tag.
139
+ // Skip when slots === 'stable' (CSS-only change) — no template diff,
140
+ // so wiping innerHTML would destroy DOM state (inputs, focus) for nothing.
141
+ if (slots !== 'stable') {
142
+ for (const tag of collected) {
143
+ const els = document.querySelectorAll(tag);
144
+ els.forEach(el => {
145
+ const state = {};
146
+ for (const k of Object.keys(el)) state[k] = el[k];
147
+ _disconnectDescendants(el);
148
+ for (const sym of Object.getOwnPropertySymbols(el)) {
149
+ if (Symbol.keyFor(sym) !== undefined) continue;
150
+ try { delete el[sym]; } catch(_) {}
151
+ }
152
+ el.innerHTML = '';
153
+ Object.assign(el, state);
154
+ try { el.render && el.render(); } catch(e) { console.error('[bimba] render error:', e); }
155
+ try { el.connectedCallback && el.connectedCallback(); } catch(_) {}
156
+ try { el.mount && el.mount(); } catch(_) {}
157
+ });
158
+ }
155
159
  }
156
160
 
157
161
  if (typeof imba !== 'undefined') imba.commit();
@@ -547,7 +551,7 @@ export function serve(entrypoint, flags) {
547
551
 
548
552
  printStatus(rel, 'ok')
549
553
  broadcast({ type: 'clear-error' })
550
- broadcast({ type: 'update', file: rel, slots: 'shifted' })
554
+ broadcast({ type: 'update', file: rel, slots: out.slots || 'shifted' })
551
555
 
552
556
  // Cascade: re-import modules that transitively import this file.
553
557
  // Skip the entry point — re-importing it re-runs imba.mount and