Skip to content

Commit 15b5dbf

Browse files
gibson042dmethvin
authored andcommitted
Fix #12229, size/consistency improvements. Close jquerygh-887.
1 parent e8e3e90 commit 15b5dbf

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

src/ajax.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var // Document location
2-
ajaxLocation,
3-
// Document location segments
1+
var
2+
// Document location
43
ajaxLocParts,
4+
ajaxLocation,
55

66
rhash = /#.*$/,
77
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
@@ -518,7 +518,7 @@ jQuery.extend({
518518

519519
// Set data for the fake xhr object
520520
jqXHR.status = status;
521-
jqXHR.statusText = "" + ( nativeStatusText || statusText );
521+
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
522522

523523
// Success/Error
524524
if ( isSuccess ) {
@@ -578,14 +578,11 @@ jQuery.extend({
578578
// Extract dataTypes list
579579
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
580580

581-
// Determine if a cross-domain request is in order
581+
// A cross-domain request is in order when we have a protocol:host:port mismatch
582582
if ( s.crossDomain == null ) {
583-
parts = rurl.exec( s.url.toLowerCase() );
584-
s.crossDomain = !!( parts &&
585-
( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
586-
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
587-
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
588-
);
583+
parts = rurl.exec( s.url.toLowerCase() ) || false;
584+
s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
585+
( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
589586
}
590587

591588
// Convert data if not already a string

src/attributes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jQuery.fn.extend({
5757
setClass = " " + elem.className + " ";
5858

5959
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
60-
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
60+
if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
6161
setClass += classNames[ c ] + " ";
6262
}
6363
}
@@ -90,7 +90,7 @@ jQuery.fn.extend({
9090
// loop over each item in the removal list
9191
for ( c = 0, cl = removes.length; c < cl; c++ ) {
9292
// Remove until there is nothing to remove,
93-
while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
93+
while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
9494
className = className.replace( " " + removes[ c ] + " " , " " );
9595
}
9696
}
@@ -144,7 +144,7 @@ jQuery.fn.extend({
144144
i = 0,
145145
l = this.length;
146146
for ( ; i < l; i++ ) {
147-
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
147+
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
148148
return true;
149149
}
150150
}
@@ -322,7 +322,7 @@ jQuery.extend({
322322
return ret;
323323

324324
} else {
325-
elem.setAttribute( name, "" + value );
325+
elem.setAttribute( name, value + "" );
326326
return value;
327327
}
328328

@@ -586,7 +586,7 @@ if ( !jQuery.support.style ) {
586586
return elem.style.cssText.toLowerCase() || undefined;
587587
},
588588
set: function( elem, value ) {
589-
return ( elem.style.cssText = "" + value );
589+
return ( elem.style.cssText = value + "" );
590590
}
591591
};
592592
}

src/core.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ jQuery.extend({
559559
},
560560

561561
nodeName: function( elem, name ) {
562-
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
562+
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
563563
},
564564

565565
// args is for internal usage only
@@ -616,7 +616,7 @@ jQuery.extend({
616616
function( text ) {
617617
return text == null ?
618618
"" :
619-
text.toString().replace( rtrim, "" );
619+
( text + "" ).replace( rtrim, "" );
620620
},
621621

622622
// results is for internal usage only
@@ -762,7 +762,7 @@ jQuery.extend({
762762
};
763763

764764
// Set the guid of unique handler to the same of original handler, so it can be removed
765-
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
765+
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
766766

767767
return proxy;
768768
},

src/data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jQuery.extend({
66

77
deletedIds: [],
88

9-
// Please use with caution
9+
// Remove at next major release (1.9/2.0)
1010
uuid: 0,
1111

1212
// Unique for each copy of jQuery on the page
@@ -58,7 +58,7 @@ jQuery.extend({
5858
// Only DOM nodes need a new unique ID for each element since their data
5959
// ends up in the global cache
6060
if ( isNode ) {
61-
elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
61+
elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
6262
} else {
6363
id = internalKey;
6464
}
@@ -232,7 +232,7 @@ jQuery.fn.extend({
232232
for ( l = attr.length; i < l; i++ ) {
233233
name = attr[i].name;
234234

235-
if ( name.indexOf( "data-" ) === 0 ) {
235+
if ( !name.indexOf( "data-" ) ) {
236236
name = jQuery.camelCase( name.substring(5) );
237237

238238
dataAttr( elem, name, data[ name ] );

src/event.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ jQuery.event = {
365365
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
366366
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
367367
delegateCount = handlers.delegateCount,
368-
args = [].slice.call( arguments ),
368+
args = core_slice.call( arguments ),
369369
run_all = !event.exclusive && !event.namespace,
370370
special = jQuery.event.special[ event.type ] || {},
371371
handlerQueue = [];
@@ -966,7 +966,7 @@ jQuery.fn.extend({
966966
},
967967
undelegate: function( selector, types, fn ) {
968968
// ( namespace ) or ( selector, types [, fn] )
969-
return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
969+
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
970970
},
971971

972972
trigger: function( type, data ) {

0 commit comments

Comments
 (0)