Skip to content

Commit

Permalink
Widget: Properly set widgetEventPrefix when redefining a widget. Fixe…
Browse files Browse the repository at this point in the history
…s #9316 - Widget: widgetEventPrefix is empty when widget is (occasionally) loaded twice.

(cherry picked from commit 2eb89f0)
  • Loading branch information
scottgonzalez committed Nov 26, 2013
1 parent 511bd98 commit c241313
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/unit/widget/widget_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ test( "re-init", function() {
deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
});

test( "redeclare", function() {
expect( 2 );

$.widget( "ui.testWidget", {} );
equal( $.ui.testWidget.prototype.widgetEventPrefix, "testWidget" );

$.widget( "ui.testWidget", {} );
equal( $.ui.testWidget.prototype.widgetEventPrefix, "testWidget" );
});

test( "inheritance", function() {
expect( 6 );
// #5830 - Widget: Using inheritance overwrites the base classes options
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,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: existingConstructor ? basePrototype.widgetEventPrefix : name
widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
}, proxiedPrototype, {
constructor: constructor,
namespace: namespace,
Expand Down

0 comments on commit c241313

Please sign in to comment.