Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions js/miso.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,13 @@ function delegateEvent(event, obj, stack, debug, context) {
}
}
stack.splice(0, 1);
for (const child of obj.children) {
if (context.isEqual(getDOMRef(child), stack[0])) {
delegateEvent(event, child, stack, debug, context);
}
}
}
for (const child of obj.children) {
delegateEvent(event, child, stack, debug, context);
}
return;
}
} else {
if (obj.type === 0 /* VComp */) {
Expand Down
2 changes: 1 addition & 1 deletion js/miso.prod.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ts/miso/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function drill<T>(c: VComp<T>): T {
}

// Extract DOM reference from any VTree (handles VComp drilling)
function getDOMRef<T>(tree: VTree<T>): T {
export function getDOMRef<T>(tree: VTree<T>): T {
switch (tree.type) {
case VTreeType.VComp:
return drill(tree);
Expand Down
10 changes: 7 additions & 3 deletions ts/miso/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventContext, VTree, EventCapture, EventObject, Options, VTreeType } from './types';
import { getDOMRef } from './dom';

/* event delegation algorithm */
export function delegate<T> (
Expand Down Expand Up @@ -124,10 +125,13 @@ function delegateEvent <T>(
}
}
stack.splice(0,1);
for (const child of obj.children) {
if (context.isEqual(getDOMRef(child), stack[0])) {
delegateEvent(event, child, stack, debug, context);
}
}
}
for (const child of obj.children) {
delegateEvent(event, child, stack, debug, context);
}
return;
}
} else {
/* stack.length === 1, we're at the target */
Expand Down