]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Only use the event prefix from the base if we're redefining a widget. Fixes...
authorScott González <scott.gonzalez@gmail.com>
Fri, 9 Nov 2012 21:48:52 +0000 (16:48 -0500)
committerScott González <scott.gonzalez@gmail.com>
Tue, 13 Nov 2012 16:06:18 +0000 (11:06 -0500)
(cherry picked from commit 9e858ba14ac0ae26780581a34565e84e0ae108ef)

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

index 1c85898413014129c348444b957a679f57ed8057..69ffa2490c715f3adbbc33609ba015b0ad8bb3f1 100644 (file)
@@ -332,8 +332,8 @@ test( "re-init", function() {
        deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
 });
 
-test( "inheritance - options", function() {
-       expect( 4 );
+test( "inheritance", function() {
+       expect( 6 );
        // #5830 - Widget: Using inheritance overwrites the base classes options
        $.widget( "ui.testWidgetBase", {
                options: {
@@ -354,6 +354,8 @@ test( "inheritance - options", function() {
                }
        });
 
+       equal( $.ui.testWidgetBase.prototype.widgetEventPrefix, "testWidgetBase",
+               "base class event prefix" );
        deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
                key1: "foo",
                key2: "bar"
@@ -361,6 +363,8 @@ test( "inheritance - options", function() {
        deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
                "base class option array not overridden");
 
+       equal( $.ui.testWidgetExtension.prototype.widgetEventPrefix, "testWidgetExtension",
+               "extension class event prefix" );
        deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
                key1: "baz",
                key2: "bar"
index 333212f0a338cf4f78d8f7c14822b7c6871a3eab..2533448689673e27951af945e58875c0589376d6 100644 (file)
@@ -101,7 +101,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: basePrototype.widgetEventPrefix || name
+               widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
        }, prototype, {
                constructor: constructor,
                namespace: namespace,