From 91ef69d7503f11f2b6223b9c0061fca51e3a006f Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 21 Nov 2011 11:14:19 -0500 Subject: Widget: Don't use $.event.props when creating events. --- ui/jquery.ui.widget.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'ui/jquery.ui.widget.js') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 53cde389e..0d52fb534 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -374,29 +374,28 @@ $.Widget.prototype = { }, _trigger: function( type, event, data ) { - var callback = this.options[ type ], - args; + var args, prop, orig, + callback = this.options[ type ]; + data = data || {}; event = $.Event( event ); event.type = ( type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type ).toLowerCase(); - data = data || {}; + // the original event may come from any element + // so we need to reset the target on the new event + event.target = this.element[ 0 ]; // copy original event properties over to the new event - // this would happen if we could call $.event.fix instead of $.Event - // but we don't have a way to force an event to be fixed multiple times - if ( event.originalEvent ) { - for ( var i = $.event.props.length, prop; i; ) { - prop = $.event.props[ --i ]; - event[ prop ] = event.originalEvent[ prop ]; + orig = event.originalEvent; + if ( orig ) { + for ( prop in orig ) { + if ( !( prop in event ) ) { + event[ prop ] = orig[ prop ]; + } } } - // the original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[0]; - this.element.trigger( event, data ); args = $.isArray( data ) ? -- cgit v1.2.3 From 5fb9629766f10a9119e0099bd8aee06f86cc3f30 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 21 Nov 2011 11:31:51 -0500 Subject: Widget: Simplify data normalization in _trigger(). --- ui/jquery.ui.widget.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'ui/jquery.ui.widget.js') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 0d52fb534..4f47a008b 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -374,7 +374,7 @@ $.Widget.prototype = { }, _trigger: function( type, event, data ) { - var args, prop, orig, + var prop, orig, callback = this.options[ type ]; data = data || {}; @@ -397,13 +397,8 @@ $.Widget.prototype = { } this.element.trigger( event, data ); - - args = $.isArray( data ) ? - [ event ].concat( data ) : - [ event, data ]; - return !( $.isFunction( callback ) && - callback.apply( this.element[0], args ) === false || + callback.apply( this.element[0], [ event ].concat( data ) ) === false || event.isDefaultPrevented() ); } }; -- cgit v1.2.3