]> 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>
Fri, 9 Nov 2012 21:49:03 +0000 (16:49 -0500)
tests/unit/widget/widget_core.js
ui/jquery.ui.widget.js

index 418cc4d397a99f59ee235fe67b58a9f96ecc567a..18b93d92e90edd044bc3e9e229906d513ac1c5a9 100644 (file)
@@ -326,8 +326,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: {
@@ -348,6 +348,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"
@@ -355,6 +357,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 02f89bc9885a7d5ae16d16495bec16fb14c11d57..06f25576afeadc6e0512ef29168d763b81059d23 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,