Skip to content

Commit e27195b

Browse files
committed
Widget: Only use the event prefix from the base if we're redefining a widget. Fixes #8805 - Widget: widgetEventPrefix is incorrect when inheriting with jQuery UI 1.9.1.
(cherry picked from commit 9e858ba)
1 parent 41ec411 commit e27195b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/unit/widget/widget_core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ test( "re-init", function() {
332332
deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
333333
});
334334

335-
test( "inheritance - options", function() {
336-
expect( 4 );
335+
test( "inheritance", function() {
336+
expect( 6 );
337337
// #5830 - Widget: Using inheritance overwrites the base classes options
338338
$.widget( "ui.testWidgetBase", {
339339
options: {
@@ -354,13 +354,17 @@ test( "inheritance - options", function() {
354354
}
355355
});
356356

357+
equal( $.ui.testWidgetBase.prototype.widgetEventPrefix, "testWidgetBase",
358+
"base class event prefix" );
357359
deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
358360
key1: "foo",
359361
key2: "bar"
360362
}, "base class option object not overridden");
361363
deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
362364
"base class option array not overridden");
363365

366+
equal( $.ui.testWidgetExtension.prototype.widgetEventPrefix, "testWidgetExtension",
367+
"extension class event prefix" );
364368
deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
365369
key1: "baz",
366370
key2: "bar"

ui/jquery.ui.widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ $.widget = function( name, base, prototype ) {
101101
// TODO: remove support for widgetEventPrefix
102102
// always use the name + a colon as the prefix, e.g., draggable:start
103103
// don't prefix for widgets that aren't DOM-based
104-
widgetEventPrefix: basePrototype.widgetEventPrefix || name
104+
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
105105
}, prototype, {
106106
constructor: constructor,
107107
namespace: namespace,

0 commit comments

Comments
 (0)