(function( jQuery ) {
var jsc = jQuery.now(),
- rscript = /<script(.|\s)*?\/script>/gi,
- rselectTextarea = /select|textarea/i,
- rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
+ rselectTextarea = /^(?:select|textarea)/i,
+ rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ rbracket = /\[\]$/,
jsre = /\=\?(&|$)/,
rquery = /\?/,
- rts = /(\?|&)_=.*?(&|$)/,
+ rts = /([?&])_=[^&]*(&?)/,
rurl = /^(\w+:)?\/\/([^\/?#]+)/,
r20 = /%20/g,
// See if a selector was specified
self.html( selector ?
// Create a dummy div to hold the results
- jQuery("<div />")
+ jQuery("<div>")
// inject the contents of the document in, removing the scripts
// to avoid any 'Permission Denied' errors in IE
.append(res.responseText.replace(rscript, ""))
if ( jQuery.isArray(obj) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
- if ( traditional || /\[\]$/.test( prefix ) ) {
+ if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
var rclass = /[\n\t]/g,
rspace = /\s+/,
rreturn = /\r/g,
- rspecialurl = /href|src|style/,
- rtype = /(button|input)/i,
- rfocusable = /(button|input|object|select|textarea)/i,
- rclickable = /^(a|area)$/i,
- rradiocheck = /radio|checkbox/;
+ rspecialurl = /^(?:href|src|style)$/,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea)?$/i,
+ rradiocheck = /^(?:radio|checkbox)$/i;
jQuery.fn.extend({
attr: function( name, value ) {
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
- quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w\-]+)$/,
+ quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w-]+)$)/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/,
// Check if a string has a non-whitespace character in it
rnotwhite = /\S/,
+ rwhite = /\s/,
// Used for trimming whitespace
trimLeft = /^\s+/,
trimRight = /\s+$/,
+ // Check for non-word characters
+ rnonword = /\W/,
+
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+
+ // Useragent RegExp
+ rwebkit = /(webkit)[ \/]([\w.]+)/,
+ ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
+ rmsie = /(msie) ([\w.]+)/,
+ rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
+
// Keep a UserAgent string for use with jQuery.browser
userAgent = navigator.userAgent,
}
// HANDLE: $("TAG")
- } else if ( !context && /^\w+$/.test( selector ) ) {
+ } else if ( !context && !rnonword.test( selector ) ) {
this.selector = selector;
this.context = document;
selector = document.getElementsByTagName( selector );
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
- if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
- .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
+ if ( rvalidchars.test(data.replace(rvalidescape, "@")
+ .replace(rvalidtokens, "]")
+ .replace(rvalidbraces, "")) ) {
// Try to use the native JSON parser first
return window.JSON && window.JSON.parse ?
uaMatch: function( ua ) {
ua = ua.toLowerCase();
- var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
- /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
- /(msie) ([\w.]+)/.exec( ua ) ||
- !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
+ var match = rwebkit.exec( ua ) ||
+ ropera.exec( ua ) ||
+ rmsie.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
[];
return { browser: match[1] || "", version: match[2] || "0" };
// Verify that \s matches non-breaking spaces
// (IE fails on this test)
-if ( !/\s/.test( "\xA0" ) ) {
+if ( !rwhite.test( "\xA0" ) ) {
trimLeft = /^[\s\xA0]+/;
trimRight = /[\s\xA0]+$/;
}
(function( jQuery ) {
var windowData = {},
- rbrace = /^(?:\{.*\}|\[.*\])$/;
+ rbrace = /^(?:\{.*\}|\[.*\])$/,
+ rdigit = /\d/;
jQuery.extend({
cache: {},
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
- /\d/.test( data ) && !isNaN( data ) ? parseFloat( data ) :
+ rdigit.test( data ) && !isNaN( data ) ? parseFloat( data ) :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} catch( e ) {}
(function( jQuery ) {
var elemdisplay = {},
- rfxtypes = /toggle|show|hide/,
+ rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
timerId,
fxAttrs = [
display = elemdisplay[ nodeName ];
} else {
- var elem = jQuery("<" + nodeName + " />").appendTo("body");
+ var elem = jQuery("<" + nodeName + ">").appendTo("body");
display = elem.css("display");
(function( jQuery ) {
var rnamespaces = /\.(.*)$/,
+ rformElems = /^(?:textarea|input|select)$/i,
+ rperiod = /\./g,
+ rspace = / /g,
+ rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) {
- return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
- return "\\" + ch;
- });
+ return nm.replace(rescape, "\\$&");
};
/*
jQuery.event.trigger( event, data, parent, true );
} else if ( !event.isDefaultPrevented() ) {
- var target = event.target, old, targetType = type.replace(/\..*$/, ""),
+ var target = event.target, old, targetType = type.replace(rnamespaces, ""),
isClick = jQuery.nodeName(target, "a") && targetType === "click",
special = jQuery.event.special[ targetType ] || {};
// change delegation, happens here so we have bind.
if ( !jQuery.support.changeBubbles ) {
- var formElems = /textarea|input|select/i,
-
- changeFilters,
+ var changeFilters,
getVal = function( elem ) {
var type = elem.type, val = elem.value;
testChange = function testChange( e ) {
var elem = e.target, data, val;
- if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
return;
}
jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
}
- return formElems.test( this.nodeName );
+ return rformElems.test( this.nodeName );
},
teardown: function( namespaces ) {
jQuery.event.remove( this, ".specialChange" );
- return formElems.test( this.nodeName );
+ return rformElems.test( this.nodeName );
}
};
}
function liveConvert( type, selector ) {
- return (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
+ return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
}
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
- rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
- rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/,
- rnocache = /<script|<object|<embed|<option|<style/i,
+ rnocache = /<(?:script|object|embed|option|style)/i,
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
- fcloseTag = function( all, front, tag ) {
- return rselfClosing.test( tag ) ?
- all :
- front + "></" + tag + ">";
- },
+ raction = /\=([^="'>\s]+\/)>/g,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
return jQuery.clean([html.replace(rinlinejQuery, "")
// Handle the case in IE 8 where action=/test/> self-closes a tag
- .replace(/\=([^="'>\s]+\/)>/g, '="$1">')
+ .replace(raction, '="$1">')
.replace(rleadingWhitespace, "")], ownerDocument)[0];
} else {
return this.cloneNode(true);
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
- value = value.replace(rxhtmlTag, fcloseTag);
+ value = value.replace(rxhtmlTag, "<$1></$2>");
try {
for ( var i = 0, l = this.length; i < l; i++ ) {
} else if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
- elem = elem.replace(rxhtmlTag, fcloseTag);
+ elem = elem.replace(rxhtmlTag, "<$1></$2>");
// Trim whitespace, otherwise indexOf won't work as expected
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
(function( jQuery ) {
+var rtable = /^t(?:able|d|h)$/i,
+ rroot = /^(?:body|html)$/i;
+
if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) {
var elem = this[0];
top += elem.offsetTop;
left += elem.offsetLeft;
- if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
top += parseFloat( computedStyle.borderTopWidth ) || 0;
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
}
// Get correct offsets
offset = this.offset(),
- parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+ parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
offsetParent: function() {
return this.map(function() {
var offsetParent = this.offsetParent || document.body;
- while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent;