Skip to content

Instantly share code, notes, and snippets.

@annevk
Last active December 15, 2015 09:29
Show Gist options
  • Save annevk/5238964 to your computer and use it in GitHub Desktop.
Save annevk/5238964 to your computer and use it in GitHub Desktop.
on() / off() sketch.
Using some experimental JS IDL syntax:
augment EventTarget {
EventTarget on(String type, EventListener callback,
{boolean ignoreBubbles?,
String? filter = null,
enum("capturing", "target", "bubbling") phase = "bubbling",
String? marker = null});
EventTarget off(String type, EventListener callback);
EventTarget off({ String? type = null, String? marker = null });
}
filter takes a selector. When filter is supplied ignoreBubbles defaults to true
which means the Event.bubbles property is ignored during event dispatch making
event delegation work better.
marker can be used for namespacing. E.g. to remove all event listeners at once
registered for the "button" component.
Everything else is as you expect it.
@zolkis
Copy link

zolkis commented Oct 1, 2013

Lovely. Any update on when can we have this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment