Standardizing on .test() and .exec() - moving away from using .match() for RegExp. Fixes jQuery bug #4113.
This commit is contained in:
parent
a3b8ac413f
commit
0d5c3a68a0
12
src/ajax.js
12
src/ajax.js
|
@ -187,15 +187,15 @@ jQuery.extend({
|
|||
// Handle JSONP Parameter Callbacks
|
||||
if ( s.dataType == "jsonp" ) {
|
||||
if ( type == "GET" ) {
|
||||
if ( !s.url.match(jsre) )
|
||||
s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
|
||||
} else if ( !s.data || !s.data.match(jsre) )
|
||||
if ( jsre.test( !s.url ) )
|
||||
s.url += (/\?/.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
|
||||
} else if ( !s.data || !jsre.test(s.data) )
|
||||
s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
|
||||
s.dataType = "json";
|
||||
}
|
||||
|
||||
// Build temporary JSONP function
|
||||
if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
|
||||
if ( s.dataType == "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
|
||||
jsonp = "jsonp" + jsc++;
|
||||
|
||||
// Replace the =? sequence both in the query string and the data
|
||||
|
@ -228,12 +228,12 @@ jQuery.extend({
|
|||
// try replacing _= if it is there
|
||||
var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
|
||||
// if nothing was replaced, add timestamp to the end
|
||||
s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
|
||||
s.url = ret + ((ret == s.url) ? (/\?/.test(s.url) ? "&" : "?") + "_=" + ts : "");
|
||||
}
|
||||
|
||||
// If data is available, append data to url for get requests
|
||||
if ( s.data && type == "GET" ) {
|
||||
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
|
||||
s.url += (/\?/.test(s.url) ? "&" : "?") + s.data;
|
||||
}
|
||||
|
||||
// Watch for a new set of requests
|
||||
|
|
|
@ -214,7 +214,7 @@ jQuery.extend({
|
|||
if ( name in elem && notxml && !special ) {
|
||||
if ( set ){
|
||||
// We can't allow the type property to be changed (since it causes problems in IE)
|
||||
if ( name == "type" && elem.nodeName.match(/(button|input)/i) && elem.parentNode )
|
||||
if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode )
|
||||
throw "type property can't be changed";
|
||||
|
||||
elem[ name ] = value;
|
||||
|
@ -230,9 +230,9 @@ jQuery.extend({
|
|||
var attributeNode = elem.getAttributeNode( "tabIndex" );
|
||||
return attributeNode && attributeNode.specified
|
||||
? attributeNode.value
|
||||
: elem.nodeName.match(/(button|input|object|select|textarea)/i)
|
||||
: /(button|input|object|select|textarea)/i.test(elem.nodeName)
|
||||
? 0
|
||||
: elem.nodeName.match(/^(a|area)$/i) && elem.href
|
||||
: /^(a|area)$/i.test(elem.nodeName) && elem.href
|
||||
? 0
|
||||
: undefined;
|
||||
}
|
||||
|
|
|
@ -474,7 +474,7 @@ jQuery.extend({
|
|||
// It's included for backwards compatibility and plugins,
|
||||
// although they should work to migrate away.
|
||||
browser: {
|
||||
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
|
||||
version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1],
|
||||
safari: /webkit/.test( userAgent ),
|
||||
opera: /opera/.test( userAgent ),
|
||||
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
|
||||
|
|
|
@ -75,7 +75,7 @@ jQuery.extend({
|
|||
}
|
||||
|
||||
return style.filter && style.filter.indexOf("opacity=") >= 0 ?
|
||||
(parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
|
||||
(parseFloat( /opacity=([^)]*)/.exec(style.filter)[1] ) / 100) + '':
|
||||
"";
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ jQuery.extend({
|
|||
|
||||
// IE uses filters for opacity
|
||||
if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
|
||||
ret = (elem.currentStyle.filter || "").match(/opacity=([^)]*)/) ?
|
||||
ret = /opacity=([^)]*)/.test(elem.currentStyle.filter || "") ?
|
||||
(parseFloat(RegExp.$1) / 100) + "" :
|
||||
"";
|
||||
|
||||
|
@ -207,4 +207,4 @@ jQuery.extend({
|
|||
for ( var name in options )
|
||||
elem.style[ name ] = old[ name ];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -132,7 +132,7 @@ jQuery.fn.extend({
|
|||
if ( /toggle|show|hide/.test(val) )
|
||||
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
|
||||
else {
|
||||
var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
|
||||
var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val),
|
||||
start = e.cur(true) || 0;
|
||||
|
||||
if ( parts ) {
|
||||
|
|
|
@ -286,7 +286,7 @@ jQuery.extend({
|
|||
if ( typeof elem === "string" ) {
|
||||
// Fix "XHTML"-style tags in all browsers
|
||||
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
|
||||
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
|
||||
return /^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i.test(tag) ?
|
||||
all :
|
||||
front + "></" + tag + ">";
|
||||
});
|
||||
|
@ -302,7 +302,7 @@ jQuery.extend({
|
|||
!tags.indexOf("<leg") &&
|
||||
[ 1, "<fieldset>", "</fieldset>" ] ||
|
||||
|
||||
tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
|
||||
/^<(thead|tbody|tfoot|colg|cap)/.test(tags) &&
|
||||
[ 1, "<table>", "</table>" ] ||
|
||||
|
||||
!tags.indexOf("<tr") &&
|
||||
|
@ -349,7 +349,7 @@ jQuery.extend({
|
|||
|
||||
// IE completely kills leading whitespace when innerHTML is used
|
||||
if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
|
||||
div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
|
||||
div.insertBefore( context.createTextNode( /^\s*/.exec(elem)[0] ), div.firstChild );
|
||||
|
||||
elem = jQuery.makeArray( div.childNodes );
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ var Expr = Sizzle.selectors = {
|
|||
"": function(checkSet, part, isXML){
|
||||
var doneName = done++, checkFn = dirCheck;
|
||||
|
||||
if ( !part.match(/\W/) ) {
|
||||
if ( !/\W/.test(part) ) {
|
||||
var nodeCheck = part = isXML ? part : part.toUpperCase();
|
||||
checkFn = dirNodeCheck;
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ var Expr = Sizzle.selectors = {
|
|||
"~": function(checkSet, part, isXML){
|
||||
var doneName = done++, checkFn = dirCheck;
|
||||
|
||||
if ( typeof part === "string" && !part.match(/\W/) ) {
|
||||
if ( typeof part === "string" && !/\W/.test(part) ) {
|
||||
var nodeCheck = part = isXML ? part : part.toUpperCase();
|
||||
checkFn = dirNodeCheck;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ var Expr = Sizzle.selectors = {
|
|||
PSEUDO: function(match, curLoop, inplace, result, not){
|
||||
if ( match[1] === "not" ) {
|
||||
// If we're dealing with a complex expression, or a simple one
|
||||
if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
|
||||
if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) {
|
||||
match[3] = Sizzle(match[3], null, null, curLoop);
|
||||
} else {
|
||||
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
||||
|
|
Loading…
Reference in a new issue