aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-07-19 13:21:51 +0000
committerJohn Resig <jeresig@gmail.com>2009-07-19 13:21:51 +0000
commit0d5c3a68a092401089c9242bdafdb1b2534feb6a (patch)
tree0b52439fb625115252239bbbf66cfc39d0fae9ae
parenta3b8ac413f9c55994922c20b39223ab9ae6d1afa (diff)
downloadjquery-0d5c3a68a092401089c9242bdafdb1b2534feb6a.tar.gz
jquery-0d5c3a68a092401089c9242bdafdb1b2534feb6a.zip
Standardizing on .test() and .exec() - moving away from using .match() for RegExp. Fixes jQuery bug #4113.
-rw-r--r--src/ajax.js12
-rw-r--r--src/attributes.js6
-rw-r--r--src/core.js2
-rw-r--r--src/css.js6
-rw-r--r--src/fx.js2
-rw-r--r--src/manipulation.js6
-rw-r--r--src/selector.js6
7 files changed, 20 insertions, 20 deletions
diff --git a/src/ajax.js b/src/ajax.js
index beed45fbf..2e4c740da 100644
--- a/src/ajax.js
+++ b/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
diff --git a/src/attributes.js b/src/attributes.js
index 9e66df0ce..041bb29fc 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -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;
}
diff --git a/src/core.js b/src/core.js
index a74f0fec9..2a064c27e 100644
--- a/src/core.js
+++ b/src/core.js
@@ -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 ),
diff --git a/src/css.js b/src/css.js
index 94a021b6a..2395bdf59 100644
--- a/src/css.js
+++ b/src/css.js
@@ -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 ];
}
-}); \ No newline at end of file
+});
diff --git a/src/fx.js b/src/fx.js
index c5c05468a..65bb3f143 100644
--- a/src/fx.js
+++ b/src/fx.js
@@ -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 ) {
diff --git a/src/manipulation.js b/src/manipulation.js
index 55017c196..20a107565 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -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 );
}
diff --git a/src/selector.js b/src/selector.js
index 1f3ceb5c1..a7d94c39d 100644
--- a/src/selector.js
+++ b/src/selector.js
@@ -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);