summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-11-09 16:48:52 -0500
committerScott González <scott.gonzalez@gmail.com>2012-11-13 11:06:18 -0500
commite27195ba443fd18e9a791fc926f226e5fc29f321 (patch)
tree082d89f2ab8cb14f40c71d1f06e5bc6cdb87015e
parent41ec41126dba9c2dd50ba0936e74237519bd92df (diff)
downloadjquery-ui-e27195ba443fd18e9a791fc926f226e5fc29f321.tar.gz
jquery-ui-e27195ba443fd18e9a791fc926f226e5fc29f321.zip
Widget: Only use the event prefix from the base if we're redefining a widget. Fixes #8805 - Widget: widgetEventPrefix is incorrect when inheriting with jQuery UI 1.9.1.
(cherry picked from commit 9e858ba14ac0ae26780581a34565e84e0ae108ef)
-rw-r--r--tests/unit/widget/widget_core.js8
-rw-r--r--ui/jquery.ui.widget.js2
2 files changed, 7 insertions, 3 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 1c8589841..69ffa2490 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -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"
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 333212f0a..253344868 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -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,