aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuslan Yakhyaev <ruslan@ruslan.io>2014-01-03 18:19:32 +0100
committerScott González <scott.gonzalez@gmail.com>2014-01-16 12:12:04 -0500
commitbe2a339b2beaed69105abae91a118bc1c8669a1b (patch)
tree76a3f68fffed37521905fdeb58cf2dac6367b37d
parent28310ff55f062199fb2f187ea13d3561a879aea8 (diff)
downloadjquery-ui-be2a339b2beaed69105abae91a118bc1c8669a1b.tar.gz
jquery-ui-be2a339b2beaed69105abae91a118bc1c8669a1b.zip
Widget: Support events with dashes and colons
Fixes #9708 Closes gh-1159
-rw-r--r--tests/unit/widget/widget_core.js19
-rw-r--r--ui/jquery.ui.widget.js2
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 3cda48df9..2fdb9bc76 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -865,21 +865,36 @@ test( "_on() with delegate to descendent", function() {
});
test( "_on() to common element", function() {
- expect( 1 );
+ expect( 4 );
$.widget( "ui.testWidget", {
_create: function() {
this._on( this.document, {
- "customevent": "_handler"
+ "customevent": "_handler",
+ "with:colons": "_colonHandler",
+ "with-dashes": "_dashHandler",
+ "with-dashes:and-colons": "_commbinedHandler"
});
},
_handler: function() {
ok( true, "handler triggered" );
+ },
+ _colonHandler: function() {
+ ok( true, "colon handler triggered" );
+ },
+ _dashHandler: function() {
+ ok( true, "dash handler triggered" );
+ },
+ _commbinedHandler: function() {
+ ok( true, "combined handler triggered" );
}
});
var widget = $( "#widget" ).testWidget().testWidget( "instance" );
$( "#widget-wrapper" ).testWidget();
widget.destroy();
$( document ).trigger( "customevent" );
+ $( document ).trigger( "with:colons" );
+ $( document ).trigger( "with-dashes" );
+ $( document ).trigger( "with-dashes:and-colons" );
});
test( "_off() - single event", function() {
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 97f5fd7e0..b62b877f7 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -414,7 +414,7 @@ $.Widget.prototype = {
handler.guid || handlerProxy.guid || $.guid++;
}
- var match = event.match( /^(\w+)\s*(.*)$/ ),
+ var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
eventName = match[1] + instance.eventNamespace,
selector = match[2];
if ( selector ) {