Skip to content

Commit 2eb89f0

Browse files
committed
Widget: Properly set widgetEventPrefix when redefining a widget. Fixes #9316 - Widget: widgetEventPrefix is empty when widget is (occasionally) loaded twice.
1 parent 9726cd7 commit 2eb89f0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/unit/widget/widget_core.js

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

334+
test( "redeclare", function() {
335+
expect( 2 );
336+
337+
$.widget( "ui.testWidget", {} );
338+
equal( $.ui.testWidget.prototype.widgetEventPrefix, "testWidget" );
339+
340+
$.widget( "ui.testWidget", {} );
341+
equal( $.ui.testWidget.prototype.widgetEventPrefix, "testWidget" );
342+
});
343+
334344
test( "inheritance", function() {
335345
expect( 6 );
336346
// #5830 - Widget: Using inheritance overwrites the base classes options

ui/jquery.ui.widget.js

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

0 commit comments

Comments
 (0)