Skip to content

Commit

Permalink
Widget: Only use the event prefix from the base if we're redefining a…
Browse files Browse the repository at this point in the history
… widget. Fixes #8805 - Widget: widgetEventPrefix is incorrect when inheriting with jQuery UI 1.9.1.

(cherry picked from commit 9e858ba)
  • Loading branch information
scottgonzalez committed Nov 13, 2012
1 parent 41ec411 commit e27195b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tests/unit/widget/widget_core.js
Expand Up @@ -332,8 +332,8 @@ test( "re-init", function() {
deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
});

test( "inheritance - options", function() {
expect( 4 );
test( "inheritance", function() {
expect( 6 );
// #5830 - Widget: Using inheritance overwrites the base classes options
$.widget( "ui.testWidgetBase", {
options: {
Expand All @@ -354,13 +354,17 @@ test( "inheritance - options", function() {
}
});

equal( $.ui.testWidgetBase.prototype.widgetEventPrefix, "testWidgetBase",
"base class event prefix" );
deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
key1: "foo",
key2: "bar"
}, "base class option object not overridden");
deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
"base class option array not overridden");

equal( $.ui.testWidgetExtension.prototype.widgetEventPrefix, "testWidgetExtension",
"extension class event prefix" );
deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
key1: "baz",
key2: "bar"
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.widget.js
Expand Up @@ -101,7 +101,7 @@ $.widget = function( name, base, prototype ) {
// TODO: remove support for widgetEventPrefix
// always use the name + a colon as the prefix, e.g., draggable:start
// don't prefix for widgets that aren't DOM-based
widgetEventPrefix: basePrototype.widgetEventPrefix || name
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
}, prototype, {
constructor: constructor,
namespace: namespace,
Expand Down

0 comments on commit e27195b

Please sign in to comment.