Test Case Boilerplate
Fork this way...
HTML
<p>
Just some content.
</p>
<div id="someId">Click me to trigger a click event on the p element</div>
<br />
<div id="otherId">Click me to trigger a click event on the document</div>
JavaScript
(function (window, $j, undefined) {
$j(document).ready(function(){
$j(window).on('anyevent.bug','p', function(){console.log('Registered on window with p as selector');});
$j(window).on('anyevent.bug', function(){console.log('Registered on window without a selector');});
$j('#someId').on('click', function(){
$j('p').trigger('anyevent'); //this trigger bubbles up all the way to the window and executes correctly
});
$j('#otherId').on('click', function(){
$j(document).trigger('anyevent'); //this event doesn't bubble up to the window and therefore doesn't cause any handler to run
});
});
})(window, jQuery);