mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Widget factory: Support passing multiple option hashes on init. Fixes #4784.
This commit is contained in:
parent
99d09ecfaf
commit
6c6218fa12
@ -57,4 +57,26 @@ test('zIndex', function() {
|
|||||||
equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
|
equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('widget factory, merge multiple option arguments', function() {
|
||||||
|
expect(1);
|
||||||
|
$.widget("ui.widgetTest", {
|
||||||
|
_init: function() {
|
||||||
|
same(this.options, {
|
||||||
|
disabled: false,
|
||||||
|
option1: "value1",
|
||||||
|
option2: "value2",
|
||||||
|
option3: "value3"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#main > :first").widgetTest({
|
||||||
|
option1: "valuex",
|
||||||
|
option2: "valuex",
|
||||||
|
option3: "value3"
|
||||||
|
}, {
|
||||||
|
option1: "value1",
|
||||||
|
option2: "value2"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -253,6 +253,11 @@ $.widget = function(name, prototype) {
|
|||||||
args = Array.prototype.slice.call(arguments, 1),
|
args = Array.prototype.slice.call(arguments, 1),
|
||||||
returnValue = this;
|
returnValue = this;
|
||||||
|
|
||||||
|
// allow multiple hashes to be passed on init
|
||||||
|
options = !isMethodCall && args.length
|
||||||
|
? $.extend.apply(null, arguments)
|
||||||
|
: options;
|
||||||
|
|
||||||
// prevent calls to internal methods
|
// prevent calls to internal methods
|
||||||
if (isMethodCall && options.substring(0, 1) == '_') {
|
if (isMethodCall && options.substring(0, 1) == '_') {
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user