aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/widget
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-06-10 20:55:04 +0200
committerScott González <scott.gonzalez@gmail.com>2012-06-14 10:39:41 -0400
commit28b14ec47cfeb3c58e44f35170cdd8a9270aceae (patch)
tree57b21aac4c95f31f6fe4677d271898e95f7c8e2c /tests/unit/widget
parent4a215e3f7215e17e0010d9439a78f74fd2c2fd66 (diff)
downloadjquery-ui-28b14ec47cfeb3c58e44f35170cdd8a9270aceae.tar.gz
jquery-ui-28b14ec47cfeb3c58e44f35170cdd8a9270aceae.zip
Generate a uuid for each widget for unique namespaces. Fixes #8385 - Widget: _bind() on elements such as document are dangerous
Diffstat (limited to 'tests/unit/widget')
-rw-r--r--tests/unit/widget/widget_core.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 3dfaf1918..1e40c4080 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -711,9 +711,10 @@ test( "_on() with delegate", function() {
expect( 8 );
$.widget( "ui.testWidget", {
_create: function() {
+ var uuid = this.uuid;
this.element = {
bind: function( event, handler ) {
- equal( event, "click.testWidget" );
+ equal( event, "click.testWidget" + uuid );
ok( $.isFunction(handler) );
},
trigger: $.noop
@@ -722,7 +723,7 @@ test( "_on() with delegate", function() {
return {
delegate: function( selector, event, handler ) {
equal( selector, "a" );
- equal( event, "click.testWidget" );
+ equal( event, "click.testWidget" + uuid );
ok( $.isFunction(handler) );
}
};
@@ -735,7 +736,7 @@ test( "_on() with delegate", function() {
return {
delegate: function( selector, event, handler ) {
equal( selector, "form fieldset > input" );
- equal( event, "change.testWidget" );
+ equal( event, "change.testWidget" + uuid );
ok( $.isFunction(handler) );
}
};
@@ -748,6 +749,24 @@ test( "_on() with delegate", function() {
$.ui.testWidget();
});
+test( "_bind() to common element", function() {
+ expect( 1 );
+ $.widget( "ui.testWidget", {
+ _create: function() {
+ this._bind( this.document, {
+ "customevent": "_handler"
+ });
+ },
+ _handler: function() {
+ ok( true, "handler triggered" );
+ }
+ });
+ var widget = $( "#widget" ).testWidget().data( "testWidget" );
+ $( "#widget-wrapper" ).testWidget();
+ widget.destroy();
+ $( document ).trigger( "customevent" );
+});
+
test( "._hoverable()", function() {
$.widget( "ui.testWidget", {
_create: function() {