Widget: Improve readability in $.widget.bridge()

Closes gh-1409
This commit is contained in:
Giovanni Giacobbi 2014-12-22 00:35:24 +01:00 committed by Scott González
parent b6bec797d6
commit 713688dccd

View File

@ -195,11 +195,6 @@ $.widget.bridge = function( name, object ) {
args = widget_slice.call( arguments, 1 ), args = widget_slice.call( arguments, 1 ),
returnValue = this; returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.widget.extend.apply( null, [ options ].concat(args) ) :
options;
if ( isMethodCall ) { if ( isMethodCall ) {
this.each(function() { this.each(function() {
var methodValue, var methodValue,
@ -224,6 +219,12 @@ $.widget.bridge = function( name, object ) {
} }
}); });
} else { } else {
// Allow multiple hashes to be passed on init
if ( args.length ) {
options = $.widget.extend.apply( null, [ options ].concat(args) );
}
this.each(function() { this.each(function() {
var instance = $.data( this, fullName ); var instance = $.data( this, fullName );
if ( instance ) { if ( instance ) {