]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget factory: Convert falsy data values to an empty hash in _trigger. Fixes #4650...
authorScott González <scott.gonzalez@gmail.com>
Sat, 4 Jul 2009 03:39:19 +0000 (03:39 +0000)
committerScott González <scott.gonzalez@gmail.com>
Sat, 4 Jul 2009 03:39:19 +0000 (03:39 +0000)
tests/unit/dialog/dialog_events.js
ui/ui.core.js

index f5356979c9c5ff514fd9351b65b7537bd734ec14..ca325e99edc98f9c5f40b049fc08b828722c110f 100644 (file)
@@ -6,13 +6,15 @@
 module("dialog: events");
 
 test("open", function() {
-       expect(6);
+       expect(11);
 
        el = $("<div></div>");
        el.dialog({
                open: function(ev, ui) {
                        ok(true, 'autoOpen: true fires open callback');
                        equals(this, el[0], "context of callback");
+                       equals(ev.type, 'dialogopen', 'event type in callback');
+                       same(ui, {}, 'ui hash in callback');
                }
        });
        el.remove();
@@ -23,19 +25,15 @@ test("open", function() {
                open: function(ev, ui) {
                        ok(true, '.dialog("open") fires open callback');
                        equals(this, el[0], "context of callback");
+                       equals(ev.type, 'dialogopen', 'event type in callback');
+                       same(ui, {}, 'ui hash in callback');
                }
-       });
-       el.dialog("open");
-       el.remove();
-
-       el = $('<div></div>').dialog({
-               autoOpen: false
-       });
-       el.bind('dialogopen', function(ev, ui) {
+       }).bind('dialogopen', function(ev, ui) {
                ok(true, 'dialog("open") fires open event');
                equals(this, el[0], 'context of event');
+               same(ui, {}, 'ui hash in event');
        });
-       el.dialog('open');
+       el.dialog("open");
        el.remove();
 });
 
@@ -132,32 +130,33 @@ test("resizeStop", function() {
 });
 
 test("close", function() {
-       expect(4);
+       expect(7);
 
        el = $('<div></div>').dialog({
                close: function(ev, ui) {
                        ok(true, '.dialog("close") fires close callback');
                        equals(this, el[0], "context of callback");
+                       equals(ev.type, 'dialogclose', 'event type in callback');
+                       same(ui, {}, 'ui hash in callback');
                }
-       });
-       el.dialog("close");
-       el.remove();
-
-       el = $('<div></div>').dialog().bind('dialogclose', function(ev, ui) {
+       }).bind('dialogclose', function(ev, ui) {
                ok(true, '.dialog("close") fires dialogclose event');
                equals(this, el[0], 'context of event');
+               same(ui, {}, 'ui hash in event');
        });
        el.dialog('close');
        el.remove();
 });
 
 test("beforeclose", function() {
-       expect(6);
+       expect(9);
 
        el = $('<div></div>').dialog({
                beforeclose: function(ev, ui) {
                        ok(true, '.dialog("close") fires beforeclose callback');
                        equals(this, el[0], "context of callback");
+                       equals(ev.type, 'dialogbeforeclose', 'event type in callback');
+                       same(ui, {}, 'ui hash in callback');
                        return false;
                }
        });
@@ -168,6 +167,7 @@ test("beforeclose", function() {
        el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
                ok(true, '.dialog("close") triggers dialogbeforeclose event');
                equals(this, el[0], "context of event");
+               same(ui, {}, 'ui hash in event');
                return false;
        });
        el.dialog('close');
index eb0420c62daa2be485201db19846a1ffda073778..313074032a5eae1dca98e3e56cfeb630c3be95e7 100644 (file)
@@ -352,6 +352,7 @@ $.widget.prototype = {
 
                event = $.Event(event);
                event.type = eventName;
+               data = data || {};
 
                // copy original event properties over to the new event
                // this would happen if we could call $.event.fix instead of $.Event