javascript - Can I rely on attach order while handling events? -
javascript - Can I rely on attach order while handling events? -
as far remember, in pure w3c event model (that means, using addeventlistener), there no guarantee event handlers invoked in order have been attached.
what jquery event model. can rely on order of attaching events? careful while answering, since there can 3 options here, not two:
you can not rely on order of attaching events, can see jquery code. you can rely on order of attaching events in current implementation, but, actually, nobody promiss supported in future, since order preserving unintentional. you can rely on order of attaching events - implemented willingly , remain forever, since intuitive , helps utilize mutual patterns, resource preinitialization , on.
if attach handlers through jquery, fired in order in attached. documented on bind
method:
when event reaches element, handlers bound event type element fired. if there multiple handlers registered, execute in order in bound. after handlers have executed, event continues along normal event propagation path.
you're right dom events specification not define order event handlers (link), , in fact browsers 1 way, ie another. guaranteed order jquery (by attaching 1 handler per event per element — own — , doing own dispatching real handlers attached via jquery). naturally means order in jquery-attached handlers called, block, in relation handlers attached in way not defined.
javascript jquery addeventlistener
Comments
Post a Comment