Bot releases are hidden (Show)
https://github.com/fregante/delegate-it/compare/v6.0.1...v6.1.0
https://github.com/fregante/delegate-it/compare/v6.0.0...v6.0.1
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})
- delegate(document, 'a', 'click', alert, true)
+ delegate('a', 'click', alert, {capture: true})
base
(#45) 5b5138b- delegate('.my-base-element', 'a', 'click', alert)
- delegate(document.querySelectorAll('.my-base-element'), 'a', 'click', alert)
oneEvent
listener (#41) 5697313+ await oneEvent('a', 'click')
+ console.log('link was clicked')
once
(#40) 39dcce7+ delegate('a', 'click', alert, {once: true})
https://github.com/fregante/delegate-it/compare/v5.0.0...v6.0.0
AbortController
(#32) 8a6c2f2const delegation = delegate(document, 'a', 'click', console.log);
delegation.destroy();
const controller = delegate(document, 'a', 'click', console.log);
controller.abort();
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();
https://github.com/fregante/delegate-it/compare/v4.0.1...v5.0.0
https://github.com/fregante/delegate-it/compare/v4.0.0...v4.0.1
Published by fregante over 2 years ago
AbortController
instead of {destroy()}
+ support signal
(#28) 4f3d7ea by @cheap-glitchBefore:
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();
Before:
import delegate from 'delegate-it'
function listener(event: delegate.Event) {}
After:
import delegate, {DelegateEvent} from 'delegate-it'
function listener(event: DelegateEvent) {}
https://github.com/fregante/delegate-it/compare/v3.0.1...v4.0.0
once
option (#29) 0081742options
parameter (#27) ec81f44https://github.com/fregante/delegate-it/compare/v3.0.0...v3.0.1
This release is a breaking change only for TypeScript users, making the types more strict and exact. Example upgrade:
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
});
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
});
https://github.com/fregante/delegate-it/compare/v2.0.2...v3.0.0
base
parameter: https://github.com/fregante/delegate-it/issues/15 7c9b6c341a67ebce6fc9037f808dd36fc6968df6This should also avoid memory leak because apparently there was a bug in the removal process.