@3sln/dodo 0.0.7 → 0.0.8

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/src/vdom.js +6 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3sln/dodo",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "A minimal, configurable virtual DOM library.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/vdom.js CHANGED
@@ -395,7 +395,8 @@ export default userSettings => {
395
395
  }
396
396
  } else {
397
397
  const oldHooks = state.vdom.hooks ?? EMPTY_MAP;
398
- const hooksIterator = toIterator(mapIter(hooks));
398
+ const newHooks = hooks ?? EMPTY_MAP;
399
+ const hooksIterator = toIterator(mapIter(newHooks));
399
400
  let result;
400
401
  while (!(result = hooksIterator.next()).done) {
401
402
  const [name, listener] = result.value;
@@ -427,7 +428,7 @@ export default userSettings => {
427
428
  while (!(result = oldHooksIterator.next()).done) {
428
429
  const [name] = result.value;
429
430
  const hookName = convertHookName(name);
430
- if (hookName[0] === '$' || mapGet(hooks, name) !== undefined) continue;
431
+ if (hookName[0] === '$' || mapGet(newHooks, name) !== undefined) continue;
431
432
  const oldListener = mapGet(oldHooks, name);
432
433
  if (typeof oldListener === 'function') {
433
434
  target.removeEventListener(hookName, oldListener);
@@ -462,7 +463,7 @@ export default userSettings => {
462
463
  const innerVdom = newVdom.tag.apply(undefined, newVdom.args);
463
464
  if (innerVdom === undefined || innerVdom === null) break;
464
465
  if (isSeq(innerVdom)) {
465
- reconcileElementChildren(target, flattenSeq(innerVdom));
466
+ reconcileElementChildren(target, flattenSeq(innerVdom, true));
466
467
  } else {
467
468
  reconcileElementChildren(target, flattenVNodeChildren([innerVdom]));
468
469
  }
@@ -651,6 +652,7 @@ export default userSettings => {
651
652
  target.removeChild(nodeToRemove);
652
653
  }
653
654
 
655
+ const window = userSettings?.window ?? target.ownerDocument.defaultView;
654
656
  const moveBefore = window.Element.prototype.moveBefore;
655
657
  const insertBefore = window.Element.prototype.insertBefore;
656
658
  if (target.isConnected) {
@@ -748,7 +750,7 @@ export default userSettings => {
748
750
  }
749
751
 
750
752
  if (isSeq(vdom)) {
751
- reconcileElementChildren(target, flattenSeq(vdom));
753
+ reconcileElementChildren(target, flattenSeq(vdom, true));
752
754
  return;
753
755
  }
754
756