dom-expressions 0.38.2 → 0.38.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dom-expressions",
3
3
  "description": "A Fine-Grained Runtime for Performant DOM Rendering",
4
- "version": "0.38.2",
4
+ "version": "0.38.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -29,5 +29,5 @@
29
29
  "seroval": "^1.1.0",
30
30
  "seroval-plugins": "^1.1.0"
31
31
  },
32
- "gitHead": "72e2010c1fb6ce1b87fd2c0e2baada3be7ad8dcf"
32
+ "gitHead": "aa6dcc6a52226ade987b3bd8d5b766a64c65de6b"
33
33
  }
package/src/client.js CHANGED
@@ -229,11 +229,11 @@ export function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef
229
229
 
230
230
  // Hydrate
231
231
  export function hydrate(code, element, options = {}) {
232
+ if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
232
233
  sharedConfig.completed = globalThis._$HY.completed;
233
234
  sharedConfig.events = globalThis._$HY.events;
234
235
  sharedConfig.load = id => globalThis._$HY.r[id];
235
236
  sharedConfig.has = id => id in globalThis._$HY.r;
236
- sharedConfig.done = globalThis._$HY.done;
237
237
  sharedConfig.gather = root => gatherHydratable(element, root);
238
238
  sharedConfig.registry = new Map();
239
239
  sharedConfig.context = {
@@ -296,8 +296,12 @@ export function runHydrationEvents() {
296
296
  while (events.length) {
297
297
  const [el, e] = events[0];
298
298
  if (!completed.has(el)) return;
299
- eventHandler(e);
300
299
  events.shift();
300
+ eventHandler(e);
301
+ }
302
+ if (sharedConfig.done) {
303
+ sharedConfig.events = _$HY.events = null;
304
+ sharedConfig.completed = _$HY.completed = null;
301
305
  }
302
306
  });
303
307
  sharedConfig.events.queued = true;
@@ -370,6 +374,10 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
370
374
  }
371
375
 
372
376
  function eventHandler(e) {
377
+ if (sharedConfig.registry && sharedConfig.events) {
378
+ if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
379
+ }
380
+
373
381
  const key = `$$${e.type}`;
374
382
  let node = (e.composedPath && e.composedPath()[0]) || e.target;
375
383
  // reverse Shadow DOM retargetting
package/src/server.js CHANGED
@@ -506,7 +506,7 @@ export function generateHydrationScript({ eventNames = ["click", "input"], nonce
506
506
  nonce ? ` nonce="${nonce}"` : ""
507
507
  }>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
508
508
  '", "'
509
- )}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
509
+ )}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
510
510
  }
511
511
 
512
512
  export function Hydration(props) {