aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/widget/widget_core.js10
-rw-r--r--ui/jquery.ui.widget.js2
2 files changed, 11 insertions, 1 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 0d97742ff..3268b756d 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -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
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 741ac74d7..9fc0136c4 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -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,