Skip to content

Commit 9e858ba

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.
1 parent 254f2b3 commit 9e858ba

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/unit/widget/widget_core.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ test( "re-init", function() {
326326
deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
327327
});
328328

329-
test( "inheritance - options", function() {
330-
expect( 4 );
329+
test( "inheritance", function() {
330+
expect( 6 );
331331
// #5830 - Widget: Using inheritance overwrites the base classes options
332332
$.widget( "ui.testWidgetBase", {
333333
options: {
@@ -348,13 +348,17 @@ test( "inheritance - options", function() {
348348
}
349349
});
350350

351+
equal( $.ui.testWidgetBase.prototype.widgetEventPrefix, "testWidgetBase",
352+
"base class event prefix" );
351353
deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
352354
key1: "foo",
353355
key2: "bar"
354356
}, "base class option object not overridden");
355357
deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
356358
"base class option array not overridden");
357359

360+
equal( $.ui.testWidgetExtension.prototype.widgetEventPrefix, "testWidgetExtension",
361+
"extension class event prefix" );
358362
deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
359363
key1: "baz",
360364
key2: "bar"

ui/jquery.ui.widget.js

+1-1
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)