Releases: fregante/delegate-it
Releases Β· fregante/delegate-it
v6.2.1
v6.2.0
v6.1.0
v6.0.1
v6.0.0
Breaking changes
Move base
to options (#46) 247ac87
- delegate(document, 'a', 'click', alert)
+ delegate('a', 'click', alert)
- delegate(myBaseElement, 'a', 'click', alert)
+ delegate('a', 'click', alert, {base: myBaseElement})
Drop support for boolean-only options (#44) 7b3dc8a
- delegate(document, 'a', 'click', alert, true)
+ delegate('a', 'click', alert, {capture: true})
Drop support for selectors and arrays as base
(#45) 5b5138b
- delegate('.my-base-element', 'a', 'click', alert)
- delegate(document.querySelectorAll('.my-base-element'), 'a', 'click', alert)
New
Add promised oneEvent
listener (#41) 5697313
+ await oneEvent('a', 'click')
+ console.log('link was clicked')
Add support for once
(#40) 39dcce7
+ delegate('a', 'click', alert, {once: true})
v5.0.0
Breaking changes
Migration
Listener removal
v3 (old)
const delegation = delegate(document, 'a', 'click', console.log);
delegation.destroy();
v4 (old)
const controller = delegate(document, 'a', 'click', console.log);
controller.abort();
v5 (new)
This was already possible in v4, so if you were using this pattern, you don't need to change anything.
const controller = new AbortController();
delegate(document, 'a', 'click', console.log, {signal: controller.signal});
controller.abort();
v4.0.1
v4.0.0
Breaking changes
- Only accept iterables, not any array-likes ec3232d by @fregante
- Output modern code 6ac66e2 by @fregante
- Return
AbortController
instead of{destroy()}
+ supportsignal
(#28) 4f3d7ea by @cheap-glitch
Migration
Listener removal
Before:
const delegation = delegate(document, 'a', 'click', console.log);
delegation.destroy();
After:
const controller = delegate(document, 'a', 'click', console.log);
controller.abort();
// or provide your own signal
const controller = new AbortController();
delegate(document, 'a', 'click', console.log, {signal: controller.signal});
controller.abort();
Types
Before:
import delegate from 'delegate-it'
function listener(event: delegate.Event) {}
After:
import delegate, {DelegateEvent} from 'delegate-it'
function listener(event: DelegateEvent) {}
v3.0.1
v3.0.0
- 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
});