]> source.dussan.org Git - jquery-ui.git/commitdiff
All: Delegate to base `_getCreateOptions()`.
authorScott González <scott.gonzalez@gmail.com>
Wed, 16 Sep 2015 16:54:12 +0000 (12:54 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 17 Sep 2015 12:47:28 +0000 (08:47 -0400)
Ensures that any extensions to the base widget will be handled properly by
individual widgets.

Closes gh-1598

tests/unit/widget/core.js
ui/widget.js
ui/widgets/selectmenu.js
ui/widgets/spinner.js

index f62024108069df90f1e0d53b570548647159ab27..6ad1e74fc4bb7c502a1a89a782a504cd9df8129c 100644 (file)
@@ -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
index eabeb398166de4292df5bfca219f1632bb1b80fd..2477595796a9d775935ce9279352558ff60547f0 100644 (file)
@@ -322,7 +322,9 @@ $.Widget.prototype = {
                this._init();
        },
 
-       _getCreateOptions: $.noop,
+       _getCreateOptions: function() {
+               return {};
+       },
 
        _getCreateEventData: $.noop,
 
index 273e68594c04519b1c45879e497adf3b49539b64..820e68570545edcec08d43ce78157d10daa6ce9c 100644 (file)
@@ -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 ) {
index 381c052bd7684a4d896da88ddc7c735acc4bad57..369e29bd719daa6745e3ce2706c0f6377d040407 100644 (file)
@@ -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 );