Skip to content

v3.0.0

Compare
Choose a tag to compare
@fregante fregante released this 10 Apr 12:16
· 33 commits to main since this release
  • Make it more strongly-typed when used with TypeScript (#25) cceddeb
  • Improve type inference for the listener callback (#19) 46a07f7

This release is a breaking change only for TypeScript users, making the types more strict and exact. Example upgrade:

v2-

delegate(document, 'button.primary', 'click', event => {
   // event is Event
   // event.delegateTarget is HTMLElement
});
delegate<HTMLButtonElement, MouseEvent>(document, 'button.primary', 'click', event => {
   // event is MouseEvent
   // event.delegateTarget is HTMLButtonElement
});

v3+

As long as the selector correctly includes the tag name, typed-query-selector will parse it to detect the expected element type. Events are matched via GlobalEventHandlersEventMap as was already documented in readme.

delegate(document, 'button.primary', 'click', event => {
   // event is MouseEvent, automatically
   // event.delegateTarget is HTMLButtonElement, automatically parsing the selector
});

v2.0.2...v3.0.0