Skip to content

Commit

Permalink
All: Delegate to base _getCreateOptions().
Browse files Browse the repository at this point in the history
Ensures that any extensions to the base widget will be handled properly by
individual widgets.

Closes gh-1598
  • Loading branch information
scottgonzalez committed Sep 17, 2015
1 parent afbcdbe commit e19d462
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tests/unit/widget/core.js
Expand Up @@ -267,14 +267,17 @@ test( "merge multiple option arguments", function() {
} ); } );


test( "._getCreateOptions()", function() { test( "._getCreateOptions()", function() {
expect( 3 ); expect( 4 );
$.widget( "ui.testWidget", { $.widget( "ui.testWidget", {
options: { options: {
option1: "valuex", option1: "valuex",
option2: "valuex", option2: "valuex",
option3: "value3" option3: "value3"
}, },
_getCreateOptions: function() { _getCreateOptions: function() {
var superOptions = this._super();

deepEqual( superOptions, {}, "Base implementation returns empty object" );


// Support: IE8 // Support: IE8
// Strict equality fails when comparing this.window in ie8 // Strict equality fails when comparing this.window in ie8
Expand Down
4 changes: 3 additions & 1 deletion ui/widget.js
Expand Up @@ -322,7 +322,9 @@ $.Widget.prototype = {
this._init(); this._init();
}, },


_getCreateOptions: $.noop, _getCreateOptions: function() {
return {};
},


_getCreateEventData: $.noop, _getCreateEventData: $.noop,


Expand Down
6 changes: 5 additions & 1 deletion ui/widgets/selectmenu.js
Expand Up @@ -646,7 +646,11 @@ return $.widget( "ui.selectmenu", {
}, },


_getCreateOptions: function() { _getCreateOptions: function() {
return { disabled: this.element.prop( "disabled" ) }; var options = this._super();

options.disabled = this.element.prop( "disabled" );

return options;
}, },


_parseOptions: function( options ) { _parseOptions: function( options ) {
Expand Down
4 changes: 2 additions & 2 deletions ui/widgets/spinner.js
Expand Up @@ -104,8 +104,8 @@ $.widget( "ui.spinner", {
}, },


_getCreateOptions: function() { _getCreateOptions: function() {
var options = {}, var options = this._super();
element = this.element; var element = this.element;


$.each( [ "min", "max", "step" ], function( i, option ) { $.each( [ "min", "max", "step" ], function( i, option ) {
var value = element.attr( option ); var value = element.attr( option );
Expand Down

0 comments on commit e19d462

Please sign in to comment.