Commit 2ef761af authored by Timmy Willison's avatar Timmy Willison

Release 3.0.0-beta1

parent 6fc01e29
...@@ -272,4 +272,9 @@ Christian Grete <webmaster@christiangrete.com> ...@@ -272,4 +272,9 @@ Christian Grete <webmaster@christiangrete.com>
Liza Ramo <liza.h.ramo@gmail.com> Liza Ramo <liza.h.ramo@gmail.com>
Julian Alexander Murillo <julian.alexander.murillo@gmail.com> Julian Alexander Murillo <julian.alexander.murillo@gmail.com>
Joelle Fleurantin <joasqueeniebee@gmail.com> Joelle Fleurantin <joasqueeniebee@gmail.com>
Jae Sung Park <alberto.park@gmail.com>
Jun Sun <klsforever@gmail.com> Jun Sun <klsforever@gmail.com>
Josh Soref <apache@soref.com>
Henry Wong <henryw4k@gmail.com>
Jon Dufresne <jon.dufresne@gmail.com>
Martijn W. van der Lee <martijn@vanderlee.com>
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
"name": "jquery", "name": "jquery",
"title": "jQuery", "title": "jQuery",
"description": "JavaScript library for DOM operations", "description": "JavaScript library for DOM operations",
"version": "2.2.0", "version": "3.0.0-beta1",
"main": "dist/jquery.js", "main": "dist/jquery.js",
"homepage": "http://jquery.com", "homepage": "https://jquery.com",
"author": { "author": {
"name": "jQuery Foundation and other contributors", "name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery/blob/2.2.0/AUTHORS.txt" "url": "https://github.com/jquery/jquery/blob/3.0.0-beta1/AUTHORS.txt"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -41,11 +41,14 @@ ...@@ -41,11 +41,14 @@
"gzip-js": "0.3.2", "gzip-js": "0.3.2",
"jsdom": "5.6.1", "jsdom": "5.6.1",
"load-grunt-tasks": "1.0.0", "load-grunt-tasks": "1.0.0",
"native-promise-only": "0.7.8-a",
"promises-aplus-tests": "2.1.0",
"q": "1.1.2",
"qunitjs": "1.17.1", "qunitjs": "1.17.1",
"qunit-assert-step": "1.0.3", "qunit-assert-step": "1.0.3",
"requirejs": "2.1.17", "requirejs": "2.1.17",
"sinon": "1.10.3", "sinon": "1.10.3",
"sizzle": "2.2.1", "sizzle": "2.3.0",
"strip-json-comments": "1.0.3", "strip-json-comments": "1.0.3",
"testswarm": "1.1.0", "testswarm": "1.1.0",
"win-spawn": "2.0.0" "win-spawn": "2.0.0"
......
...@@ -14,6 +14,7 @@ define( [ ...@@ -14,6 +14,7 @@ define( [
], function( jQuery, document, rnotwhite, location, nonce, rquery ) { ], function( jQuery, document, rnotwhite, location, nonce, rquery ) {
var var
r20 = /%20/g,
rhash = /#.*$/, rhash = /#.*$/,
rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
...@@ -223,7 +224,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -223,7 +224,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( current ) { if ( current ) {
// There's only work to do if current dataType is non-auto // There's only work to do if current dataType is non-auto
if ( current === "*" ) { if ( current === "*" ) {
current = prev; current = prev;
...@@ -405,12 +406,18 @@ jQuery.extend( { ...@@ -405,12 +406,18 @@ jQuery.extend( {
// Url cleanup var // Url cleanup var
urlAnchor, urlAnchor,
// Request state (becomes false upon send and true upon completion)
completed,
// To know if global events are to be dispatched // To know if global events are to be dispatched
fireGlobals, fireGlobals,
// Loop variable // Loop variable
i, i,
// uncached part of the url
uncached,
// Create the final options object // Create the final options object
s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
...@@ -434,9 +441,6 @@ jQuery.extend( { ...@@ -434,9 +441,6 @@ jQuery.extend( {
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {}, requestHeadersNames = {},
// The jqXHR state
state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
...@@ -447,7 +451,7 @@ jQuery.extend( { ...@@ -447,7 +451,7 @@ jQuery.extend( {
// Builds headers hashtable if needed // Builds headers hashtable if needed
getResponseHeader: function( key ) { getResponseHeader: function( key ) {
var match; var match;
if ( state === 2 ) { if ( completed ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( ( match = rheaders.exec( responseHeadersString ) ) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
...@@ -461,14 +465,14 @@ jQuery.extend( { ...@@ -461,14 +465,14 @@ jQuery.extend( {
// Raw string // Raw string
getAllResponseHeaders: function() { getAllResponseHeaders: function() {
return state === 2 ? responseHeadersString : null; return completed ? responseHeadersString : null;
}, },
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
var lname = name.toLowerCase(); if ( completed == null ) {
if ( !state ) { name = requestHeadersNames[ name.toLowerCase() ] =
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; requestHeadersNames[ name.toLowerCase() ] || name;
requestHeaders[ name ] = value; requestHeaders[ name ] = value;
} }
return this; return this;
...@@ -476,7 +480,7 @@ jQuery.extend( { ...@@ -476,7 +480,7 @@ jQuery.extend( {
// Overrides response content-type header // Overrides response content-type header
overrideMimeType: function( type ) { overrideMimeType: function( type ) {
if ( !state ) { if ( completed == null ) {
s.mimeType = type; s.mimeType = type;
} }
return this; return this;
...@@ -486,16 +490,16 @@ jQuery.extend( { ...@@ -486,16 +490,16 @@ jQuery.extend( {
statusCode: function( map ) { statusCode: function( map ) {
var code; var code;
if ( map ) { if ( map ) {
if ( state < 2 ) { if ( completed ) {
for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
} else {
// Execute the appropriate callbacks // Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] ); jqXHR.always( map[ jqXHR.status ] );
} else {
// Lazy-add the new callbacks in a way that preserves old ones
for ( code in map ) {
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
} }
} }
return this; return this;
...@@ -513,15 +517,12 @@ jQuery.extend( { ...@@ -513,15 +517,12 @@ jQuery.extend( {
}; };
// Attach deferreds // Attach deferreds
deferred.promise( jqXHR ).complete = completeDeferred.add; deferred.promise( jqXHR );
jqXHR.success = jqXHR.done;
jqXHR.error = jqXHR.fail;
// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (prefilters might expect it) // Add protocol if not provided (prefilters might expect it)
// Handle falsy url in the settings object (#10093: consistency with old signature) // Handle falsy url in the settings object (#10093: consistency with old signature)
// We also use the url parameter if available // We also use the url parameter if available
s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" ) s.url = ( ( url || s.url || location.href ) + "" )
.replace( rprotocol, location.protocol + "//" ); .replace( rprotocol, location.protocol + "//" );
// Alias method option to type as per ticket #12004 // Alias method option to type as per ticket #12004
...@@ -561,7 +562,7 @@ jQuery.extend( { ...@@ -561,7 +562,7 @@ jQuery.extend( {
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
// If request was aborted inside a prefilter, stop there // If request was aborted inside a prefilter, stop there
if ( state === 2 ) { if ( completed ) {
return jqXHR; return jqXHR;
} }
...@@ -582,29 +583,36 @@ jQuery.extend( { ...@@ -582,29 +583,36 @@ jQuery.extend( {
// Save the URL in case we're toying with the If-Modified-Since // Save the URL in case we're toying with the If-Modified-Since
// and/or If-None-Match header later on // and/or If-None-Match header later on
cacheURL = s.url; // Remove hash to simplify url manipulation
cacheURL = s.url.replace( rhash, "" );
// More options handling for requests with no content // More options handling for requests with no content
if ( !s.hasContent ) { if ( !s.hasContent ) {
// Remember the hash so we can put it back
uncached = s.url.slice( cacheURL.length );
// If data is available, append data to url // If data is available, append data to url
if ( s.data ) { if ( s.data ) {
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
// #9682: remove data so that it's not used in an eventual retry // #9682: remove data so that it's not used in an eventual retry
delete s.data; delete s.data;
} }
// Add anti-cache in url if needed // Add anti-cache in uncached url if needed
if ( s.cache === false ) { if ( s.cache === false ) {
s.url = rts.test( cacheURL ) ? cacheURL = cacheURL.replace( rts, "" );
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
}
// If there is already a '_' parameter, set its value // Put hash and anti-cache on the URL that will be requested (gh-1732)
cacheURL.replace( rts, "$1_=" + nonce++ ) : s.url = cacheURL + uncached;
// Otherwise add one to the end // Change '%20' to '+' if this is encoded form body content (gh-2658)
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; } else if ( s.data && s.processData &&
} ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
s.data = s.data.replace( r20, "+" );
} }
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
...@@ -638,7 +646,7 @@ jQuery.extend( { ...@@ -638,7 +646,7 @@ jQuery.extend( {
// Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && if ( s.beforeSend &&
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
// Abort if not done already and return // Abort if not done already and return
return jqXHR.abort(); return jqXHR.abort();
...@@ -648,9 +656,9 @@ jQuery.extend( { ...@@ -648,9 +656,9 @@ jQuery.extend( {
strAbort = "abort"; strAbort = "abort";
// Install callbacks on deferreds // Install callbacks on deferreds
for ( i in { success: 1, error: 1, complete: 1 } ) { completeDeferred.add( s.complete );
jqXHR[ i ]( s[ i ] ); jqXHR.done( s.success );
} jqXHR.fail( s.error );
// Get transport // Get transport
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
...@@ -667,7 +675,7 @@ jQuery.extend( { ...@@ -667,7 +675,7 @@ jQuery.extend( {
} }
// If request was aborted inside ajaxSend, stop there // If request was aborted inside ajaxSend, stop there
if ( state === 2 ) { if ( completed ) {
return jqXHR; return jqXHR;
} }
...@@ -679,18 +687,17 @@ jQuery.extend( { ...@@ -679,18 +687,17 @@ jQuery.extend( {
} }
try { try {
state = 1; completed = false;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Propagate exception as error if not done // Rethrow post-completion exceptions
if ( state < 2 ) { if ( completed ) {
done( -1, e );
// Simply rethrow otherwise
} else {
throw e; throw e;
} }
// Propagate others as results
done( -1, e );
} }
} }
...@@ -699,13 +706,12 @@ jQuery.extend( { ...@@ -699,13 +706,12 @@ jQuery.extend( {
var isSuccess, success, error, response, modified, var isSuccess, success, error, response, modified,
statusText = nativeStatusText; statusText = nativeStatusText;
// Called once // Ignore repeat invocations
if ( state === 2 ) { if ( completed ) {
return; return;
} }
// State is "done" now completed = true;
state = 2;
// Clear timeout if it exists // Clear timeout if it exists
if ( timeoutTimer ) { if ( timeoutTimer ) {
......
...@@ -4,23 +4,13 @@ define( [ ...@@ -4,23 +4,13 @@ define( [
"../ajax", "../ajax",
"../traversing", "../traversing",
"../manipulation", "../manipulation",
"../selector", "../selector"
// Optional event/alias dependency
"../event/alias"
], function( jQuery ) { ], function( jQuery ) {
// Keep a copy of the old load method
var _load = jQuery.fn.load;
/** /**
* Load a url into a page * Load a url into a page
*/ */
jQuery.fn.load = function( url, params, callback ) { jQuery.fn.load = function( url, params, callback ) {
if ( typeof url !== "string" && _load ) {
return _load.apply( this, arguments );
}
var selector, type, response, var selector, type, response,
self = this, self = this,
off = url.indexOf( " " ); off = url.indexOf( " " );
......
...@@ -2,11 +2,7 @@ define( [ ...@@ -2,11 +2,7 @@ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// Support: Android 2.3 jQuery.parseJSON = JSON.parse;
// Workaround failure to string-cast null input
jQuery.parseJSON = function( data ) {
return JSON.parse( data + "" );
};
return jQuery.parseJSON; return jQuery.parseJSON;
......
...@@ -4,6 +4,13 @@ define( [ ...@@ -4,6 +4,13 @@ define( [
"../ajax" "../ajax"
], function( jQuery, document ) { ], function( jQuery, document ) {
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );
// Install script dataType // Install script dataType
jQuery.ajaxSetup( { jQuery.ajaxSetup( {
accepts: { accepts: {
......
...@@ -7,7 +7,14 @@ define( [ ...@@ -7,7 +7,14 @@ define( [
], function( jQuery, access, support, rnotwhite ) { ], function( jQuery, access, support, rnotwhite ) {
var boolHook, var boolHook,
attrHandle = jQuery.expr.attrHandle; attrHandle = jQuery.expr.attrHandle,
// Exclusively lowercase A-Z in attribute names (gh-2730)
// https://dom.spec.whatwg.org/#converted-to-ascii-lowercase
raz = /[A-Z]+/g,
lowercase = function( ch ) {
return ch.toLowerCase();
};
jQuery.fn.extend( { jQuery.fn.extend( {
attr: function( name, value ) { attr: function( name, value ) {
...@@ -39,7 +46,7 @@ jQuery.extend( { ...@@ -39,7 +46,7 @@ jQuery.extend( {
// All attributes are lowercase // All attributes are lowercase
// Grab necessary hook if one is defined // Grab necessary hook if one is defined
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
name = name.toLowerCase(); name = name.replace( raz, lowercase );
hooks = jQuery.attrHooks[ name ] || hooks = jQuery.attrHooks[ name ] ||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
} }
...@@ -86,21 +93,12 @@ jQuery.extend( { ...@@ -86,21 +93,12 @@ jQuery.extend( {
}, },
removeAttr: function( elem, value ) { removeAttr: function( elem, value ) {
var name, propName, var name,
i = 0, i = 0,
attrNames = value && value.match( rnotwhite ); attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) { if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) { while ( ( name = attrNames[ i++ ] ) ) {
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false
elem[ propName ] = false;
}
elem.removeAttribute( name ); elem.removeAttribute( name );
} }
} }
...@@ -120,6 +118,7 @@ boolHook = { ...@@ -120,6 +118,7 @@ boolHook = {
return name; return name;
} }
}; };
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
var getter = attrHandle[ name ] || jQuery.find.attr; var getter = attrHandle[ name ] || jQuery.find.attr;
......
...@@ -10,7 +10,7 @@ define( [ ...@@ -10,7 +10,7 @@ define( [
input.type = "checkbox"; input.type = "checkbox";
// Support: iOS<=5.1, Android<=4.2+ // Support: Android<4.4
// Default value for a checkbox should be "on" // Default value for a checkbox should be "on"
support.checkOn = input.value !== ""; support.checkOn = input.value !== "";
...@@ -18,11 +18,6 @@ define( [ ...@@ -18,11 +18,6 @@ define( [
// Must access selectedIndex to make default options select // Must access selectedIndex to make default options select
support.optSelected = opt.selected; support.optSelected = opt.selected;
// Support: Android<=2.3
// Options inside disabled selects are incorrectly marked as disabled
select.disabled = true;
support.optDisabled = !opt.disabled;
// Support: IE<=11+ // Support: IE<=11+
// An input loses its value after becoming a radio // An input loses its value after becoming a radio
input = document.createElement( "input" ); input = document.createElement( "input" );
......
...@@ -90,7 +90,7 @@ jQuery.extend( { ...@@ -90,7 +90,7 @@ jQuery.extend( {
var value, option, var value, option,
options = elem.options, options = elem.options,
index = elem.selectedIndex, index = elem.selectedIndex,
one = elem.type === "select-one" || index < 0, one = elem.type === "select-one",
values = one ? null : [], values = one ? null : [],
max = one ? index + 1 : options.length, max = one ? index + 1 : options.length,
i = index < 0 ? i = index < 0 ?
...@@ -105,8 +105,7 @@ jQuery.extend( { ...@@ -105,8 +105,7 @@ jQuery.extend( {
if ( ( option.selected || i === index ) && if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup // Don't return options that are disabled or in a disabled optgroup
( support.optDisabled ? !option.disabled &&
!option.disabled : option.getAttribute( "disabled" ) === null ) &&
( !option.parentNode.disabled || ( !option.parentNode.disabled ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
......
...@@ -191,7 +191,7 @@ jQuery.Callbacks = function( options ) { ...@@ -191,7 +191,7 @@ jQuery.Callbacks = function( options ) {
// Abort any pending executions // Abort any pending executions
lock: function() { lock: function() {
locked = queue = []; locked = queue = [];
if ( !memory ) { if ( !memory && !firing ) {
list = memory = ""; list = memory = "";
} }
return this; return this;
......
...@@ -8,8 +8,10 @@ define( [ ...@@ -8,8 +8,10 @@ define( [
"./var/class2type", "./var/class2type",
"./var/toString", "./var/toString",
"./var/hasOwn", "./var/hasOwn",
"./var/support" "./var/support",
], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { "./core/DOMEval"
], function( arr, document, slice, concat,
push, indexOf, class2type, toString, hasOwn, support, DOMEval ) {
var var
version = "@VERSION", version = "@VERSION",
...@@ -28,7 +30,7 @@ var ...@@ -28,7 +30,7 @@ var
// Matches dashed string for camelizing // Matches dashed string for camelizing
rmsPrefix = /^-ms-/, rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi, rdashAlpha = /-([a-z])/g,
// Used by jQuery.camelCase as callback to replace() // Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) { fcamelCase = function( all, letter ) {
...@@ -42,9 +44,6 @@ jQuery.fn = jQuery.prototype = { ...@@ -42,9 +44,6 @@ jQuery.fn = jQuery.prototype = {
constructor: jQuery, constructor: jQuery,
// Start with an empty selector
selector: "",
// The default length of a jQuery object is 0 // The default length of a jQuery object is 0
length: 0, length: 0,
...@@ -73,7 +72,6 @@ jQuery.fn = jQuery.prototype = { ...@@ -73,7 +72,6 @@ jQuery.fn = jQuery.prototype = {
// Add the old object onto the stack (as a reference) // Add the old object onto the stack (as a reference)
ret.prevObject = this; ret.prevObject = this;
ret.context = this.context;
// Return the newly-formed element set // Return the newly-formed element set
return ret; return ret;
...@@ -214,12 +212,12 @@ jQuery.extend( { ...@@ -214,12 +212,12 @@ jQuery.extend( {
isNumeric: function( obj ) { isNumeric: function( obj ) {
// parseFloat NaNs numeric-cast false positives (null|true|false|"") // As of jQuery 3.0, isNumeric is limited to
// ...but misinterprets leading-number strings, particularly hex literals ("0x...") // strings and numbers (primitives or objects)
// subtraction forces infinities to NaN // that can be coerced to finite numbers (gh-2662)
// adding 1 corrects loss of precision from parseFloat (#15100) var type = jQuery.type( obj );
var realStringObj = obj && obj.toString(); return ( type === "number" || type === "string" ) &&
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; ( obj - parseFloat( obj ) + 1 ) >= 0;
}, },
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
...@@ -255,7 +253,7 @@ jQuery.extend( { ...@@ -255,7 +253,7 @@ jQuery.extend( {
return obj + ""; return obj + "";
} }
// Support: Android<4.0, iOS<6 (functionish RegExp) // Support: Android<4.0 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call( obj ) ] || "object" : class2type[ toString.call( obj ) ] || "object" :
typeof obj; typeof obj;
...@@ -263,28 +261,7 @@ jQuery.extend( { ...@@ -263,28 +261,7 @@ jQuery.extend( {
// Evaluates a script in a global context // Evaluates a script in a global context
globalEval: function( code ) { globalEval: function( code ) {
var script, DOMEval( code );
indirect = eval;
code = jQuery.trim( code );
if ( code ) {
// If the code includes a valid, prologue position
// strict mode pragma, execute code by injecting a
// script tag into the document.
if ( code.indexOf( "use strict" ) === 1 ) {
script = document.createElement( "script" );
script.text = code;
document.head.appendChild( script ).parentNode.removeChild( script );
} else {
// Otherwise, avoid the DOM node creation, insertion
// and removal by using an indirect global eval
indirect( code );
}
}
}, },
// Convert dashed to camelCase; used by the css and data modules // Convert dashed to camelCase; used by the css and data modules
...@@ -348,6 +325,8 @@ jQuery.extend( { ...@@ -348,6 +325,8 @@ jQuery.extend( {
return arr == null ? -1 : indexOf.call( arr, elem, i ); return arr == null ? -1 : indexOf.call( arr, elem, i );
}, },
// Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit
merge: function( first, second ) { merge: function( first, second ) {
var len = +second.length, var len = +second.length,
j = 0, j = 0,
......
define( [
"../var/document"
], function( document ) {
function DOMEval( code, doc ) {
doc = doc || document;
var script = doc.createElement( "script" );
script.text = code;
doc.head.appendChild( script ).parentNode.removeChild( script );
}
return DOMEval;
} );
...@@ -12,7 +12,8 @@ var rootjQuery, ...@@ -12,7 +12,8 @@ var rootjQuery,
// A simple way to check for HTML strings // A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <) // Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, // Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context, root ) { init = jQuery.fn.init = function( selector, context, root ) {
var match, elem; var match, elem;
...@@ -75,17 +76,12 @@ var rootjQuery, ...@@ -75,17 +76,12 @@ var rootjQuery,
} else { } else {
elem = document.getElementById( match[ 2 ] ); elem = document.getElementById( match[ 2 ] );
// Support: Blackberry 4.6 if ( elem ) {
// gEBID returns nodes no longer in the document (#6963)
if ( elem && elem.parentNode ) {
// Inject the element directly into the jQuery object // Inject the element directly into the jQuery object
this.length = 1;
this[ 0 ] = elem; this[ 0 ] = elem;
this.length = 1;
} }
this.context = document;
this.selector = selector;
return this; return this;
} }
...@@ -101,7 +97,7 @@ var rootjQuery, ...@@ -101,7 +97,7 @@ var rootjQuery,
// HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
} else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
this.context = this[ 0 ] = selector; this[ 0 ] = selector;
this.length = 1; this.length = 1;
return this; return this;
...@@ -115,11 +111,6 @@ var rootjQuery, ...@@ -115,11 +111,6 @@ var rootjQuery,
selector( jQuery ); selector( jQuery );
} }
if ( selector.selector !== undefined ) {
this.selector = selector.selector;
this.context = selector.context;
}
return jQuery.makeArray( selector, this ); return jQuery.makeArray( selector, this );
}; };
......
...@@ -13,8 +13,8 @@ define( [ ...@@ -13,8 +13,8 @@ define( [
// defaults to document // defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) { jQuery.parseHTML = function( data, context, keepScripts ) {
if ( !data || typeof data !== "string" ) { if ( typeof data !== "string" ) {
return null; return [];
} }
if ( typeof context === "boolean" ) { if ( typeof context === "boolean" ) {
keepScripts = context; keepScripts = context;
......
define( [ define( [
"../core", "../core",
"../var/document", "../var/document",
"../core/init",
"../deferred" "../deferred"
], function( jQuery, document ) { ], function( jQuery, document ) {
...@@ -52,12 +51,6 @@ jQuery.extend( { ...@@ -52,12 +51,6 @@ jQuery.extend( {
// If there are functions bound, to execute // If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] ); readyList.resolveWith( document, [ jQuery ] );
// Trigger any bound ready events
if ( jQuery.fn.triggerHandler ) {
jQuery( document ).triggerHandler( "ready" );
jQuery( document ).off( "ready" );
}
} }
} ); } );
......
define( function() { define( function() {
// Match a standalone tag // Match a standalone tag
return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
} ); } );
...@@ -12,16 +12,14 @@ define( [ ...@@ -12,16 +12,14 @@ define( [
"./css/var/swap", "./css/var/swap",
"./css/curCSS", "./css/curCSS",
"./css/adjustCSS", "./css/adjustCSS",
"./css/defaultDisplay",
"./css/addGetHookIf", "./css/addGetHookIf",
"./css/support", "./css/support",
"./data/var/dataPriv",
"./core/init", "./core/init",
"./core/ready", "./core/ready",
"./selector" // contains "./selector" // contains
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, isHidden, ], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand,
getStyles, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support, dataPriv ) { isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
var var
...@@ -29,14 +27,13 @@ var ...@@ -29,14 +27,13 @@ var
// except "table", "table-cell", or "table-caption" // except "table", "table-cell", or "table-caption"
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/, rdisplayswap = /^(none|table(?!-c[ea]).+)/,
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = { cssNormalTransform = {
letterSpacing: "0", letterSpacing: "0",
fontWeight: "400" fontWeight: "400"
}, },
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], cssPrefixes = [ "Webkit", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style; emptyStyle = document.createElement( "div" ).style;
// Return a css property mapped to a potentially vendor prefixed property // Return a css property mapped to a potentially vendor prefixed property
...@@ -118,22 +115,23 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -118,22 +115,23 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
function getWidthOrHeight( elem, name, extra ) { function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value // Start with offset property, which is equivalent to the border-box value
var valueIsBorderBox = true, var val,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight, valueIsBorderBox = true,
styles = getStyles( elem ), styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Support: IE <= 11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = elem.getBoundingClientRect()[ name ];
}
// Support: IE11 only // Support: IE11 only
// In IE 11 fullscreen elements inside of an iframe have // In IE 11 fullscreen elements inside of an iframe have
// 100x too small dimensions (gh-1764). // 100x too small dimensions (gh-1764).
if ( document.msFullscreenElement && window.top !== window ) { if ( document.msFullscreenElement && window.top !== window ) {
val *= 100;
// Support: IE11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
} }
// Some non-html elements return undefined for offsetWidth, so check for null/undefined // Some non-html elements return undefined for offsetWidth, so check for null/undefined
...@@ -173,66 +171,6 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -173,66 +171,6 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px"; ) + "px";
} }
function showHide( elements, show ) {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
values[ index ] = dataPriv.get( elem, "olddisplay" );
display = elem.style.display;
if ( show ) {
// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if ( !values[ index ] && display === "none" ) {
elem.style.display = "";
}
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if ( elem.style.display === "" && isHidden( elem ) ) {
values[ index ] = dataPriv.access(
elem,
"olddisplay",
defaultDisplay( elem.nodeName )
);
}
} else {
hidden = isHidden( elem );
if ( display !== "none" || !hidden ) {
dataPriv.set(
elem,
"olddisplay",
hidden ? display : jQuery.css( elem, "display" )
);
}
}
}
// Set the display of most of the elements in a second loop
// to avoid the constant reflow
for ( index = 0; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
elem.style.display = show ? values[ index ] || "" : "none";
}
}
return elements;
}
jQuery.extend( { jQuery.extend( {
// Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
...@@ -384,7 +322,14 @@ jQuery.each( [ "height", "width" ], function( i, name ) { ...@@ -384,7 +322,14 @@ jQuery.each( [ "height", "width" ], function( i, name ) {
// Certain elements can have dimension info if we invisibly show them // Certain elements can have dimension info if we invisibly show them
// but it must have a current display style that would benefit // but it must have a current display style that would benefit
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
elem.offsetWidth === 0 ?
// Support: Safari 8+
// Table columns in Safari have non-zero offsetWidth & zero
// getBoundingClientRect().width unless display is changed.
// Support: IE <= 11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
swap( elem, cssShow, function() { swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra ); return getWidthOrHeight( elem, name, extra );
} ) : } ) :
...@@ -429,16 +374,6 @@ jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, ...@@ -429,16 +374,6 @@ jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
} }
); );
// Support: Android 2.3
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) {
if ( computed ) {
return swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}
}
);
// These hooks are used by animate to expand properties // These hooks are used by animate to expand properties
jQuery.each( { jQuery.each( {
margin: "", margin: "",
...@@ -489,25 +424,6 @@ jQuery.fn.extend( { ...@@ -489,25 +424,6 @@ jQuery.fn.extend( {
jQuery.style( elem, name, value ) : jQuery.style( elem, name, value ) :
jQuery.css( elem, name ); jQuery.css( elem, name );
}, name, value, arguments.length > 1 ); }, name, value, arguments.length > 1 );
},
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHidden( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
} }
} ); } );
......
...@@ -7,12 +7,7 @@ jQuery.expr.filters.hidden = function( elem ) { ...@@ -7,12 +7,7 @@ jQuery.expr.filters.hidden = function( elem ) {
return !jQuery.expr.filters.visible( elem ); return !jQuery.expr.filters.visible( elem );
}; };
jQuery.expr.filters.visible = function( elem ) { jQuery.expr.filters.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements
// Use OR instead of AND as the element is not visible if either is true
// See tickets #10406 and #13132
return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0;
}; };
} ); } );
define( [ define( [
"../data/var/dataPriv" "../core",
], function( dataPriv ) { "../data/var/dataPriv",
"../css/var/isHidden"
], function( jQuery, dataPriv, isHidden ) {
var defaultDisplayMap = {};
function getDefaultDisplay( elem ) {
var temp,
doc = elem.ownerDocument,
nodeName = elem.nodeName,
display = defaultDisplayMap[ nodeName ];
if ( display ) {
return display;
}
temp = doc.body.appendChild( doc.createElement( nodeName ) ),
display = jQuery.css( temp, "display" );
temp.parentNode.removeChild( temp );
if ( display === "none" ) {
display = "block";
}
defaultDisplayMap[ nodeName ] = display;
return display;
}
function showHide( elements, show ) { function showHide( elements, show ) {
var display, elem, var display, elem,
...@@ -17,23 +44,35 @@ function showHide( elements, show ) { ...@@ -17,23 +44,35 @@ function showHide( elements, show ) {
display = elem.style.display; display = elem.style.display;
if ( show ) { if ( show ) {
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
// check is required in this first loop unless we have a nonempty display value (either
// inline or about-to-be-restored)
if ( display === "none" ) { if ( display === "none" ) {
values[ index ] = dataPriv.get( elem, "display" ) || null;
if ( !values[ index ] ) {
elem.style.display = "";
}
}
if ( elem.style.display === "" && jQuery.css( elem, "display" ) === "none" &&
// Support: Firefox <=42 - 43
// Don't set inline display on disconnected elements with computed display: none
jQuery.contains( elem.ownerDocument, elem ) ) {
// Restore a pre-hide() value if we have one values[ index ] = getDefaultDisplay( elem );
values[ index ] = dataPriv.get( elem, "display" ) || "";
} }
} else { } else {
if ( display !== "none" ) { if ( display !== "none" ) {
values[ index ] = "none"; values[ index ] = "none";
// Remember the value we're replacing // Remember what we're overwriting
dataPriv.set( elem, "display", display ); dataPriv.set( elem, "display", display );
} }
} }
} }
// Set the display of the elements in a second loop // Set the display of the elements in a second loop to avoid constant reflow
// to avoid the constant reflow
for ( index = 0; index < length; index++ ) { for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) { if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ]; elements[ index ].style.display = values[ index ];
...@@ -43,6 +82,27 @@ function showHide( elements, show ) { ...@@ -43,6 +82,27 @@ function showHide( elements, show ) {
return elements; return elements;
} }
return showHide; jQuery.fn.extend( {
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHidden( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
}
} );
return showHide;
} ); } );
...@@ -29,10 +29,7 @@ define( [ ...@@ -29,10 +29,7 @@ define( [
// so they're executed at the same time to save the second computation. // so they're executed at the same time to save the second computation.
function computeStyleTests() { function computeStyleTests() {
div.style.cssText = div.style.cssText =
"box-sizing:border-box;" +
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
"position:relative;display:block;" + "position:relative;display:block;" +
"margin:auto;border:1px;padding:1px;" + "margin:auto;border:1px;padding:1px;" +
"top:1%;width:50%"; "top:1%;width:50%";
...@@ -84,34 +81,6 @@ define( [ ...@@ -84,34 +81,6 @@ define( [
computeStyleTests(); computeStyleTests();
} }
return reliableMarginLeftVal; return reliableMarginLeftVal;
},
reliableMarginRight: function() {
// Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// This support function is only executed once so no memoizing is needed.
var ret,
marginDiv = div.appendChild( document.createElement( "div" ) );
// Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
"display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
documentElement.appendChild( container );
ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );
documentElement.removeChild( container );
div.removeChild( marginDiv );
return ret;
} }
} ); } );
} )(); } )();
......
...@@ -112,7 +112,7 @@ jQuery.fn.extend( { ...@@ -112,7 +112,7 @@ jQuery.fn.extend( {
} }
return access( this, function( value ) { return access( this, function( value ) {
var data, camelKey; var data;
// The calling jQuery object (element matches) is not empty // The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the // (and therefore has an element appears at this[ 0 ]) and the
...@@ -122,29 +122,15 @@ jQuery.fn.extend( { ...@@ -122,29 +122,15 @@ jQuery.fn.extend( {
if ( elem && value === undefined ) { if ( elem && value === undefined ) {
// Attempt to get data from the cache // Attempt to get data from the cache
// with the key as-is // The key will always be camelCased in Data
data = dataUser.get( elem, key ) || data = dataUser.get( elem, key );
// Try to find dashed key if it exists (gh-2779)
// This is for 2.2.x only
dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() );
if ( data !== undefined ) {
return data;
}
camelKey = jQuery.camelCase( key );
// Attempt to get data from the cache
// with the key camelized
data = dataUser.get( elem, camelKey );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
// Attempt to "discover" the data in // Attempt to "discover" the data in
// HTML5 custom data-* attrs // HTML5 custom data-* attrs
data = dataAttr( elem, camelKey, undefined ); data = dataAttr( elem, key );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
...@@ -154,24 +140,10 @@ jQuery.fn.extend( { ...@@ -154,24 +140,10 @@ jQuery.fn.extend( {
} }
// Set the data... // Set the data...
camelKey = jQuery.camelCase( key );
this.each( function() { this.each( function() {
// First, attempt to store a copy or reference of any // We always store the camelCased key
// data that might've been store with a camelCased key. dataUser.set( this, key, value );
var data = dataUser.get( this, camelKey );
// For HTML5 data-* attribute interop, we have to
// store property names with dashes in a camelCase form.
// This might not apply to all properties...*
dataUser.set( this, camelKey, value );
// *... In the case of properties that might _actually_
// have dashes, we need to also store a copy of that
// unchanged property.
if ( key.indexOf( "-" ) > -1 && data !== undefined ) {
dataUser.set( this, key, value );
}
} ); } );
}, null, value, arguments.length > 1, null, true ); }, null, value, arguments.length > 1, null, true );
}, },
......
...@@ -12,35 +12,8 @@ Data.uid = 1; ...@@ -12,35 +12,8 @@ Data.uid = 1;
Data.prototype = { Data.prototype = {
register: function( owner, initial ) {
var value = initial || {};
// If it is a node unlikely to be stringify-ed or looped over
// use plain assignment
if ( owner.nodeType ) {
owner[ this.expando ] = value;
// Otherwise secure it in a non-enumerable, non-writable property
// configurability must be true to allow the property to be
// deleted with the delete operator
} else {
Object.defineProperty( owner, this.expando, {
value: value,
writable: true,
configurable: true
} );
}
return owner[ this.expando ];
},
cache: function( owner ) { cache: function( owner ) {
// We can accept data for non-element nodes in modern browsers,
// but we should not, see #8335.
// Always return an empty object.
if ( !acceptData( owner ) ) {
return {};
}
// Check if the owner object already has a cache // Check if the owner object already has a cache
var value = owner[ this.expando ]; var value = owner[ this.expando ];
...@@ -77,15 +50,16 @@ Data.prototype = { ...@@ -77,15 +50,16 @@ Data.prototype = {
cache = this.cache( owner ); cache = this.cache( owner );
// Handle: [ owner, key, value ] args // Handle: [ owner, key, value ] args
// Always use camelCase key (gh-2257)
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
cache[ data ] = value; cache[ jQuery.camelCase( data ) ] = value;
// Handle: [ owner, { properties } ] args // Handle: [ owner, { properties } ] args
} else { } else {
// Copy the properties one-by-one to the cache object // Copy the properties one-by-one to the cache object
for ( prop in data ) { for ( prop in data ) {
cache[ prop ] = data[ prop ]; cache[ jQuery.camelCase( prop ) ] = data[ prop ];
} }
} }
return cache; return cache;
...@@ -93,10 +67,11 @@ Data.prototype = { ...@@ -93,10 +67,11 @@ Data.prototype = {
get: function( owner, key ) { get: function( owner, key ) {
return key === undefined ? return key === undefined ?
this.cache( owner ) : this.cache( owner ) :
owner[ this.expando ] && owner[ this.expando ][ key ];
// Always use camelCase key (gh-2257)
owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
}, },
access: function( owner, key, value ) { access: function( owner, key, value ) {
var stored;
// In cases where either: // In cases where either:
// //
...@@ -112,10 +87,7 @@ Data.prototype = { ...@@ -112,10 +87,7 @@ Data.prototype = {
if ( key === undefined || if ( key === undefined ||
( ( key && typeof key === "string" ) && value === undefined ) ) { ( ( key && typeof key === "string" ) && value === undefined ) ) {
stored = this.get( owner, key ); return this.get( owner, key );
return stored !== undefined ?
stored : this.get( owner, jQuery.camelCase( key ) );
} }
// When the key is not a string, or both a key and value // When the key is not a string, or both a key and value
...@@ -131,48 +103,35 @@ Data.prototype = { ...@@ -131,48 +103,35 @@ Data.prototype = {
return value !== undefined ? value : key; return value !== undefined ? value : key;
}, },
remove: function( owner, key ) { remove: function( owner, key ) {
var i, name, camel, var i,
cache = owner[ this.expando ]; cache = owner[ this.expando ];
if ( cache === undefined ) { if ( cache === undefined ) {
return; return;
} }
if ( key === undefined ) { if ( key !== undefined ) {
this.register( owner );
} else {
// Support array or space separated string of keys // Support array or space separated string of keys
if ( jQuery.isArray( key ) ) { if ( jQuery.isArray( key ) ) {
// If "name" is an array of keys... // If key is an array of keys...
// When data is initially created, via ("key", "val") signature, // We always set camelCase keys, so remove that.
// keys will be converted to camelCase. key = key.map( jQuery.camelCase );
// Since there is no way to tell _how_ a key was added, remove
// both plain key and camelCase key. #12786
// This will only penalize the array argument path.
name = key.concat( key.map( jQuery.camelCase ) );
} else { } else {
camel = jQuery.camelCase( key ); key = jQuery.camelCase( key );
// Try the string as a key before any manipulation // If a key with the spaces exists, use it.
if ( key in cache ) { // Otherwise, create an array by matching non-whitespace
name = [ key, camel ]; key = key in cache ?
} else { [ key ] :
( key.match( rnotwhite ) || [] );
// If a key with the spaces exists, use it.
// Otherwise, create an array by matching non-whitespace
name = camel;
name = name in cache ?
[ name ] : ( name.match( rnotwhite ) || [] );
}
} }
i = name.length; i = key.length;
while ( i-- ) { while ( i-- ) {
delete cache[ name[ i ] ]; delete cache[ key[ i ] ];
} }
} }
......
This diff is collapsed.
define( [
"../core",
"../deferred"
], function( jQuery ) {
// These usually indicate a programmer mistake during development,
// warn about them ASAP rather than swallowing them by default.
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
jQuery.Deferred.exceptionHook = function( error, stack ) {
// Support: IE9
// Console exists when dev tools are open, which can happen at any time
if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
window.console.warn( "jQuery.Deferred exception: " + error.message, stack );
}
};
} );
...@@ -20,13 +20,7 @@ jQuery.fn.extend( { ...@@ -20,13 +20,7 @@ jQuery.fn.extend( {
return arguments.length === 1 ? return arguments.length === 1 ?
this.off( selector, "**" ) : this.off( selector, "**" ) :
this.off( types, selector || "**", fn ); this.off( types, selector || "**", fn );
},
size: function() {
return this.length;
} }
} ); } );
jQuery.fn.andSelf = jQuery.fn.addBack;
} ); } );
...@@ -19,10 +19,10 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -19,10 +19,10 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
// isn't a whole lot we can do. See pull request at this URL for discussion: return funcName.indexOf( "outer" ) === 0 ?
// https://github.com/jquery/jquery/pull/764 elem[ "inner" + name ] :
return elem.document.documentElement[ "client" + name ]; elem.document.documentElement[ "client" + name ];
} }
// Get document width or height // Get document width or height
...@@ -45,7 +45,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -45,7 +45,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
// Set width or height on the element // Set width or height on the element
jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable, null ); }, type, chainable ? margin : undefined, chainable );
}; };
} ); } );
} ); } );
......
...@@ -2,27 +2,36 @@ define( [ ...@@ -2,27 +2,36 @@ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rcssNum", "./var/rcssNum",
"./css/var/cssExpand",
"./var/rnotwhite", "./var/rnotwhite",
"./css/var/cssExpand",
"./css/var/isHidden", "./css/var/isHidden",
"./css/var/swap",
"./css/adjustCSS", "./css/adjustCSS",
"./css/defaultDisplay",
"./data/var/dataPriv", "./data/var/dataPriv",
"./css/showHide",
"./core/init", "./core/init",
"./effects/Tween",
"./queue", "./queue",
"./css",
"./deferred", "./deferred",
"./traversing" "./traversing",
], function( jQuery, document, rcssNum, cssExpand, rnotwhite, "./manipulation",
isHidden, adjustCSS, defaultDisplay, dataPriv ) { "./css",
"./effects/Tween"
], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap,
adjustCSS, dataPriv, showHide ) {
var var
fxNow, timerId, fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
rrun = /queueHooks$/; rrun = /queueHooks$/;
function raf() {
if ( timerId ) {
window.requestAnimationFrame( raf );
jQuery.fx.tick();
}
}
// Animations created synchronously will run synchronously // Animations created synchronously will run synchronously
function createFxNow() { function createFxNow() {
window.setTimeout( function() { window.setTimeout( function() {
...@@ -68,14 +77,15 @@ function createTween( value, prop, animation ) { ...@@ -68,14 +77,15 @@ function createTween( value, prop, animation ) {
function defaultPrefilter( elem, props, opts ) { function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */ /* jshint validthis: true */
var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
isBox = "width" in props || "height" in props,
anim = this, anim = this,
orig = {}, orig = {},
style = elem.style, style = elem.style,
hidden = elem.nodeType && isHidden( elem ), hidden = elem.nodeType && isHidden( elem ),
dataShow = dataPriv.get( elem, "fxshow" ); dataShow = dataPriv.get( elem, "fxshow" );
// Handle queue: false promises // Queue-skipping animations hijack the fx hooks
if ( !opts.queue ) { if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" ); hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) { if ( hooks.unqueued == null ) {
...@@ -101,25 +111,77 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -101,25 +111,77 @@ function defaultPrefilter( elem, props, opts ) {
} ); } );
} }
// Height/width overflow pass // Detect show/hide animations
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { for ( prop in props ) {
value = props[ prop ];
if ( rfxtypes.test( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// Pretend to be hidden if this is a "show" and
// there is still data from a stopped show/hide
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true;
// Make sure that nothing sneaks out // Ignore all other no-op show/hide data
// Record all 3 overflow attributes because IE9-10 do not } else {
// change the overflow attribute when overflowX and continue;
// overflowY are set to the same value }
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
}
// Bail out if this is a no-op like .hide().hide()
propTween = !jQuery.isEmptyObject( props );
if ( !propTween && jQuery.isEmptyObject( orig ) ) {
return;
}
// Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) {
// Support: IE 9 - 11
// Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Set display property to inline-block for height/width // Identify a display type, preferring old show/hide data over the CSS cascade
// animations on inline elements that are having width/height animated restoreDisplay = dataShow && dataShow.display;
if ( restoreDisplay == null ) {
restoreDisplay = dataPriv.get( elem, "display" );
}
display = jQuery.css( elem, "display" ); display = jQuery.css( elem, "display" );
if ( display === "none" ) {
if ( restoreDisplay ) {
display = restoreDisplay;
} else {
// Test default display if display is currently "none" // Get nonempty value(s) by temporarily forcing visibility
checkDisplay = display === "none" ? showHide( [ elem ], true );
dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; restoreDisplay = elem.style.display || restoreDisplay;
display = jQuery.css( elem, "display" );
showHide( [ elem ] );
}
}
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { // Animate inline elements as inline-block
style.display = "inline-block"; if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
if ( jQuery.css( elem, "float" ) === "none" ) {
// Restore the original display value at the end of pure show/hide animations
if ( !propTween ) {
anim.done( function() {
style.display = restoreDisplay;
} );
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
}
}
style.display = "inline-block";
}
} }
} }
...@@ -132,73 +194,53 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -132,73 +194,53 @@ function defaultPrefilter( elem, props, opts ) {
} ); } );
} }
// show/hide pass // Implement show/hide animations
for ( prop in props ) { propTween = false;
value = props[ prop ]; for ( prop in orig ) {
if ( rfxtypes.exec( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// If there is dataShow left over from a stopped hide or show // General show/hide setup for this element animation
// and we are going to proceed with show, we should pretend to be hidden if ( !propTween ) {
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { if ( dataShow ) {
hidden = true; if ( "hidden" in dataShow ) {
} else { hidden = dataShow.hidden;
continue;
} }
} else {
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
} }
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
// Any non-fx value stops us from restoring the original display value // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
} else { if ( toggle ) {
display = undefined; dataShow.hidden = !hidden;
} }
}
if ( !jQuery.isEmptyObject( orig ) ) { // Show elements before animating them
if ( dataShow ) { if ( hidden ) {
if ( "hidden" in dataShow ) { showHide( [ elem ], true );
hidden = dataShow.hidden;
} }
} else {
dataShow = dataPriv.access( elem, "fxshow", {} );
}
// Store state if its toggle - enables .stop().toggle() to "reverse" /* jshint -W083 */
if ( toggle ) {
dataShow.hidden = !hidden;
}
if ( hidden ) {
jQuery( elem ).show();
} else {
anim.done( function() { anim.done( function() {
jQuery( elem ).hide();
// The final step of a "hide" animation is actually hiding the element
if ( !hidden ) {
showHide( [ elem ] );
}
dataPriv.remove( elem, "fxshow" );
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
} ); } );
} }
anim.done( function() {
var prop;
dataPriv.remove( elem, "fxshow" ); // Per-property setup
for ( prop in orig ) { propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
jQuery.style( elem, prop, orig[ prop ] ); if ( !( prop in dataShow ) ) {
} dataShow[ prop ] = propTween.start;
} ); if ( hidden ) {
for ( prop in orig ) { propTween.end = propTween.start;
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); propTween.start = prop === "width" || prop === "height" ? 1 : 0;
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = tween.start;
if ( hidden ) {
tween.end = tween.start;
tween.start = prop === "width" || prop === "height" ? 1 : 0;
}
} }
} }
// If this is a noop like .hide().hide(), restore an overwritten display value
} else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
style.display = display;
} }
} }
...@@ -355,6 +397,7 @@ function Animation( elem, properties, options ) { ...@@ -355,6 +397,7 @@ function Animation( elem, properties, options ) {
} }
jQuery.Animation = jQuery.extend( Animation, { jQuery.Animation = jQuery.extend( Animation, {
tweeners: { tweeners: {
"*": [ function( prop, value ) { "*": [ function( prop, value ) {
var tween = this.createTween( prop, value ); var tween = this.createTween( prop, value );
...@@ -401,9 +444,15 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -401,9 +444,15 @@ jQuery.speed = function( speed, easing, fn ) {
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
}; };
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? // Go to the end state if fx are off or if document is hidden
opt.duration : opt.duration in jQuery.fx.speeds ? if ( jQuery.fx.off || document.hidden ) {
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; opt.duration = 0;
} else {
opt.duration = typeof opt.duration === "number" ?
opt.duration : opt.duration in jQuery.fx.speeds ?
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
}
// Normalize opt.queue - true/undefined/null -> "fx" // Normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) { if ( opt.queue == null || opt.queue === true ) {
...@@ -607,12 +656,18 @@ jQuery.fx.timer = function( timer ) { ...@@ -607,12 +656,18 @@ jQuery.fx.timer = function( timer ) {
jQuery.fx.interval = 13; jQuery.fx.interval = 13;
jQuery.fx.start = function() { jQuery.fx.start = function() {
if ( !timerId ) { if ( !timerId ) {
timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); timerId = window.requestAnimationFrame ?
window.requestAnimationFrame( raf ) :
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
} }
}; };
jQuery.fx.stop = function() { jQuery.fx.stop = function() {
window.clearInterval( timerId ); if ( window.cancelAnimationFrame ) {
window.cancelAnimationFrame( timerId );
} else {
window.clearInterval( timerId );
}
timerId = null; timerId = null;
}; };
......
...@@ -27,17 +27,12 @@ Tween.prototype = { ...@@ -27,17 +27,12 @@ Tween.prototype = {
Tween.propHooks._default.get( this ); Tween.propHooks._default.get( this );
}, },
run: function( percent ) { run: function( percent ) {
var eased, var hooks = Tween.propHooks[ this.prop ];
hooks = Tween.propHooks[ this.prop ];
if ( this.options.duration ) { this.pos = this.options.duration ?
this.pos = eased = jQuery.easing[ this.easing ]( jQuery.easing[ this.easing ]( percent ) :
percent, this.options.duration * percent, 0, 1, this.options.duration percent;
); this.now = ( this.end - this.start ) * this.pos + this.start;
} else {
this.pos = eased = percent;
}
this.now = ( this.end - this.start ) * eased + this.start;
if ( this.options.step ) { if ( this.options.step ) {
this.options.step.call( this.elem, this.now, this ); this.options.step.call( this.elem, this.now, this );
......
...@@ -70,8 +70,6 @@ function on( elem, types, selector, data, fn, one ) { ...@@ -70,8 +70,6 @@ function on( elem, types, selector, data, fn, one ) {
} }
if ( fn === false ) { if ( fn === false ) {
fn = returnFalse; fn = returnFalse;
} else if ( !fn ) {
return this;
} }
if ( one === 1 ) { if ( one === 1 ) {
...@@ -469,13 +467,7 @@ jQuery.event = { ...@@ -469,13 +467,7 @@ jQuery.event = {
event[ prop ] = originalEvent[ prop ]; event[ prop ] = originalEvent[ prop ];
} }
// Support: Cordova 2.5 (WebKit) (#13255) // Support: Safari 6-8+
// All events should have a target; Cordova deviceready doesn't
if ( !event.target ) {
event.target = document;
}
// Support: Safari 6.0+, Chrome<28
// Target should not be a text node (#504, #13143) // Target should not be a text node (#504, #13143)
if ( event.target.nodeType === 3 ) { if ( event.target.nodeType === 3 ) {
event.target = event.target.parentNode; event.target = event.target.parentNode;
...@@ -662,6 +654,7 @@ jQuery.each( { ...@@ -662,6 +654,7 @@ jQuery.each( {
} ); } );
jQuery.fn.extend( { jQuery.fn.extend( {
on: function( types, selector, data, fn ) { on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn ); return on( this, types, selector, data, fn );
}, },
......
...@@ -5,9 +5,9 @@ define( [ ...@@ -5,9 +5,9 @@ define( [
"./trigger" "./trigger"
], function( jQuery ) { ], function( jQuery ) {
jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu" ).split( " " ), "change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( i, name ) { function( i, name ) {
// Handle event binding // Handle event binding
......
...@@ -121,7 +121,7 @@ jQuery.extend( jQuery.event, { ...@@ -121,7 +121,7 @@ jQuery.extend( jQuery.event, {
special._default.apply( eventPath.pop(), data ) === false ) && special._default.apply( eventPath.pop(), data ) === false ) &&
acceptData( elem ) ) { acceptData( elem ) ) {
// Call a native DOM method on the target with the same name name as the event. // Call a native DOM method on the target with the same name as the event.
// Don't do default actions on window, that's where global variables be (#6170) // Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
......
/*! /*!
* jQuery JavaScript Library v@VERSION * jQuery JavaScript Library v@VERSION
* http://jquery.com/ * https://jquery.com/
* *
* Includes Sizzle.js * Includes Sizzle.js
* http://sizzlejs.com/ * https://sizzlejs.com/
* *
* Copyright jQuery Foundation and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * https://jquery.org/license
* *
* Date: @DATE * Date: @DATE
*/ */
......
...@@ -4,6 +4,7 @@ define( [ ...@@ -4,6 +4,7 @@ define( [
"./traversing", "./traversing",
"./callbacks", "./callbacks",
"./deferred", "./deferred",
"./deferred/exceptionHook",
"./core/ready", "./core/ready",
"./data", "./data",
"./queue", "./queue",
......
...@@ -15,6 +15,7 @@ define( [ ...@@ -15,6 +15,7 @@ define( [
"./data/var/dataPriv", "./data/var/dataPriv",
"./data/var/dataUser", "./data/var/dataUser",
"./data/var/acceptData", "./data/var/acceptData",
"./core/DOMEval",
"./core/init", "./core/init",
"./traversing", "./traversing",
...@@ -23,10 +24,10 @@ define( [ ...@@ -23,10 +24,10 @@ define( [
], function( jQuery, concat, push, access, ], function( jQuery, concat, push, access,
rcheckableType, rtagName, rscriptType, rcheckableType, rtagName, rscriptType,
wrapMap, getAll, setGlobalEval, buildFragment, support, wrapMap, getAll, setGlobalEval, buildFragment, support,
dataPriv, dataUser, acceptData ) { dataPriv, dataUser, acceptData, DOMEval ) {
var var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
// Support: IE 10-11, Edge 10240+ // Support: IE 10-11, Edge 10240+
// In IE/Edge using regex groups here causes severe slowdowns. // In IE/Edge using regex groups here causes severe slowdowns.
...@@ -192,7 +193,7 @@ function domManip( collection, args, callback, ignored ) { ...@@ -192,7 +193,7 @@ function domManip( collection, args, callback, ignored ) {
jQuery._evalUrl( node.src ); jQuery._evalUrl( node.src );
} }
} else { } else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
} }
} }
} }
...@@ -238,7 +239,7 @@ jQuery.extend( { ...@@ -238,7 +239,7 @@ jQuery.extend( {
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) { !jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone ); destElements = getAll( clone );
srcElements = getAll( elem ); srcElements = getAll( elem );
...@@ -307,10 +308,6 @@ jQuery.extend( { ...@@ -307,10 +308,6 @@ jQuery.extend( {
} ); } );
jQuery.fn.extend( { jQuery.fn.extend( {
// Keep domManip exposed until 3.0 (gh-2225)
domManip: domManip,
detach: function( selector ) { detach: function( selector ) {
return remove( this, selector, true ); return remove( this, selector, true );
}, },
...@@ -468,8 +465,8 @@ jQuery.each( { ...@@ -468,8 +465,8 @@ jQuery.each( {
elems = i === last ? this : this.clone( true ); elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems ); jQuery( insert[ i ] )[ original ]( elems );
// Support: QtWebKit // Support: Android<4.1, PhantomJS<2
// .get() because push.apply(_, arraylike) throws // .get() because push.apply(_, arraylike) throws on ancient WebKit
push.apply( ret, elems.get() ); push.apply( ret, elems.get() );
} }
......
...@@ -9,6 +9,7 @@ jQuery._evalUrl = function( url ) { ...@@ -9,6 +9,7 @@ jQuery._evalUrl = function( url ) {
// Make this explicit, since user can override this through ajaxSetup (#11264) // Make this explicit, since user can override this through ajaxSetup (#11264)
type: "GET", type: "GET",
dataType: "script", dataType: "script",
cache: true,
async: false, async: false,
global: false, global: false,
"throws": true "throws": true
......
...@@ -8,7 +8,7 @@ define( [ ...@@ -8,7 +8,7 @@ define( [
div = fragment.appendChild( document.createElement( "div" ) ), div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" ); input = document.createElement( "input" );
// Support: Android 4.0-4.3, Safari<=5.1 // Support: Android 4.0-4.3
// Check state lost if the name is set (#11217) // Check state lost if the name is set (#11217)
// Support: Windows Web Apps (WWA) // Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901) // `name` and `type` must use .setAttribute for WWA (#14901)
...@@ -18,7 +18,7 @@ define( [ ...@@ -18,7 +18,7 @@ define( [
div.appendChild( input ); div.appendChild( input );
// Support: Safari<=5.1, Android<4.2 // Support: Android<4.2
// Older WebKit doesn't clone checked state correctly in fragments // Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
......
define( function() { define( function() {
return ( /<([\w:-]+)/ ); return ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
} ); } );
...@@ -74,6 +74,8 @@ jQuery.offset = { ...@@ -74,6 +74,8 @@ jQuery.offset = {
jQuery.fn.extend( { jQuery.fn.extend( {
offset: function( options ) { offset: function( options ) {
// Preserve chaining for setter
if ( arguments.length ) { if ( arguments.length ) {
return options === undefined ? return options === undefined ?
this : this :
...@@ -82,28 +84,36 @@ jQuery.fn.extend( { ...@@ -82,28 +84,36 @@ jQuery.fn.extend( {
} ); } );
} }
var docElem, win, var docElem, win, rect, doc,
elem = this[ 0 ], elem = this[ 0 ];
box = { top: 0, left: 0 },
doc = elem && elem.ownerDocument;
if ( !doc ) { if ( !elem ) {
return; return;
} }
docElem = doc.documentElement; // Support: IE<=11+
// Running getBoundingClientRect on a
// disconnected node in IE throws an error
if ( !elem.getClientRects().length ) {
return { top: 0, left: 0 };
}
rect = elem.getBoundingClientRect();
// Make sure it's not a disconnected DOM node // Make sure element is not hidden (display: none)
if ( !jQuery.contains( docElem, elem ) ) { if ( rect.width || rect.height ) {
return box; doc = elem.ownerDocument;
win = getWindow( doc );
docElem = doc.documentElement;
return {
top: rect.top + win.pageYOffset - docElem.clientTop,
left: rect.left + win.pageXOffset - docElem.clientLeft
};
} }
box = elem.getBoundingClientRect(); // Return zeros for disconnected and hidden elements (gh-2310)
win = getWindow( doc ); return rect;
return {
top: box.top + win.pageYOffset - docElem.clientTop,
left: box.left + win.pageXOffset - docElem.clientLeft
};
}, },
position: function() { position: function() {
......
...@@ -5,7 +5,7 @@ define( [ ...@@ -5,7 +5,7 @@ define( [
], function( jQuery ) { ], function( jQuery ) {
// Based off of the plugin by Clint Helfers, with permission. // Based off of the plugin by Clint Helfers, with permission.
// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
jQuery.fn.delay = function( time, type ) { jQuery.fn.delay = function( time, type ) {
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
type = type || "fx"; type = type || "fx";
......
...@@ -6,7 +6,7 @@ define( [ ...@@ -6,7 +6,7 @@ define( [
"./attributes/prop" "./attributes/prop"
], function( jQuery, rcheckableType ) { ], function( jQuery, rcheckableType ) {
var r20 = /%20/g, var
rbracket = /\[\]$/, rbracket = /\[\]$/,
rCRLF = /\r?\n/g, rCRLF = /\r?\n/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
...@@ -85,7 +85,7 @@ jQuery.param = function( a, traditional ) { ...@@ -85,7 +85,7 @@ jQuery.param = function( a, traditional ) {
} }
// Return the resulting serialization // Return the resulting serialization
return s.join( "&" ).replace( r20, "+" ); return s.join( "&" );
}; };
jQuery.fn.extend( { jQuery.fn.extend( {
......
...@@ -39,23 +39,24 @@ jQuery.fn.extend( { ...@@ -39,23 +39,24 @@ jQuery.fn.extend( {
i = 0, i = 0,
l = this.length, l = this.length,
matched = [], matched = [],
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? targets = typeof selectors !== "string" && jQuery( selectors );
jQuery( selectors, context || this.context ) :
0;
for ( ; i < l; i++ ) { // Positional selectors never match, since there's no _selection_ context
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { if ( !rneedsContext.test( selectors ) ) {
for ( ; i < l; i++ ) {
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments // Always skip document fragments
if ( cur.nodeType < 11 && ( pos ? if ( cur.nodeType < 11 && ( targets ?
pos.index( cur ) > -1 : targets.index( cur ) > -1 :
// Don't pass non-elements to Sizzle // Don't pass non-elements to Sizzle
cur.nodeType === 1 && cur.nodeType === 1 &&
jQuery.find.matchesSelector( cur, selectors ) ) ) { jQuery.find.matchesSelector( cur, selectors ) ) ) {
matched.push( cur ); matched.push( cur );
break; break;
}
} }
} }
} }
......
...@@ -33,7 +33,7 @@ function winnow( elements, qualifier, not ) { ...@@ -33,7 +33,7 @@ function winnow( elements, qualifier, not ) {
} }
return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not; return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
} ); } );
} }
...@@ -72,10 +72,7 @@ jQuery.fn.extend( { ...@@ -72,10 +72,7 @@ jQuery.fn.extend( {
jQuery.find( selector, self[ i ], ret ); jQuery.find( selector, self[ i ], ret );
} }
// Needed because $( selector, context ) becomes $( context ).find( selector ) return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
ret.selector = this.selector ? this.selector + " " + selector : selector;
return ret;
}, },
filter: function( selector ) { filter: function( selector ) {
return this.pushStack( winnow( this, selector || [], false ) ); return this.pushStack( winnow( this, selector || [], false ) );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment