- From: François REMY <notifications@github.com>
- Date: Sat, 24 Jun 2017 11:05:04 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 24 June 2017 18:05:36 UTC
Ok... I think I understand the proposal better now. Do I?
```
<section> <span a> <div> <span b> <a href="#"> <span c></span> </a> </span> ...
```
```
div.addEventListener(
'click',
handler,
{
for: t => t.matches("span"),
...otherOptions
}
)
```
would be similar in spirit to
```
div.addEventListener(
'click',
addDelegatedHandlers(
handler,
t => t.matches("span"),
{ ...otherOptions }
),
true
);
function addDelegatedHandlers(handler, condition, otherOptions) {
return event => {
let futureTargets = event.getFutureTargets() // [ span[b], a[href], span[c] ]
let futureTargetsToHook = futureTargets.filter(condition); // [ span[b], span[c] ]
for(let futureTarget of futureTargetsToHook) {
futureTarget.addEventListener(event.type, handler, otherOptions);
setImmediate(t => futureTarget.removeEventListener(event.type, handler, otherOptions));
}
};
}
```
Is that right?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/215#issuecomment-310854509
Received on Saturday, 24 June 2017 18:05:36 UTC