MCPcopy Index your code
hub / github.com/jquery/jquery / on

Function on

dist-module/jquery.factory.module.js:4579–4638  ·  view source on GitHub ↗
( elem, types, selector, data, fn, one )

Source from the content-addressed store, hash-verified

4577}
4578
4579function on( elem, types, selector, data, fn, one ) {
4580 var origFn, type;
4581
4582 // Types can be a map of types/handlers
4583 if ( typeof types === "object" ) {
4584
4585 // ( types-Object, selector, data )
4586 if ( typeof selector !== "string" ) {
4587
4588 // ( types-Object, data )
4589 data = data || selector;
4590 selector = undefined;
4591 }
4592 for ( type in types ) {
4593 on( elem, type, selector, data, types[ type ], one );
4594 }
4595 return elem;
4596 }
4597
4598 if ( data == null && fn == null ) {
4599
4600 // ( types, fn )
4601 fn = selector;
4602 data = selector = undefined;
4603 } else if ( fn == null ) {
4604 if ( typeof selector === "string" ) {
4605
4606 // ( types, selector, fn )
4607 fn = data;
4608 data = undefined;
4609 } else {
4610
4611 // ( types, data, fn )
4612 fn = data;
4613 data = selector;
4614 selector = undefined;
4615 }
4616 }
4617 if ( fn === false ) {
4618 fn = returnFalse;
4619 } else if ( !fn ) {
4620 return elem;
4621 }
4622
4623 if ( one === 1 ) {
4624 origFn = fn;
4625 fn = function( event ) {
4626
4627 // Can use an empty set, since event contains the info
4628 jQuery().off( event );
4629 return origFn.apply( this, arguments );
4630 };
4631
4632 // Use same guid so caller can remove using origFn
4633 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4634 }
4635 return elem.each( function() {
4636 jQuery.event.add( this, types, fn, data, selector );

Callers 1

jQueryFactoryWrapperFunction · 0.70

Calls 1

jQueryFunction · 0.70

Tested by

no test coverage detected