aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-04-29 07:36:31 -0700
committerDave Methvin <dave.methvin@gmail.com>2011-04-29 07:36:31 -0700
commite2bace8fa129c2bf3fe5bd382a4b05d96e8cf245 (patch)
treec9d30a7140498ea0ddeded24f9c6d439821749d2
parente5f4ec846ceff3e97711e45e968f6cead5e9a674 (diff)
parentbf678fd9d6209f77a37b9dd29e7ea621cf3bd3f7 (diff)
downloadjquery-e2bace8fa129c2bf3fe5bd382a4b05d96e8cf245.tar.gz
jquery-e2bace8fa129c2bf3fe5bd382a4b05d96e8cf245.zip
Merged pull request #361 from rwldrn/9008a.
Restored /g flag to rspaces; Adds unit tests; Supplements #9008
-rw-r--r--src/ajax.js6
-rw-r--r--src/attributes.js8
-rw-r--r--src/event.js2
-rw-r--r--test/unit/event.js16
4 files changed, 24 insertions, 8 deletions
diff --git a/src/ajax.js b/src/ajax.js
index 2d048479c..a16717b00 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -13,7 +13,7 @@ var r20 = /%20/g,
rquery = /\?/,
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
rselectTextarea = /^(?:select|textarea)/i,
- rspaces = /\s+/,
+ rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/,
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
@@ -71,7 +71,7 @@ function addToPrefiltersOrTransports( structure ) {
}
if ( jQuery.isFunction( func ) ) {
- var dataTypes = dataTypeExpression.toLowerCase().split( rspaces ),
+ var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
i = 0,
length = dataTypes.length,
dataType,
@@ -599,7 +599,7 @@ jQuery.extend({
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
// Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspaces );
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
// Determine if a cross-domain request is in order
if ( s.crossDomain == null ) {
diff --git a/src/attributes.js b/src/attributes.js
index 43d72ae9b..ade38bcaf 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -1,7 +1,7 @@
(function( jQuery ) {
var rclass = /[\n\t\r]/g,
- rspaces = /\s+/,
+ rspace = /\s+/,
rreturn = /\r/g,
rtype = /^(?:button|input)$/i,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
@@ -43,7 +43,7 @@ jQuery.fn.extend({
}
if ( value && typeof value === "string" ) {
- var classNames = (value || "").split( rspaces );
+ var classNames = (value || "").split( rspace );
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
@@ -79,7 +79,7 @@ jQuery.fn.extend({
}
if ( (value && typeof value === "string") || value === undefined ) {
- var classNames = (value || "").split( rspaces );
+ var classNames = (value || "").split( rspace );
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
@@ -120,7 +120,7 @@ jQuery.fn.extend({
i = 0,
self = jQuery( this ),
state = stateVal,
- classNames = value.split( rspaces );
+ classNames = value.split( rspace );
while ( (className = classNames[ i++ ]) ) {
// check each className given, space seperated list
diff --git a/src/event.js b/src/event.js
index 09ea02e75..05e79d358 100644
--- a/src/event.js
+++ b/src/event.js
@@ -4,7 +4,7 @@ var hasOwn = Object.prototype.hasOwnProperty,
rnamespaces = /\.(.*)$/,
rformElems = /^(?:textarea|input|select)$/i,
rperiod = /\./g,
- rspaces = /\s+/,
+ rspaces = / /g,
rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) {
return nm.replace(rescape, "\\$&");
diff --git a/test/unit/event.js b/test/unit/event.js
index 0424538d6..13877e019 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -68,6 +68,22 @@ test("bind(), multiple events at once", function() {
equals( mouseoverCounter, 1, "bind() with multiple events at once" );
});
+test("bind(), five events at once", function() {
+ expect(1);
+
+ var count = 0,
+ handler = function(event) {
+ count++;
+ };
+
+ jQuery("#firstp").bind("click mouseover foo bar baz", handler)
+ .trigger("click").trigger("mouseover")
+ .trigger("foo").trigger("bar")
+ .trigger("baz");
+
+ equals( count, 5, "bind() five events at once" );
+});
+
test("bind(), multiple events at once and namespaces", function() {
expect(7);