dom-expressions 0.40.10 → 0.40.11

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.40.10",
4
+ "version": "0.40.11",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,14 +20,14 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "csstype": "^3.0",
23
- "seroval": "~1.5.0",
24
- "seroval-plugins": "~1.5.0"
23
+ "seroval": "~1.6.8",
24
+ "seroval-plugins": "~1.6.8"
25
25
  },
26
26
  "devDependencies": {
27
- "babel-plugin-jsx-dom-expressions": "^0.40.10",
27
+ "babel-plugin-jsx-dom-expressions": "^0.40.11",
28
28
  "csstype": "^3.1",
29
- "seroval": "~1.5.0",
30
- "seroval-plugins": "~1.5.0"
29
+ "seroval": "~1.6.8",
30
+ "seroval-plugins": "~1.6.8"
31
31
  },
32
- "gitHead": "727298ff79a54ef5299d3649ab7f4105a326e9b3"
32
+ "gitHead": "3eba17b37754abaae2346c0237a4a65de802a316"
33
33
  }
package/src/client.js CHANGED
@@ -54,9 +54,10 @@ export function render(code, element, init, options = {}) {
54
54
  let disposer;
55
55
  root(dispose => {
56
56
  disposer = dispose;
57
+ // Hydration owns the whole container, including nodes streamed in after init.
57
58
  element === document
58
59
  ? code()
59
- : insert(element, code(), element.firstChild ? null : undefined, init);
60
+ : insert(element, code(), !init && element.firstChild ? null : undefined, init);
60
61
  }, options.owner);
61
62
  return () => {
62
63
  disposer();
@@ -448,27 +449,35 @@ function eventHandler(e) {
448
449
  // cancel hydration
449
450
  if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
450
451
 
451
- if (e.composedPath) {
452
- const path = e.composedPath();
453
- retarget(path[0]);
454
- for (let i = 0; i < path.length - 2; i++) {
455
- node = path[i];
456
- if (!handleNode()) break;
457
- if (node._$host) {
458
- node = node._$host;
459
- // bubble up from portal mount instead of composedPath
460
- walkUpTree();
461
- break;
462
- }
463
- if (node.parentNode === oriCurrentTarget) {
464
- break; // don't bubble above root of event delegation
452
+ try {
453
+ if (e.composedPath) {
454
+ const path = e.composedPath();
455
+ retarget(path[0]);
456
+ for (let i = 0; i < path.length - 2; i++) {
457
+ node = path[i];
458
+ if (!handleNode()) break;
459
+ if (node._$host) {
460
+ node = node._$host;
461
+ // bubble up from portal mount instead of composedPath
462
+ walkUpTree();
463
+ break;
464
+ }
465
+ if (node.parentNode === oriCurrentTarget) {
466
+ break; // don't bubble above root of event delegation
467
+ }
465
468
  }
466
469
  }
470
+ // fallback for browsers that don't support composedPath
471
+ else walkUpTree();
472
+ // Mixing portals and shadow dom can lead to a nonstandard target, so reset here.
473
+ retarget(oriTarget);
474
+ } finally {
475
+ // The currentTarget getter shares this closure scope. Chromium keeps the
476
+ // getter from the first event of each event interface reachable for the
477
+ // page's lifetime (via the interface's shared map descriptors), so release
478
+ // the event and the last walked node to not pin a detached DOM tree.
479
+ e = node = null;
467
480
  }
468
- // fallback for browsers that don't support composedPath
469
- else walkUpTree();
470
- // Mixing portals and shadow dom can lead to a nonstandard target, so reset here.
471
- retarget(oriTarget);
472
481
  }
473
482
 
474
483
  function insertExpression(parent, value, current, marker, unwrapArray) {
package/src/universal.js CHANGED
@@ -63,7 +63,7 @@ export function createRenderer({
63
63
  if (current.length === 0) {
64
64
  appendNodes(parent, array, marker);
65
65
  } else reconcileArrays(parent, current, array);
66
- } else if (current == null || current === "") {
66
+ } else if (current == null || !getFirstChild(parent)) {
67
67
  appendNodes(parent, array);
68
68
  } else {
69
69
  reconcileArrays(parent, (multi && current) || [getFirstChild(parent)], array);
@@ -74,7 +74,7 @@ export function createRenderer({
74
74
  if (Array.isArray(current)) {
75
75
  if (multi) return (current = cleanChildren(parent, current, marker, value));
76
76
  cleanChildren(parent, current, null, value);
77
- } else if (current == null || current === "" || !getFirstChild(parent)) {
77
+ } else if (current == null || !getFirstChild(parent)) {
78
78
  insertNode(parent, value);
79
79
  } else replaceNode(parent, value, getFirstChild(parent));
80
80
  current = value;