]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Properly set widgetEventPrefix when redefining a widget. Fixes #9316 - Widget...
authorScott González <scott.gonzalez@gmail.com>
Mon, 20 May 2013 15:30:49 +0000 (11:30 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 26 Nov 2013 15:16:01 +0000 (10:16 -0500)
(cherry picked from commit 2eb89f07341a557084fa3363fe22afe62530654d)

tests/unit/widget/widget_core.js
ui/jquery.ui.widget.js

index 8102b1f4fa84d8ffda6ded4c5d9daf8005b091b4..86b6ca5f96b2e47801761bf6fa8e5d42b035c591 100644 (file)
@@ -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
index c581e4b81567911211352d6f0208a1898570cc51..050125fa9f1c3003bde203093cd3e4275373cdc7 100644 (file)
@@ -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,