forked from jquery/jquery-ui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Widget: Deep extend options when creating a new plugin. Fixes #5830 -…
… Widget: Using inheritance overwrites the base classes options.
- Loading branch information
1 parent
06f721b
commit f24bc0f
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* widget unit tests | ||
*/ | ||
(function($) { | ||
|
||
module('widget: tickets'); | ||
|
||
test('#5830 - Widget: Using inheritance overwrites the base classes options', function() { | ||
$.widget( "ui.testWidgetBase", { | ||
options: { | ||
obj: { | ||
key1: "foo", | ||
key2: "bar" | ||
}, | ||
arr: [ "testing" ] | ||
} | ||
}); | ||
|
||
$.widget( "ui.testWidgetExtension", $.ui.testWidgetBase, { | ||
options: { | ||
obj: { | ||
key1: "baz" | ||
}, | ||
arr: [ "alpha", "beta" ] | ||
} | ||
}); | ||
|
||
same( $.ui.testWidgetBase.prototype.options.obj, { | ||
key1: "foo", | ||
key2: "bar" | ||
}, "base class option object not overridden"); | ||
same( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ], | ||
"base class option array not overridden"); | ||
|
||
same( $.ui.testWidgetExtension.prototype.options.obj, { | ||
key1: "baz", | ||
key2: "bar" | ||
}, "extension class option object extends base"); | ||
same( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ], | ||
"extension class option array overwrites base"); | ||
|
||
delete $.ui.testWidgetBase; | ||
delete $.ui.testWidgetExtension; | ||
}); | ||
|
||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters