Allow the events given to Guacamole.Event.DOMEvent to be a single event or omitted entirely.
@@ -79,10 +79,10 @@ Guacamole.Event = function Event(type) {
};
/**
- * A {@link Guacamole.Event} that relates to one or more DOM events. Continued
- * propagation and default behavior of the related DOM events may be prevented
- * with {@link Guacamole.Event.DOMEvent#stopPropagation stopPropagation()} and
- * {@link Guacamole.Event.DOMEvent#preventDefault preventDefault()}
+ * A {@link Guacamole.Event} that may relate to one or more DOM events.
+ * Continued propagation and default behavior of the related DOM events may be
+ * prevented with {@link Guacamole.Event.DOMEvent#stopPropagation stopPropagation()}
+ * and {@link Guacamole.Event.DOMEvent#preventDefault preventDefault()}
* respectively.
*
* @constructor
@@ -91,8 +91,8 @@ Guacamole.Event = function Event(type) {
* @param {String} type
* The unique name of this event type.
*
- * @param {Event[]} events
- * The DOM events that are related to this event. Future calls to
+ * @param {Event|Event[]} [events=[]]
+ * The DOM events that are related to this event, if any. Future calls to
* {@link Guacamole.Event.DOMEvent#preventDefault preventDefault()} and
* {@link Guacamole.Event.DOMEvent#stopPropagation stopPropagation()} will
* affect these events.
@@ -101,6 +101,13 @@ Guacamole.Event.DOMEvent = function DOMEvent(type, events) {
Guacamole.Event.call(this, type);
+ // Default to empty array
+ events = events || [];
+
+ // Automatically wrap non-array single Event in an array
+ if (!Array.isArray(events))
+ events = [ events ];
+
/**
* Requests that the default behavior of related DOM events be prevented.
* Whether this request will be honored by the browser depends on the
