From 1ecf6e528a12c668ee876ae734d2429a106e47d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 16 Sep 2015 12:54:12 -0400 Subject: [PATCH] All: Delegate to base `_getCreateOptions()`. Ensures that any extensions to the base widget will be handled properly by individual widgets. --- tests/unit/widget/core.js | 5 ++++- ui/widget.js | 4 +++- ui/widgets/selectmenu.js | 6 +++++- ui/widgets/spinner.js | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/unit/widget/core.js b/tests/unit/widget/core.js index f6202410806..6ad1e74fc4b 100644 --- a/tests/unit/widget/core.js +++ b/tests/unit/widget/core.js @@ -267,7 +267,7 @@ test( "merge multiple option arguments", function() { } ); test( "._getCreateOptions()", function() { - expect( 3 ); + expect( 4 ); $.widget( "ui.testWidget", { options: { option1: "valuex", @@ -275,6 +275,9 @@ test( "._getCreateOptions()", function() { option3: "value3" }, _getCreateOptions: function() { + var superOptions = this._super(); + + deepEqual( superOptions, {}, "Base implementation returns empty object" ); // Support: IE8 // Strict equality fails when comparing this.window in ie8 diff --git a/ui/widget.js b/ui/widget.js index eabeb398166..2477595796a 100644 --- a/ui/widget.js +++ b/ui/widget.js @@ -322,7 +322,9 @@ $.Widget.prototype = { this._init(); }, - _getCreateOptions: $.noop, + _getCreateOptions: function() { + return {}; + }, _getCreateEventData: $.noop, diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js index 273e68594c0..820e6857054 100644 --- a/ui/widgets/selectmenu.js +++ b/ui/widgets/selectmenu.js @@ -646,7 +646,11 @@ return $.widget( "ui.selectmenu", { }, _getCreateOptions: function() { - return { disabled: this.element.prop( "disabled" ) }; + var options = this._super(); + + options.disabled = this.element.prop( "disabled" ); + + return options; }, _parseOptions: function( options ) { diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index 381c052bd76..369e29bd719 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -104,8 +104,8 @@ $.widget( "ui.spinner", { }, _getCreateOptions: function() { - var options = {}, - element = this.element; + var options = this._super(); + var element = this.element; $.each( [ "min", "max", "step" ], function( i, option ) { var value = element.attr( option );