aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/widget/widget_core.js30
-rw-r--r--ui/jquery.ui.widget.js2
2 files changed, 20 insertions, 12 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 8cacdd47d..41ae8ffb4 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -673,23 +673,31 @@ test( "_bind() with delegate", function() {
this.element = {
bind: function( event, handler ) {
equal( event, "click.testWidget" );
- ok( $.isFunction(handler) );
- },
- delegate: function( selector, event, handler ) {
- equal( selector, "a" );
- equal( event, "click.testWidget" );
- ok( $.isFunction(handler) );
+ ok( $.isFunction(handler) );
},
trigger: $.noop
};
+ this.widget = function() {
+ return {
+ delegate: function( selector, event, handler ) {
+ equal( selector, "a" );
+ equal( event, "click.testWidget" );
+ ok( $.isFunction(handler) );
+ }
+ };
+ };
this._bind({
"click": "handler",
- "click a": "handler",
+ "click a": "handler"
});
- this.element.delegate = function( selector, event, handler ) {
- equal( selector, "form fieldset > input" );
- equal( event, "change.testWidget" );
- ok( $.isFunction(handler) );
+ this.widget = function() {
+ return {
+ delegate: function( selector, event, handler ) {
+ equal( selector, "form fieldset > input" );
+ equal( event, "change.testWidget" );
+ ok( $.isFunction(handler) );
+ }
+ };
};
this._bind({
"change form fieldset > input": "handler"
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 4c538d020..5b7942600 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -326,7 +326,7 @@ $.Widget.prototype = {
eventName = match[1] + "." + instance.widgetName,
selector = match[2];
if ( selector ) {
- element.delegate( selector, eventName, handlerProxy );
+ instance.widget().delegate( selector, eventName, handlerProxy );
} else {
element.bind( eventName, handlerProxy );
}