diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-10-24 10:41:48 -0400 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-10-24 10:42:21 -0400 |
commit | 721a4b4ae027b140ca280bbc8fb8ed334081b184 (patch) | |
tree | 26d6d48d83d125ed2ef0c778e23cb863b4eba843 /tests | |
parent | 848ab485839b6dd26f2b6c6680141d95cab32ceb (diff) | |
download | jquery-ui-721a4b4ae027b140ca280bbc8fb8ed334081b184.tar.gz jquery-ui-721a4b4ae027b140ca280bbc8fb8ed334081b184.zip |
Widget: Fix _on to use element argument for delegated events. Fixes #8658 - Widget: this._on delegates using instance.widget() instead of passed element
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/widget/widget_core.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 624ccf743..7bddc7f5c 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -760,6 +760,30 @@ test( "_on() with delegate", function() { $.ui.testWidget(); }); +test( "_on() with delegate to descendent", function() { + expect( 4 ); + $.widget( "ui.testWidget", { + _create: function() { + this.target = $( "<p><strong>hello</strong> world</p>" ); + this.child = this.target.children(); + this._on( this.target, { + "keyup": "handlerDirect", + "keyup strong": "handlerDelegated" + }); + this.child.trigger( "keyup" ); + }, + handlerDirect: function( event ) { + deepEqual( event.currentTarget, this.target[ 0 ] ); + deepEqual( event.target, this.child[ 0 ] ); + }, + handlerDelegated: function( event ) { + deepEqual( event.currentTarget, this.child[ 0 ] ); + deepEqual( event.target, this.child[ 0 ] ); + } + }); + $.ui.testWidget(); +}); + test( "_on() to common element", function() { expect( 1 ); $.widget( "ui.testWidget", { |