javascript event handling
<p>I'm working on a very lightweight system to test a javascript framework I am building for work.</p>

<p>I've created a test function that acts as a wrapper invoking the function i am testing within a try/catch to report feedback without breaking my test cycle. The problem is that my catch isn't getting called when I deliberately create an error.</p>

<p>My code....</p>

<pre><code>    /// &lt;summary&gt;
    ///     Acts as a wrapper to allow us to perform and report the result 
    ///     of each individual
    ///     test without blocking further tests.
    /// &lt;/summary&gt;
    /// &lt;param name="selector" type="String"&gt;
    ///     The id jQuery selector e.g #versionTests to repot feedback to.
    /// &lt;/param&gt;
    /// &lt;param name="testFunction" type="Function"&gt;
    ///     The test function to call.
    /// &lt;/param&gt;
    test: function (selector, testFunction) {

        try {
            // now we are calling our own callback function
            if (typeof testFunction === 'function') {

                testFunction.call();
            }
        } catch (e) {

       jQuery(selector).addClass("error").append("&lt;p&gt;" + e.description + "&lt;/p&gt;");

        }

    }
</code></pre>

<p>Thanks in advance....</p>

<p>EDIT.. Added called code for clarity.</p>

<p>The test function that I am calling is basically on that calls this....</p>

<pre><code>    testEqualizeHeight: function () {

        PeachUI("div.heightTest").equalizeHeight();
    }
</code></pre>

<p>Which calls this....... (<code>this.selector</code> is a property that reflect jQuerys selector.)
note the missing <code>'$'</code> on <code>$selector.height(tallest);</code></p>

<pre><code>equalizeHeight: function () {
    /// &lt;summary&gt;
    ///     Equalizes the height of the specified element(s).
    /// &lt;/summary&gt;

    var $tallest = 0, $selector = this.selector;

    $selector.each(function () {

        var $height = jQuery(this).height();

        if ($height &gt; $tallest) {

            $tallest = $height;
        }
    });

    // ie6 height is the same as min-height for other browsers.
    if (PeachUI.browser.ie6) {

        $selector.height(tallest);

    } else {

        $selector.css("min-height", $tallest);
    }
}
</code></pre>
