From 0ee79afdfe7d1f875195eb353700c0e6f38c30b4 Mon Sep 17 00:00:00 2001 From: Erick Acuna Date: Tue, 24 Jun 2014 12:43:18 -0400 Subject: [PATCH 1/2] Fixed issue number 1298 component.trigger does not pass event object #1298 --- src/js/component.js | 10 ++++++---- src/js/events.js | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/js/component.js b/src/js/component.js index b6ff71bd89..a79a5312ec 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -563,13 +563,15 @@ vjs.Component.prototype.one = function(type, fn) { * Trigger an event on an element * * myComponent.trigger('eventName'); + * myComponent.trigger({'type':'eventName', 'value':'eventValue'}); * - * @param {String} type The event type to trigger, e.g. 'click' - * @param {Event|Object} event The event object to be passed to the listener + * @param {Object} event either a string (the event type) + * to trigger or an event object + * with a type attribute. * @return {vjs.Component} self */ -vjs.Component.prototype.trigger = function(type, event){ - vjs.trigger(this.el_, type, event); +vjs.Component.prototype.trigger = function(event){ + vjs.trigger(this.el_, event); return this; }; diff --git a/src/js/events.js b/src/js/events.js index becac0ce9c..0ecfc0ea3f 100644 --- a/src/js/events.js +++ b/src/js/events.js @@ -265,7 +265,9 @@ vjs.fixEvent = function(event) { /** * Trigger an event for an element * @param {Element|Object} elem Element to trigger an event on - * @param {String} event Type of event to trigger + * @param {Object} event either a string (the event type) + * to trigger or an event object with a + * type attribute. * @private */ vjs.trigger = function(elem, event) { From d24a9b48aca41c22412357f050d1a73ed09c1d65 Mon Sep 17 00:00:00 2001 From: Erick Acuna Date: Thu, 26 Jun 2014 10:50:25 -0400 Subject: [PATCH 2/2] Updated jsdoc --- src/js/component.js | 8 ++++---- src/js/events.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/component.js b/src/js/component.js index a79a5312ec..07f7a8a250 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -563,11 +563,11 @@ vjs.Component.prototype.one = function(type, fn) { * Trigger an event on an element * * myComponent.trigger('eventName'); - * myComponent.trigger({'type':'eventName', 'value':'eventValue'}); + * myComponent.trigger({'type':'eventName'}); * - * @param {Object} event either a string (the event type) - * to trigger or an event object - * with a type attribute. + * @param {Event|Object|String} event either a string (the event type) + * to trigger or an event object + * with a type attribute. * @return {vjs.Component} self */ vjs.Component.prototype.trigger = function(event){ diff --git a/src/js/events.js b/src/js/events.js index 0ecfc0ea3f..5e3098b02a 100644 --- a/src/js/events.js +++ b/src/js/events.js @@ -264,10 +264,10 @@ vjs.fixEvent = function(event) { /** * Trigger an event for an element - * @param {Element|Object} elem Element to trigger an event on - * @param {Object} event either a string (the event type) - * to trigger or an event object with a - * type attribute. + * @param {Element|Object} elem Element to trigger an event on + * @param {Event|Object|String} event either a string (the event type) + * to trigger or an event object with a + * type attribute. * @private */ vjs.trigger = function(elem, event) {