title: Infinite loop when using jQuery to trigger event on object with function of same name
body: <p>That title probably doesn't help much, I tried though.  Anyway I ran into this extremely mysterious (and frustrating) bug resulting in a <code>RangeError: Maximum call stack size exceeded</code> in some OO JS I'd written.  Took me a couple hours but I finally got to the cause.  Here's a simple example that will result in the same exception:</p>
  
  <pre><code>// Class
  var Foo = function(){
      // "Public" function
      this.bar = function(){
          console.log('loop!');
          $(this).trigger('bar');
      }
  }
  
  var foo = new Foo();
  $(foo).trigger('bar');
  </code></pre>
  
  <p>Running this code will result in <code>loop!</code> being logged to the console a ton of times before eventually resulting in the range exception.</p>
  
  <p>Clearly there's something about jQuery's <code>trigger</code> function I don't understand, and it boils down to this: <strong>why would foo's <code>bar</code> function be called at all?</strong>  Yes, the event name and the class's function name are the same, but I don't understand how the two are related.</p>