mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Widget: Properly set widgetEventPrefix when redefining a widget. Fixes #9316 - Widget: widgetEventPrefix is empty when widget is (occasionally) loaded twice.
This commit is contained in:
parent
9726cd72b6
commit
2eb89f0734
@ -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
|
||||
|
2
ui/jquery.ui.widget.js
vendored
2
ui/jquery.ui.widget.js
vendored
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user