From b3fcf174716203013e9844f1aee3216f971fcd43 Mon Sep 17 00:00:00 2001 From: Michael DellaNoce Date: Tue, 1 Feb 2011 06:57:48 -0500 Subject: Widget: Modified _trigger to invoke callbacks with apply so that handlers are invoked the same way .trigger() invokes them. Fixes #6795 - Widget: _trigger passes array arguments to handlers inconsistently. --- tests/unit/widget/widget_tickets.js | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests') diff --git a/tests/unit/widget/widget_tickets.js b/tests/unit/widget/widget_tickets.js index 0267c8ff4..9c0bddf03 100644 --- a/tests/unit/widget/widget_tickets.js +++ b/tests/unit/widget/widget_tickets.js @@ -40,4 +40,52 @@ test( "#5830 - Widget: Using inheritance overwrites the base classes options", f delete $.ui.testWidgetExtension; }); +test( "#6795 - Widget: handle array arguments to _trigger consistently", function() { + expect( 4 ); + + $.widget( "ui.testWidget", { + _create: function() {}, + testEvent: function() { + var ui = { + foo: "bar", + baz: { + qux: 5, + quux: 20 + } + }; + var extra = { + bar: 5 + }; + this._trigger( "foo", null, [ ui, extra ] ); + } + }); + $( "#widget" ).bind( "testwidgetfoo", function( event, ui, extra ) { + same( ui, { + foo: "bar", + baz: { + qux: 5, + quux: 20 + } + }, "event: ui hash passed" ); + same( extra, { + bar: 5 + }, "event: extra argument passed" ); + }); + $( "#widget" ).testWidget({ + foo: function( event, ui, extra ) { + same( ui, { + foo: "bar", + baz: { + qux: 5, + quux: 20 + } + }, "callback: ui hash passed" ); + same( extra, { + bar: 5 + }, "callback: extra argument passed" ); + } + }) + .testWidget( "testEvent" ); +}); + }( jQuery ) ); -- cgit v1.2.3