JSFiddle - React, Tailwind, and code Playground
by Ben Alman
HTML
<div id="test"></div>
JavaScript
// BEGIN JQUERY-HOURLY CLOSURE
// $.getScript('http://www.miketaylr.com/jquery-nightly/jquery-hourly.js',function(){(function($){
var i = 0;
function log() {
console.log.apply( console, [ ++i ].concat( [].slice.call(arguments) ) );
};
// When special events are unbound via .die, remove + teardown never get
// called, and the event-named property is not removed from the 'events'
// data object.
log( $.fn.jquery );
$.event.special.foo = {
setup: function( data, namespaces, handler ) {
log.apply( log, [ 'setup', this ].concat( [].slice.call(arguments) ) );
},
teardown: function( namespaces ) {
log.apply( log, [ 'teardown', this ].concat( [].slice.call(arguments) ) );
},
add: function( handleObj ) {
log.apply( log, [ 'add', this ].concat( [].slice.call(arguments) ) );
},
remove: function( handleObj ) {
log.apply( log, [ 'remove', this ].concat( [].slice.call(arguments) ) );
},
_default: function( event ) {
log.apply( log, [ '_default', event.target ].concat( [].slice.call(arguments) ) );
}
};
$('#test').bind( 'foo', function(event){ log( 'BIND: FOO', this, event.target ); } );
log( $('#test').data( 'events' ).foo[0] );
$('#test').trigger( 'foo' );
$('#test').unbind( 'foo' );
log( $('#test').data( 'events' ) );
$('#test').trigger( 'foo' );
$('#test').live( 'foo', function(event){ log( 'LIVE: FOO', this, event.target ); } );
log( $.data( document, 'events' ).foo[0] );
$('#test').trigger( 'foo' );
$('#test').die( 'foo' );
log( '>>> remove should be called here!' );
log( '>>> teardown should be called here!' );
log( $.data( document, 'events' ).foo[0], '>>> this should cause an error!' );
$('#test').trigger( 'foo' );
// END JQUERY-HOURLY CLOSURE
// })(jQuery.noConflict(true))});