Commit 56ead6ff authored by Timmy Willison's avatar Timmy Willison

Release 1.12.1

parent 514cf3e4
...@@ -6,10 +6,10 @@ Michael Geary <mike@geary.com> ...@@ -6,10 +6,10 @@ Michael Geary <mike@geary.com>
Stefan Petre <stefan.petre@gmail.com> Stefan Petre <stefan.petre@gmail.com>
Yehuda Katz <wycats@gmail.com> Yehuda Katz <wycats@gmail.com>
Corey Jewett <cj@syntheticplayground.com> Corey Jewett <cj@syntheticplayground.com>
Klaus Hartl <klaus.hartl@gmail.com> Klaus Hartl <klaus.hartl@googlemail.com>
Franck Marcia <franck.marcia@gmail.com> Franck Marcia <franck.marcia@gmail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com> Jörn Zaefferer <joern.zaefferer@gmail.com>
Paul Bakaus <paul.bakaus@gmail.com> Paul Bakaus <paul.bakaus@googlemail.com>
Brandon Aaron <brandon.aaron@gmail.com> Brandon Aaron <brandon.aaron@gmail.com>
Mike Alsup <malsup@gmail.com> Mike Alsup <malsup@gmail.com>
Dave Methvin <dave.methvin@gmail.com> Dave Methvin <dave.methvin@gmail.com>
...@@ -47,7 +47,7 @@ Matt Curry <matt@pseudocoder.com> ...@@ -47,7 +47,7 @@ Matt Curry <matt@pseudocoder.com>
Michael Monteleone <michael@michaelmonteleone.net> Michael Monteleone <michael@michaelmonteleone.net>
Noah Sloan <noah.sloan@gmail.com> Noah Sloan <noah.sloan@gmail.com>
Tom Viner <github@viner.tv> Tom Viner <github@viner.tv>
Douglas Neiner <doug@dougneiner.com> Douglas Neiner <doug@pixelgraphics.us>
Adam J. Sontag <ajpiano@ajpiano.com> Adam J. Sontag <ajpiano@ajpiano.com>
Dave Reed <dareed@microsoft.com> Dave Reed <dareed@microsoft.com>
Ralph Whitbeck <ralph.whitbeck@gmail.com> Ralph Whitbeck <ralph.whitbeck@gmail.com>
...@@ -57,7 +57,7 @@ J. Ryan Stinnett <jryans@gmail.com> ...@@ -57,7 +57,7 @@ J. Ryan Stinnett <jryans@gmail.com>
unknown <Igen005@.upcorp.ad.uprr.com> unknown <Igen005@.upcorp.ad.uprr.com>
temp01 <temp01irc@gmail.com> temp01 <temp01irc@gmail.com>
Heungsub Lee <h@subl.ee> Heungsub Lee <h@subl.ee>
Colin Snover <github.com@zetafleet.com> Colin Snover <colin@alpha.zetafleet.com>
Ryan W Tenney <ryan@10e.us> Ryan W Tenney <ryan@10e.us>
Pinhook <contact@pinhooklabs.com> Pinhook <contact@pinhooklabs.com>
Ron Otten <r.j.g.otten@gmail.com> Ron Otten <r.j.g.otten@gmail.com>
...@@ -69,7 +69,7 @@ Henri Wiechers <hwiechers@gmail.com> ...@@ -69,7 +69,7 @@ Henri Wiechers <hwiechers@gmail.com>
Russell Holbrook <russell.holbrook@patch.com> Russell Holbrook <russell.holbrook@patch.com>
Julian Aubourg <aubourg.julian@gmail.com> Julian Aubourg <aubourg.julian@gmail.com>
Gianni Alessandro Chiappetta <gianni@runlevel6.org> Gianni Alessandro Chiappetta <gianni@runlevel6.org>
Scott Jehl <scottjehl@gmail.com> Scott Jehl <scott@scottjehl.com>
James Burke <jrburke@gmail.com> James Burke <jrburke@gmail.com>
Jonas Pfenniger <jonas@pfenniger.name> Jonas Pfenniger <jonas@pfenniger.name>
Xavi Ramirez <xavi.rmz@gmail.com> Xavi Ramirez <xavi.rmz@gmail.com>
...@@ -78,10 +78,10 @@ Sylvester Keil <sylvester@keil.or.at> ...@@ -78,10 +78,10 @@ Sylvester Keil <sylvester@keil.or.at>
Brandon Sterne <bsterne@mozilla.com> Brandon Sterne <bsterne@mozilla.com>
Mathias Bynens <mathias@qiwi.be> Mathias Bynens <mathias@qiwi.be>
Timmy Willison <timmywillisn@gmail.com> Timmy Willison <timmywillisn@gmail.com>
Corey Frang <gnarf37@gmail.com> Corey Frang <gnarf@gnarf.net>
Digitalxero <digitalxero> Digitalxero <digitalxero>
Anton Kovalyov <anton@kovalyov.net> Anton Kovalyov <anton@kovalyov.net>
David Murdoch <david@davidmurdoch.com> David Murdoch <musicisair@yahoo.com>
Josh Varner <josh.varner@gmail.com> Josh Varner <josh.varner@gmail.com>
Charles McNulty <cmcnulty@kznf.com> Charles McNulty <cmcnulty@kznf.com>
Jordan Boesch <jboesch26@gmail.com> Jordan Boesch <jboesch26@gmail.com>
...@@ -139,7 +139,7 @@ Chris Faulkner <thefaulkner@gmail.com> ...@@ -139,7 +139,7 @@ Chris Faulkner <thefaulkner@gmail.com>
Elijah Manor <elijah.manor@gmail.com> Elijah Manor <elijah.manor@gmail.com>
Daniel Chatfield <chatfielddaniel@gmail.com> Daniel Chatfield <chatfielddaniel@gmail.com>
Nikita Govorov <nikita.govorov@gmail.com> Nikita Govorov <nikita.govorov@gmail.com>
Wesley Walser <waw325@gmail.com> Wesley Walser <wwalser@atlassian.com>
Mike Pennisi <mike@mikepennisi.com> Mike Pennisi <mike@mikepennisi.com>
Markus Staab <markus.staab@redaxo.de> Markus Staab <markus.staab@redaxo.de>
Dave Riddle <david@joyvuu.com> Dave Riddle <david@joyvuu.com>
...@@ -170,8 +170,6 @@ Paul Ramos <paul.b.ramos@gmail.com> ...@@ -170,8 +170,6 @@ Paul Ramos <paul.b.ramos@gmail.com>
Rod Vagg <rod@vagg.org> Rod Vagg <rod@vagg.org>
Bennett Sorbo <bsorbo@gmail.com> Bennett Sorbo <bsorbo@gmail.com>
Sebastian Burkhard <sebi.burkhard@gmail.com> Sebastian Burkhard <sebi.burkhard@gmail.com>
Zachary Adam Kaplan <razic@viralkitty.com>
nanto_vi <nanto@moon.email.ne.jp>
nanto <nanto@moon.email.ne.jp> nanto <nanto@moon.email.ne.jp>
Danil Somsikov <danilasomsikov@gmail.com> Danil Somsikov <danilasomsikov@gmail.com>
Ryunosuke SATO <tricknotes.rs@gmail.com> Ryunosuke SATO <tricknotes.rs@gmail.com>
...@@ -179,70 +177,62 @@ Jean Boussier <jean.boussier@gmail.com> ...@@ -179,70 +177,62 @@ Jean Boussier <jean.boussier@gmail.com>
Adam Coulombe <me@adam.co> Adam Coulombe <me@adam.co>
Andrew Plummer <plummer.andrew@gmail.com> Andrew Plummer <plummer.andrew@gmail.com>
Mark Raddatz <mraddatz@gmail.com> Mark Raddatz <mraddatz@gmail.com>
Isaac Z. Schlueter <i@izs.me>
Karl Sieburg <ksieburg@yahoo.com>
Pascal Borreli <pascal@borreli.com>
Nguyen Phuc Lam <ruado1987@gmail.com>
Dmitry Gusev <dmitry.gusev@gmail.com> Dmitry Gusev <dmitry.gusev@gmail.com>
Michał Gołębiowski <m.goleb@gmail.com> Michał Gołębiowski <m.goleb@gmail.com>
Li Xudong <istonelee@gmail.com> Nguyen Phuc Lam <ruado1987@gmail.com>
Steven Benner <admin@stevenbenner.com>
Tom H Fuertes <tomfuertes@gmail.com> Tom H Fuertes <tomfuertes@gmail.com>
Renato Oliveira dos Santos <ros3@cin.ufpe.br> Brandon Johnson <bjohn465+github@gmail.com>
ros3cin <ros3@cin.ufpe.br>
Jason Bedard <jason+jquery@jbedard.ca> Jason Bedard <jason+jquery@jbedard.ca>
Kyle Robinson Young <kyle@dontkry.com> Kyle Robinson Young <kyle@dontkry.com>
Renato Oliveira dos Santos <ros3@cin.ufpe.br>
Chris Talkington <chris@talkingtontech.com> Chris Talkington <chris@talkingtontech.com>
Eddie Monge <eddie@eddiemonge.com> Eddie Monge <eddie@eddiemonge.com>
Terry Jones <terry@jon.es> Terry Jones <terry@jon.es>
Jason Merino <jasonmerino@gmail.com> Jason Merino <jasonmerino@gmail.com>
Jeremy Dunck <jdunck@gmail.com> Jeremy Dunck <jdunck@gmail.com>
Chris Price <price.c@gmail.com> Chris Price <price.c@gmail.com>
Guy Bedford <guybedford@gmail.com>
Amey Sakhadeo <me@ameyms.com> Amey Sakhadeo <me@ameyms.com>
Mike Sidorov <mikes.ekb@gmail.com>
Anthony Ryan <anthonyryan1@gmail.com> Anthony Ryan <anthonyryan1@gmail.com>
Dominik D. Geyer <dominik.geyer@gmail.com> Dominik D. Geyer <dominik.geyer@gmail.com>
George Kats <katsgeorgeek@gmail.com> George Kats <katsgeorgeek@gmail.com>
Lihan Li <frankieteardrop@gmail.com> Lihan Li <frankieteardrop@gmail.com>
Ronny Springer <springer.ronny@gmail.com> Ronny Springer <springer.ronny@gmail.com>
Chris Antaki <ChrisAntaki@gmail.com>
Marian Sollmann <marian.sollmann@cargomedia.ch> Marian Sollmann <marian.sollmann@cargomedia.ch>
njhamann <njhamann@gmail.com> Corey Frang <gnarf37@gmail.com>
Ilya Kantor <iliakan@gmail.com> Chris Antaki <ChrisAntaki@gmail.com>
Noah Hamann <njhamann@gmail.com>
David Hong <d.hong@me.com> David Hong <d.hong@me.com>
John Paul <john@johnkpaul.com>
Jakob Stoeck <jakob@pokermania.de> Jakob Stoeck <jakob@pokermania.de>
Christopher Jones <chris@cjqed.com> Christopher Jones <christopherjonesqed@gmail.com>
Forbes Lindesay <forbes@lindesay.co.uk> Forbes Lindesay <forbes@lindesay.co.uk>
John Paul <john@johnkpaul.com>
S. Andrew Sheppard <andrew@wq.io> S. Andrew Sheppard <andrew@wq.io>
Leonardo Balter <leonardo.balter@gmail.com> Leonardo Balter <leonardo.balter@gmail.com>
Roman Reiß <me@silverwind.io> Roman Reiß <me@silverwind.io>
Benjy Cui <benjytrys@gmail.com> Benjy Cui <benjytrys@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com> Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
John Hoven <hovenj@gmail.com> John Hoven <hovenj@gmail.com>
Philip Jägenstedt <philip@foolip.org>
Christian Kosmowski <ksmwsk@gmail.com> Christian Kosmowski <ksmwsk@gmail.com>
Liang Peng <poppinlp@gmail.com> Liang Peng <poppinlp@gmail.com>
TJ VanToll <tj.vantoll@gmail.com> TJ VanToll <tj.vantoll@gmail.com>
Senya Pugach <upisfree@outlook.com> Senya Pugach <upisfree@outlook.com>
Aurelio De Rosa <aurelioderosa@gmail.com> Aurelio De Rosa <aurelioderosa@gmail.com>
Nazar Mokrynskyi <nazar@mokrynskyi.com> Nazar Mokrynskyi <nazar@mokrynskyi.com>
Amit Merchant <bullredeyes@gmail.com>
Jason Bedard <jason+github@jbedard.ca>
Arthur Verschaeve <contact@arthurverschaeve.be> Arthur Verschaeve <contact@arthurverschaeve.be>
Dan Hart <danhart@notonthehighstreet.com> Dan Hart <danhart@notonthehighstreet.com>
Scott González <scott.gonzalez@gmail.com>
Zheming Sun <mescodasun@gmail.com>
Bin Xin <rhyzix@gmail.com> Bin Xin <rhyzix@gmail.com>
David Corbacho <davidcorbacho@gmail.com> David Corbacho <davidcorbacho@gmail.com>
Veaceslav Grimalschi <grimalschi@yandex.ru> Veaceslav Grimalschi <grimalschi@yandex.ru>
Daniel Husar <dano.husar@gmail.com> Daniel Husar <dano.husar@gmail.com>
Frederic Hemberger <mail@frederic-hemberger.de> Jason Bedard <jason+github@jbedard.ca>
Ben Toews <mastahyeti@gmail.com> Ben Toews <mastahyeti@gmail.com>
Aditya Raghavan <araghavan3@gmail.com> Aditya Raghavan <araghavan3@gmail.com>
Victor Homyakov <vkhomyackov@gmail.com>
Shivaji Varma <contact@shivajivarma.com>
Nicolas HENRY <icewil@gmail.com> Nicolas HENRY <icewil@gmail.com>
Norman Xu <homyu.shinn@gmail.com>
Anne-Gaelle Colom <coloma@westminster.ac.uk> Anne-Gaelle Colom <coloma@westminster.ac.uk>
Victor Homyakov <vkhomyackov@gmail.com>
George Mauer <gmauer@gmail.com> George Mauer <gmauer@gmail.com>
Leonardo Braga <leonardo.braga@gmail.com> Leonardo Braga <leonardo.braga@gmail.com>
Stephen Edgar <stephen@netweb.com.au> Stephen Edgar <stephen@netweb.com.au>
...@@ -256,25 +246,21 @@ Calvin Metcalf <calvin.metcalf@gmail.com> ...@@ -256,25 +246,21 @@ Calvin Metcalf <calvin.metcalf@gmail.com>
Mu Haibao <mhbseal@163.com> Mu Haibao <mhbseal@163.com>
Richard McDaniel <rm0026@uah.edu> Richard McDaniel <rm0026@uah.edu>
Chris Rebert <github@rebertia.com> Chris Rebert <github@rebertia.com>
Gabriel Schulhof <gabriel.schulhof@intel.com>
Gilad Peleg <giladp007@gmail.com> Gilad Peleg <giladp007@gmail.com>
Martin Naumann <martin@geekonaut.de> Martin Naumann <martin@geekonaut.de>
Marek Lewandowski <m.lewandowski@cksource.com>
Bruno Pérel <brunoperel@gmail.com> Bruno Pérel <brunoperel@gmail.com>
Reed Loden <reed@reedloden.com> Reed Loden <reed@reedloden.com>
Daniel Nill <daniellnill@gmail.com> Daniel Nill <daniellnill@gmail.com>
Yongwoo Jeon <yongwoo.jeon@navercorp.com> Yongwoo Jeon <yongwoo.jeon@navercorp.com>
Sean Henderson <seanh.za@gmail.com> Sean Henderson <seanh.za@gmail.com>
Adrian Olek <adrianolek@gmail.com>
Richard Kraaijenhagen <stdin+git@riichard.com> Richard Kraaijenhagen <stdin+git@riichard.com>
Connor Atherton <c.liam.atherton@gmail.com>
Gary Ye <garysye@gmail.com> Gary Ye <garysye@gmail.com>
Christian Grete <webmaster@christiangrete.com> 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>
Joelle Fleurantin <joasqueeniebee@gmail.com> Joelle Fleurantin <joasqueeniebee@gmail.com>
Jae Sung Park <alberto.park@gmail.com> Julian Alexander Murillo <julian.alexander.murillo@gmail.com>
Jun Sun <klsforever@gmail.com> Jun Sun <klsforever@gmail.com>
Josh Soref <apache@soref.com> Devin Wilson <dwilson6.github@gmail.com>
Henry Wong <henryw4k@gmail.com> Todor Prikumov <tono_pr@abv.bg>
Jon Dufresne <jon.dufresne@gmail.com> Zack Hall <zackhall@outlook.com>
Martijn W. van der Lee <martijn@vanderlee.com>
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 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": "3.0.0-beta1", "version": "1.12.1",
"main": "dist/jquery.js", "main": "dist/jquery.js",
"homepage": "https://jquery.com", "homepage": "http://jquery.com",
"author": { "author": {
"name": "jQuery Foundation and other contributors", "name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery/blob/3.0.0-beta1/AUTHORS.txt" "url": "https://github.com/jquery/jquery/blob/1.12-stable/AUTHORS.txt"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -41,14 +41,12 @@ ...@@ -41,14 +41,12 @@
"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", "npm": "2.1.12",
"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.12.2",
"sizzle": "2.3.0", "sizzle": "2.2.1",
"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"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"undef": true, "undef": true,
"unused": true, "unused": true,
"evil": true,
"sub": true, "sub": true,
// Support: IE < 10, Android < 4.1 // Support: IE < 10, Android < 4.1
...@@ -22,8 +23,8 @@ ...@@ -22,8 +23,8 @@
"JSON": false, "JSON": false,
"jQuery": true, "jQuery": true,
"define": true, "define": false,
"module": true, "module": false,
"noGlobal": true "noGlobal": true
} }
} }
...@@ -9,20 +9,21 @@ define( [ ...@@ -9,20 +9,21 @@ define( [
"./core/init", "./core/init",
"./ajax/parseJSON", "./ajax/parseJSON",
"./ajax/parseXML", "./ajax/parseXML",
"./event/trigger",
"./deferred" "./deferred"
], 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,
// IE leaves an \r character at EOL
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
// #7653, #8125, #8152: local protocol detection // #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent = /^(?:GET|HEAD)$/, rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//, rprotocol = /^\/\//,
rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
/* Prefilters /* Prefilters
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
...@@ -45,9 +46,11 @@ var ...@@ -45,9 +46,11 @@ var
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = "*/".concat( "*" ), allTypes = "*/".concat( "*" ),
// Anchor tag for parsing the document origin // Document location
originAnchor = document.createElement( "a" ); ajaxLocation = location.href,
originAnchor.href = location.href;
// Segment location into parts
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) { function addToPrefiltersOrTransports( structure ) {
...@@ -70,7 +73,7 @@ function addToPrefiltersOrTransports( structure ) { ...@@ -70,7 +73,7 @@ function addToPrefiltersOrTransports( structure ) {
while ( ( dataType = dataTypes[ i++ ] ) ) { while ( ( dataType = dataTypes[ i++ ] ) ) {
// Prepend if requested // Prepend if requested
if ( dataType[ 0 ] === "+" ) { if ( dataType.charAt( 0 ) === "+" ) {
dataType = dataType.slice( 1 ) || "*"; dataType = dataType.slice( 1 ) || "*";
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
...@@ -114,7 +117,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX ...@@ -114,7 +117,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
// that takes "flat" options (not to be deep extended) // that takes "flat" options (not to be deep extended)
// Fixes #9887 // Fixes #9887
function ajaxExtend( target, src ) { function ajaxExtend( target, src ) {
var key, deep, var deep, key,
flatOptions = jQuery.ajaxSettings.flatOptions || {}; flatOptions = jQuery.ajaxSettings.flatOptions || {};
for ( key in src ) { for ( key in src ) {
...@@ -134,8 +137,7 @@ function ajaxExtend( target, src ) { ...@@ -134,8 +137,7 @@ function ajaxExtend( target, src ) {
* - returns the corresponding response * - returns the corresponding response
*/ */
function ajaxHandleResponses( s, jqXHR, responses ) { function ajaxHandleResponses( s, jqXHR, responses ) {
var firstDataType, ct, finalDataType, type,
var ct, type, finalDataType, firstDataType,
contents = s.contents, contents = s.contents,
dataTypes = s.dataTypes; dataTypes = s.dataTypes;
...@@ -267,7 +269,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -267,7 +269,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( conv !== true ) { if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them // Unless errors are allowed to bubble, catch and return them
if ( conv && s.throws ) { if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
response = conv( response ); response = conv( response );
} else { } else {
try { try {
...@@ -297,9 +299,9 @@ jQuery.extend( { ...@@ -297,9 +299,9 @@ jQuery.extend( {
etag: {}, etag: {},
ajaxSettings: { ajaxSettings: {
url: location.href, url: ajaxLocation,
type: "GET", type: "GET",
isLocal: rlocalProtocol.test( location.protocol ), isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
global: true, global: true,
processData: true, processData: true,
async: true, async: true,
...@@ -391,32 +393,30 @@ jQuery.extend( { ...@@ -391,32 +393,30 @@ jQuery.extend( {
// Force options to be an object // Force options to be an object
options = options || {}; options = options || {};
var transport, var
// Cross-domain detection vars
parts,
// Loop variable
i,
// URL without anti-cache param // URL without anti-cache param
cacheURL, cacheURL,
// Response headers // Response headers as string
responseHeadersString, responseHeadersString,
responseHeaders,
// timeout handle // timeout handle
timeoutTimer, timeoutTimer,
// Url cleanup var
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 transport,
i,
// uncached part of the url // Response headers
uncached, responseHeaders,
// Create the final options object // Create the final options object
s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
...@@ -441,6 +441,9 @@ jQuery.extend( { ...@@ -441,6 +441,9 @@ jQuery.extend( {
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {}, requestHeadersNames = {},
// The jqXHR state
state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
...@@ -451,7 +454,7 @@ jQuery.extend( { ...@@ -451,7 +454,7 @@ jQuery.extend( {
// Builds headers hashtable if needed // Builds headers hashtable if needed
getResponseHeader: function( key ) { getResponseHeader: function( key ) {
var match; var match;
if ( completed ) { if ( state === 2 ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( ( match = rheaders.exec( responseHeadersString ) ) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
...@@ -465,14 +468,14 @@ jQuery.extend( { ...@@ -465,14 +468,14 @@ jQuery.extend( {
// Raw string // Raw string
getAllResponseHeaders: function() { getAllResponseHeaders: function() {
return completed ? responseHeadersString : null; return state === 2 ? responseHeadersString : null;
}, },
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
if ( completed == null ) { var lname = name.toLowerCase();
name = requestHeadersNames[ name.toLowerCase() ] = if ( !state ) {
requestHeadersNames[ name.toLowerCase() ] || name; name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
requestHeaders[ name ] = value; requestHeaders[ name ] = value;
} }
return this; return this;
...@@ -480,7 +483,7 @@ jQuery.extend( { ...@@ -480,7 +483,7 @@ jQuery.extend( {
// Overrides response content-type header // Overrides response content-type header
overrideMimeType: function( type ) { overrideMimeType: function( type ) {
if ( completed == null ) { if ( !state ) {
s.mimeType = type; s.mimeType = type;
} }
return this; return this;
...@@ -490,16 +493,16 @@ jQuery.extend( { ...@@ -490,16 +493,16 @@ jQuery.extend( {
statusCode: function( map ) { statusCode: function( map ) {
var code; var code;
if ( map ) { if ( map ) {
if ( completed ) { if ( state < 2 ) {
// Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] );
} else {
// Lazy-add the new callbacks in a way that preserves old ones
for ( code in map ) { for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
} }
} else {
// Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] );
} }
} }
return this; return this;
...@@ -517,13 +520,17 @@ jQuery.extend( { ...@@ -517,13 +520,17 @@ jQuery.extend( {
}; };
// Attach deferreds // Attach deferreds
deferred.promise( jqXHR ); deferred.promise( jqXHR ).complete = completeDeferred.add;
jqXHR.success = jqXHR.done;
jqXHR.error = jqXHR.fail;
// Add protocol if not provided (prefilters might expect it) // Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
// 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 ) + "" ) s.url = ( ( url || s.url || ajaxLocation ) + "" )
.replace( rprotocol, location.protocol + "//" ); .replace( rhash, "" )
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
// Alias method option to type as per ticket #12004 // Alias method option to type as per ticket #12004
s.type = options.method || options.type || s.method || s.type; s.type = options.method || options.type || s.method || s.type;
...@@ -531,26 +538,14 @@ jQuery.extend( { ...@@ -531,26 +538,14 @@ jQuery.extend( {
// Extract dataTypes list // Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
// A cross-domain request is in order when the origin doesn't match the current origin. // A cross-domain request is in order when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) { if ( s.crossDomain == null ) {
urlAnchor = document.createElement( "a" ); parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&
// Support: IE8-11+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
// IE throws exception if url is malformed, e.g. http://example.com:80x/ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
try { ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
urlAnchor.href = s.url; );
// Support: IE8-11+
// Anchor's host property isn't correctly set when s.url is relative
urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) {
// If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid
s.crossDomain = true;
}
} }
// Convert data if not already a string // Convert data if not already a string
...@@ -562,7 +557,7 @@ jQuery.extend( { ...@@ -562,7 +557,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 ( completed ) { if ( state === 2 ) {
return jqXHR; return jqXHR;
} }
...@@ -583,36 +578,29 @@ jQuery.extend( { ...@@ -583,36 +578,29 @@ 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
// Remove hash to simplify url manipulation cacheURL = s.url;
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 += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; cacheURL = ( s.url += ( 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 uncached url if needed // Add anti-cache in url if needed
if ( s.cache === false ) { if ( s.cache === false ) {
cacheURL = cacheURL.replace( rts, "" ); s.url = rts.test( cacheURL ) ?
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
}
// Put hash and anti-cache on the URL that will be requested (gh-1732) // If there is already a '_' parameter, set its value
s.url = cacheURL + uncached; cacheURL.replace( rts, "$1_=" + nonce++ ) :
// Change '%20' to '+' if this is encoded form body content (gh-2658) // Otherwise add one to the end
} else if ( s.data && s.processData && cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
( 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.
...@@ -646,19 +634,19 @@ jQuery.extend( { ...@@ -646,19 +634,19 @@ 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 || completed ) ) { ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
// Abort if not done already and return // Abort if not done already and return
return jqXHR.abort(); return jqXHR.abort();
} }
// Aborting is no longer a cancellation // aborting is no longer a cancellation
strAbort = "abort"; strAbort = "abort";
// Install callbacks on deferreds // Install callbacks on deferreds
completeDeferred.add( s.complete ); for ( i in { success: 1, error: 1, complete: 1 } ) {
jqXHR.done( s.success ); jqXHR[ i ]( s[ i ] );
jqXHR.fail( s.error ); }
// Get transport // Get transport
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
...@@ -675,7 +663,7 @@ jQuery.extend( { ...@@ -675,7 +663,7 @@ jQuery.extend( {
} }
// If request was aborted inside ajaxSend, stop there // If request was aborted inside ajaxSend, stop there
if ( completed ) { if ( state === 2 ) {
return jqXHR; return jqXHR;
} }
...@@ -687,17 +675,18 @@ jQuery.extend( { ...@@ -687,17 +675,18 @@ jQuery.extend( {
} }
try { try {
completed = false; state = 1;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Rethrow post-completion exceptions // Propagate exception as error if not done
if ( completed ) { if ( state < 2 ) {
done( -1, e );
// Simply rethrow otherwise
} else {
throw e; throw e;
} }
// Propagate others as results
done( -1, e );
} }
} }
...@@ -706,12 +695,13 @@ jQuery.extend( { ...@@ -706,12 +695,13 @@ jQuery.extend( {
var isSuccess, success, error, response, modified, var isSuccess, success, error, response, modified,
statusText = nativeStatusText; statusText = nativeStatusText;
// Ignore repeat invocations // Called once
if ( completed ) { if ( state === 2 ) {
return; return;
} }
completed = true; // State is "done" now
state = 2;
// Clear timeout if it exists // Clear timeout if it exists
if ( timeoutTimer ) { if ( timeoutTimer ) {
...@@ -771,7 +761,8 @@ jQuery.extend( { ...@@ -771,7 +761,8 @@ jQuery.extend( {
} }
} else { } else {
// Extract error from statusText and normalize for non-aborts // We extract error from statusText
// then normalize statusText and status for non-aborts
error = statusText; error = statusText;
if ( status || !statusText ) { if ( status || !statusText ) {
statusText = "error"; statusText = "error";
...@@ -829,7 +820,7 @@ jQuery.extend( { ...@@ -829,7 +820,7 @@ jQuery.extend( {
jQuery.each( [ "get", "post" ], function( i, method ) { jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) { jQuery[ method ] = function( url, data, callback, type ) {
// Shift arguments if data argument was omitted // shift arguments if data argument was omitted
if ( jQuery.isFunction( data ) ) { if ( jQuery.isFunction( data ) ) {
type = type || callback; type = type || callback;
callback = data; callback = data;
......
...@@ -53,7 +53,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -53,7 +53,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
return responseContainer[ 0 ]; return responseContainer[ 0 ];
}; };
// Force json dataType // force json dataType
s.dataTypes[ 0 ] = "json"; s.dataTypes[ 0 ] = "json";
// Install callback // Install callback
...@@ -77,10 +77,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -77,10 +77,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
// Save back as free // Save back as free
if ( s[ callbackName ] ) { if ( s[ callbackName ] ) {
// Make sure that re-using the options doesn't screw things around // make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback; s.jsonpCallback = originalSettings.jsonpCallback;
// Save the callback name for future use // save the callback name for future use
oldCallbacks.push( callbackName ); oldCallbacks.push( callbackName );
} }
......
...@@ -4,19 +4,29 @@ define( [ ...@@ -4,19 +4,29 @@ 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( " " );
if ( off > -1 ) { if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) ); selector = jQuery.trim( url.slice( off, url.length ) );
url = url.slice( 0, off ); url = url.slice( 0, off );
} }
......
...@@ -2,7 +2,51 @@ define( [ ...@@ -2,7 +2,51 @@ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
jQuery.parseJSON = JSON.parse; var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
jQuery.parseJSON = function( data ) {
// Attempt to parse using the native JSON parser first
if ( window.JSON && window.JSON.parse ) {
// Support: Android 2.3
// Workaround failure to string-cast null input
return window.JSON.parse( data + "" );
}
var requireNonComma,
depth = null,
str = jQuery.trim( data + "" );
// Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
// after removing valid tokens
return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
// Force termination if we see a misplaced comma
if ( requireNonComma && comma ) {
depth = 0;
}
// Perform no more replacements after returning to outermost depth
if ( depth === 0 ) {
return token;
}
// Commas must not follow "[", "{", or ","
requireNonComma = open || comma;
// Determine new depth
// array/object open ("[" or "{"): depth += true - false (increment)
// array/object close ("]" or "}"): depth += false - true (decrement)
// other cases ("," or primitive): depth += true - true (numeric cast)
depth += !close - !open;
// Remove this token
return "";
} ) ) ?
( Function( "return " + str ) )() :
jQuery.error( "Invalid JSON: " + data );
};
return jQuery.parseJSON; return jQuery.parseJSON;
......
...@@ -4,19 +4,23 @@ define( [ ...@@ -4,19 +4,23 @@ define( [
// Cross-browser xml parsing // Cross-browser xml parsing
jQuery.parseXML = function( data ) { jQuery.parseXML = function( data ) {
var xml; var xml, tmp;
if ( !data || typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
return null; return null;
} }
// Support: IE9
try { try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); if ( window.DOMParser ) { // Standard
tmp = new window.DOMParser();
xml = tmp.parseFromString( data, "text/xml" );
} else { // IE
xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
xml.async = "false";
xml.loadXML( data );
}
} catch ( e ) { } catch ( e ) {
xml = undefined; xml = undefined;
} }
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data ); jQuery.error( "Invalid XML: " + data );
} }
return xml; return xml;
......
...@@ -28,13 +28,14 @@ jQuery.ajaxSetup( { ...@@ -28,13 +28,14 @@ jQuery.ajaxSetup( {
} }
} ); } );
// Handle cache's special case and crossDomain // Handle cache's special case and global
jQuery.ajaxPrefilter( "script", function( s ) { jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.cache === undefined ) { if ( s.cache === undefined ) {
s.cache = false; s.cache = false;
} }
if ( s.crossDomain ) { if ( s.crossDomain ) {
s.type = "GET"; s.type = "GET";
s.global = false;
} }
} ); } );
...@@ -43,29 +44,55 @@ jQuery.ajaxTransport( "script", function( s ) { ...@@ -43,29 +44,55 @@ jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain requests // This transport only deals with cross domain requests
if ( s.crossDomain ) { if ( s.crossDomain ) {
var script, callback;
var script,
head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
return { return {
send: function( _, complete ) {
script = jQuery( "<script>" ).prop( { send: function( _, callback ) {
charset: s.scriptCharset,
src: s.url script = document.createElement( "script" );
} ).on(
"load error", script.async = true;
callback = function( evt ) {
script.remove(); if ( s.scriptCharset ) {
callback = null; script.charset = s.scriptCharset;
if ( evt ) { }
complete( evt.type === "error" ? 404 : 200, evt.type );
script.src = s.url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function( _, isAbort ) {
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
// Remove the script
if ( script.parentNode ) {
script.parentNode.removeChild( script );
}
// Dereference the script
script = null;
// Callback if not abort
if ( !isAbort ) {
callback( 200, "success" );
} }
} }
); };
// Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
// Use native DOM manipulation to avoid our domManip AJAX trickery // Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] ); head.insertBefore( script, head.firstChild );
}, },
abort: function() { abort: function() {
if ( callback ) { if ( script ) {
callback(); script.onload( undefined, true );
} }
} }
}; };
......
define( [ define( [
"../core", "../core",
"../var/document",
"../var/support", "../var/support",
"../ajax" "../ajax"
], function( jQuery, support ) { ], function( jQuery, document, support ) {
// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
// Support: IE6-IE8
function() {
// XHR cannot access local files, always use ActiveX for that case
if ( this.isLocal ) {
return createActiveXHR();
}
// Support: IE 9-11
// IE seems to error on cross-domain PATCH requests when ActiveX XHR
// is used. In IE 9+ always use the native XHR.
// Note: this condition won't catch Edge as it doesn't define
// document.documentMode but it also doesn't support ActiveX so it won't
// reach this code.
if ( document.documentMode > 8 ) {
return createStandardXHR();
}
// Support: IE<9
// oldIE XHR does not support non-RFC2616 methods (#13240)
// See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
// and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
// Although this check for six methods instead of eight
// since IE also does not support "trace" and "connect"
return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
createStandardXHR() || createActiveXHR();
} :
// For all other browsers, use the standard XMLHttpRequest object
createStandardXHR;
var xhrId = 0,
xhrCallbacks = {},
xhrSupported = jQuery.ajaxSettings.xhr();
jQuery.ajaxSettings.xhr = function() { // Support: IE<10
try { // Open requests must be manually aborted on unload (#5280)
return new window.XMLHttpRequest(); // See https://support.microsoft.com/kb/2856746 for more info
} catch ( e ) {} if ( window.attachEvent ) {
}; window.attachEvent( "onunload", function() {
for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]( undefined, true );
}
} );
}
// Determine support properties
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
xhrSupported = support.ajax = !!xhrSupported;
var xhrSuccessStatus = { // Create transport if the browser can provide an xhr
if ( xhrSupported ) {
// File protocol always yields status code 0, assume 200 jQuery.ajaxTransport( function( options ) {
0: 200,
// Support: IE9 // Cross domain only allowed if supported through XMLHttpRequest
// #1450: sometimes IE returns 1223 when it should be 204 if ( !options.crossDomain || support.cors ) {
1223: 204
},
xhrSupported = jQuery.ajaxSettings.xhr();
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); var callback;
support.ajax = xhrSupported = !!xhrSupported;
return {
jQuery.ajaxTransport( function( options ) { send: function( headers, complete ) {
var callback, errorCallback; var i,
xhr = options.xhr(),
// Cross domain only allowed if supported through XMLHttpRequest id = ++xhrId;
if ( support.cors || xhrSupported && !options.crossDomain ) {
return { // Open the socket
send: function( headers, complete ) { xhr.open(
var i, options.type,
xhr = options.xhr(); options.url,
options.async,
xhr.open( options.username,
options.type, options.password
options.url, );
options.async,
options.username, // Apply custom fields if provided
options.password if ( options.xhrFields ) {
); for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
// Apply custom fields if provided }
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
} }
}
// Override mime type if needed // Override mime type if needed
if ( options.mimeType && xhr.overrideMimeType ) { if ( options.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( options.mimeType ); xhr.overrideMimeType( options.mimeType );
} }
// X-Requested-With header // X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are // For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure. // akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup) // (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided. // For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest"; headers[ "X-Requested-With" ] = "XMLHttpRequest";
} }
// Set headers // Set headers
for ( i in headers ) { for ( i in headers ) {
xhr.setRequestHeader( i, headers[ i ] );
} // Support: IE<9
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
// request header to a null-value.
//
// To keep consistent with other XHR implementations, cast the value
// to string and ignore `undefined`.
if ( headers[ i ] !== undefined ) {
xhr.setRequestHeader( i, headers[ i ] + "" );
}
}
// Do send the request
// This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send( ( options.hasContent && options.data ) || null );
// Listener
callback = function( _, isAbort ) {
var status, statusText, responses;
// Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
// Clean up
delete xhrCallbacks[ id ];
callback = undefined;
xhr.onreadystatechange = jQuery.noop;
// Callback // Abort manually if needed
callback = function( type ) { if ( isAbort ) {
return function() { if ( xhr.readyState !== 4 ) {
if ( callback ) { xhr.abort();
callback = errorCallback = xhr.onload =
xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
if ( type === "abort" ) {
xhr.abort();
} else if ( type === "error" ) {
// Support: IE9
// On a manual native abort, IE9 throws
// errors on any property access that is not readyState
if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
} }
} else { } else {
complete( responses = {};
xhrSuccessStatus[ xhr.status ] || xhr.status, status = xhr.status;
xhr.statusText,
// Support: IE<10
// Support: IE9 only // Accessing binary-data responseText throws an exception
// IE9 has no XHR2 but throws on binary (trac-11426) // (#11426)
// For XHR2 non-text, let the caller handle it (gh-2498) if ( typeof xhr.responseText === "string" ) {
( xhr.responseType || "text" ) !== "text" || responses.text = xhr.responseText;
typeof xhr.responseText !== "string" ? }
{ binary: xhr.response } :
{ text: xhr.responseText }, // Firefox throws an exception when accessing
xhr.getAllResponseHeaders() // statusText for faulty cross-domain requests
); try {
statusText = xhr.statusText;
} catch ( e ) {
// We normalize with Webkit giving an empty statusText
statusText = "";
}
// Filter status for non standard behaviors
// If the request is local and we have data: assume a success
// (success with no data won't get notified, that's the best we
// can do given current implementations)
if ( !status && options.isLocal && !options.crossDomain ) {
status = responses.text ? 200 : 404;
// IE - #1450: sometimes returns 1223 when it should be 204
} else if ( status === 1223 ) {
status = 204;
}
} }
} }
};
}; // Call complete if needed
if ( responses ) {
// Listen to events complete( status, statusText, responses, xhr.getAllResponseHeaders() );
xhr.onload = callback();
errorCallback = xhr.onerror = callback( "error" );
// Support: IE9
// Use onreadystatechange to replace onabort
// to handle uncaught aborts
if ( xhr.onabort !== undefined ) {
xhr.onabort = errorCallback;
} else {
xhr.onreadystatechange = function() {
// Check readyState before timeout as it changes
if ( xhr.readyState === 4 ) {
// Allow onerror to be called first,
// but that will not handle a native abort
// Also, save errorCallback to a variable
// as xhr.onerror cannot be accessed
window.setTimeout( function() {
if ( callback ) {
errorCallback();
}
} );
} }
}; };
}
// Create the abort callback // Do send the request
callback = callback( "abort" ); // `xhr.send` may raise an exception, but it will be
// handled in jQuery.ajax (so no try/catch here)
if ( !options.async ) {
// If we're in sync mode we fire the callback
callback();
} else if ( xhr.readyState === 4 ) {
try { // (IE6 & IE7) if it's in cache and has been
// retrieved directly we need to fire the callback
window.setTimeout( callback );
} else {
// Do send the request (this may raise an exception) // Register the callback, but delay it in case `xhr.send` throws
xhr.send( options.hasContent && options.data || null ); // Add to the list of active xhr callbacks
} catch ( e ) { xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
}
},
// #14683: Only rethrow if this hasn't been notified as an error yet abort: function() {
if ( callback ) { if ( callback ) {
throw e; callback( undefined, true );
} }
} }
}, };
}
} );
}
abort: function() { // Functions to create xhrs
if ( callback ) { function createStandardXHR() {
callback(); try {
} return new window.XMLHttpRequest();
} } catch ( e ) {}
}; }
}
} ); function createActiveXHR() {
try {
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
} catch ( e ) {}
}
} ); } );
define( [ define( [
"./core", "./core",
"./attributes/val",
"./attributes/attr", "./attributes/attr",
"./attributes/prop", "./attributes/prop",
"./attributes/classes", "./attributes/classes"
"./attributes/val"
], function( jQuery ) { ], function( jQuery ) {
// Return jQuery for attributes-only inclusion // Return jQuery for attributes-only inclusion
......
...@@ -3,18 +3,15 @@ define( [ ...@@ -3,18 +3,15 @@ define( [
"../core/access", "../core/access",
"./support", "./support",
"../var/rnotwhite", "../var/rnotwhite",
"./val",
"../selector" "../selector"
], function( jQuery, access, support, rnotwhite ) { ], function( jQuery, access, support, rnotwhite ) {
var boolHook, var nodeHook, boolHook,
attrHandle = jQuery.expr.attrHandle, attrHandle = jQuery.expr.attrHandle,
ruseDefault = /^(?:checked|selected)$/i,
// Exclusively lowercase A-Z in attribute names (gh-2730) getSetAttribute = support.getSetAttribute,
// https://dom.spec.whatwg.org/#converted-to-ascii-lowercase getSetInput = support.input;
raz = /[A-Z]+/g,
lowercase = function( ch ) {
return ch.toLowerCase();
};
jQuery.fn.extend( { jQuery.fn.extend( {
attr: function( name, value ) { attr: function( name, value ) {
...@@ -46,9 +43,9 @@ jQuery.extend( { ...@@ -46,9 +43,9 @@ 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.replace( raz, lowercase ); name = name.toLowerCase();
hooks = jQuery.attrHooks[ name ] || hooks = jQuery.attrHooks[ name ] ||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
} }
if ( value !== undefined ) { if ( value !== undefined ) {
...@@ -81,6 +78,9 @@ jQuery.extend( { ...@@ -81,6 +78,9 @@ jQuery.extend( {
set: function( elem, value ) { set: function( elem, value ) {
if ( !support.radioValue && value === "radio" && if ( !support.radioValue && value === "radio" &&
jQuery.nodeName( elem, "input" ) ) { jQuery.nodeName( elem, "input" ) ) {
// Setting the type on a radio button after the value resets the value in IE8-9
// Reset value to default in case type is set after value during creation
var val = elem.value; var val = elem.value;
elem.setAttribute( "type", value ); elem.setAttribute( "type", value );
if ( val ) { if ( val ) {
...@@ -93,13 +93,34 @@ jQuery.extend( { ...@@ -93,13 +93,34 @@ jQuery.extend( {
}, },
removeAttr: function( elem, value ) { removeAttr: function( elem, value ) {
var name, var name, propName,
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++ ] ) ) {
elem.removeAttribute( name ); propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false
if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
elem[ propName ] = false;
// Support: IE<9
// Also clear defaultChecked/defaultSelected (if appropriate)
} else {
elem[ jQuery.camelCase( "default-" + name ) ] =
elem[ propName ] = false;
}
// See #9699 for explanation of this approach (setting first, then removal)
} else {
jQuery.attr( elem, name, "" );
}
elem.removeAttribute( getSetAttribute ? name : propName );
} }
} }
} }
...@@ -112,8 +133,16 @@ boolHook = { ...@@ -112,8 +133,16 @@ boolHook = {
// Remove boolean attributes when set to false // Remove boolean attributes when set to false
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
} else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
// IE<8 needs the *property* name
elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
} else { } else {
elem.setAttribute( name, name );
// Support: IE<9
// Use defaultChecked and defaultSelected for oldIE
elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
} }
return name; return name;
} }
...@@ -122,20 +151,131 @@ boolHook = { ...@@ -122,20 +151,131 @@ boolHook = {
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;
attrHandle[ name ] = function( elem, name, isXML ) { if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
var ret, handle; attrHandle[ name ] = function( elem, name, isXML ) {
if ( !isXML ) { var ret, handle;
if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter
handle = attrHandle[ name ]; // Avoid an infinite loop by temporarily removing this function from the getter
attrHandle[ name ] = ret; handle = attrHandle[ name ];
ret = getter( elem, name, isXML ) != null ? attrHandle[ name ] = ret;
name.toLowerCase() : ret = getter( elem, name, isXML ) != null ?
null; name.toLowerCase() :
attrHandle[ name ] = handle; null;
attrHandle[ name ] = handle;
}
return ret;
};
} else {
attrHandle[ name ] = function( elem, name, isXML ) {
if ( !isXML ) {
return elem[ jQuery.camelCase( "default-" + name ) ] ?
name.toLowerCase() :
null;
}
};
}
} );
// fix oldIE attroperties
if ( !getSetInput || !getSetAttribute ) {
jQuery.attrHooks.value = {
set: function( elem, value, name ) {
if ( jQuery.nodeName( elem, "input" ) ) {
// Does not return so that setAttribute is also used
elem.defaultValue = value;
} else {
// Use nodeHook if defined (#1954); otherwise setAttribute is fine
return nodeHook && nodeHook.set( elem, value, name );
}
} }
return ret;
}; };
} ); }
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !getSetAttribute ) {
// Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue
nodeHook = {
set: function( elem, value, name ) {
// Set the existing or create a new attribute node
var ret = elem.getAttributeNode( name );
if ( !ret ) {
elem.setAttributeNode(
( ret = elem.ownerDocument.createAttribute( name ) )
);
}
ret.value = value += "";
// Break association with cloned elements by also using setAttribute (#9646)
if ( name === "value" || value === elem.getAttribute( name ) ) {
return value;
}
}
};
// Some attributes are constructed with empty-string values when not defined
attrHandle.id = attrHandle.name = attrHandle.coords =
function( elem, name, isXML ) {
var ret;
if ( !isXML ) {
return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
ret.value :
null;
}
};
// Fixing value retrieval on a button requires this module
jQuery.valHooks.button = {
get: function( elem, name ) {
var ret = elem.getAttributeNode( name );
if ( ret && ret.specified ) {
return ret.value;
}
},
set: nodeHook.set
};
// Set contenteditable to false on removals(#10429)
// Setting to empty string throws an error as an invalid value
jQuery.attrHooks.contenteditable = {
set: function( elem, value, name ) {
nodeHook.set( elem, value === "" ? false : value, name );
}
};
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
// This is for removals
jQuery.each( [ "width", "height" ], function( i, name ) {
jQuery.attrHooks[ name ] = {
set: function( elem, value ) {
if ( value === "" ) {
elem.setAttribute( name, "auto" );
return value;
}
}
};
} );
}
if ( !support.style ) {
jQuery.attrHooks.style = {
get: function( elem ) {
// Return undefined in the case of empty string
// Note: IE uppercases css property names, but if we were to .toLowerCase()
// .cssText, that would destroy case sensitivity in URL's, like in "background"
return elem.style.cssText || undefined;
},
set: function( elem, value ) {
return ( elem.style.cssText = value + "" );
}
};
}
} ); } );
define( [ define( [
"../core", "../core",
"../var/rnotwhite", "../var/rnotwhite",
"../data/var/dataPriv",
"../core/init" "../core/init"
], function( jQuery, rnotwhite, dataPriv ) { ], function( jQuery, rnotwhite ) {
var rclass = /[\t\r\n\f]/g; var rclass = /[\t\r\n\f]/g;
function getClass( elem ) { function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || ""; return jQuery.attr( elem, "class" ) || "";
} }
jQuery.fn.extend( { jQuery.fn.extend( {
...@@ -38,10 +37,10 @@ jQuery.fn.extend( { ...@@ -38,10 +37,10 @@ jQuery.fn.extend( {
} }
} }
// Only assign if different to avoid unneeded rendering. // only assign if different to avoid unneeded rendering.
finalValue = jQuery.trim( cur ); finalValue = jQuery.trim( cur );
if ( curValue !== finalValue ) { if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue ); jQuery.attr( elem, "class", finalValue );
} }
} }
} }
...@@ -87,7 +86,7 @@ jQuery.fn.extend( { ...@@ -87,7 +86,7 @@ jQuery.fn.extend( {
// Only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = jQuery.trim( cur ); finalValue = jQuery.trim( cur );
if ( curValue !== finalValue ) { if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue ); jQuery.attr( elem, "class", finalValue );
} }
} }
} }
...@@ -137,21 +136,19 @@ jQuery.fn.extend( { ...@@ -137,21 +136,19 @@ jQuery.fn.extend( {
className = getClass( this ); className = getClass( this );
if ( className ) { if ( className ) {
// Store className if set // store className if set
dataPriv.set( this, "__className__", className ); jQuery._data( this, "__className__", className );
} }
// If the element has a class name or if we're passed `false`, // If the element has a class name or if we're passed "false",
// then remove the whole classname (if there was one, the above saved it). // then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything), // Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored. // falling back to the empty string if nothing was stored.
if ( this.setAttribute ) { jQuery.attr( this, "class",
this.setAttribute( "class", className || value === false ?
className || value === false ? "" :
"" : jQuery._data( this, "__className__" ) || ""
dataPriv.get( this, "__className__" ) || "" );
);
}
} }
} ); } );
}, },
......
...@@ -5,7 +5,7 @@ define( [ ...@@ -5,7 +5,7 @@ define( [
"../selector" "../selector"
], function( jQuery, access, support ) { ], function( jQuery, access, support ) {
var rfocusable = /^(?:input|select|textarea|button)$/i, var rfocusable = /^(?:input|select|textarea|button|object)$/i,
rclickable = /^(?:a|area)$/i; rclickable = /^(?:a|area)$/i;
jQuery.fn.extend( { jQuery.fn.extend( {
...@@ -14,8 +14,14 @@ jQuery.fn.extend( { ...@@ -14,8 +14,14 @@ jQuery.fn.extend( {
}, },
removeProp: function( name ) { removeProp: function( name ) {
name = jQuery.propFix[ name ] || name;
return this.each( function() { return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ];
// try/catch handles cases where IE balks (such as removing a property on window)
try {
this[ name ] = undefined;
delete this[ name ];
} catch ( e ) {}
} ); } );
} }
} ); } );
...@@ -79,12 +85,35 @@ jQuery.extend( { ...@@ -79,12 +85,35 @@ jQuery.extend( {
} }
} ); } );
// Some attributes require a special call on IE
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !support.hrefNormalized ) {
// href/src property should get the full normalized URL (#10299/#12915)
jQuery.each( [ "href", "src" ], function( i, name ) {
jQuery.propHooks[ name ] = {
get: function( elem ) {
return elem.getAttribute( name, 4 );
}
};
} );
}
// Support: Safari, IE9+
// mis-reports the default selected property of an option
// Accessing the parent's selectedIndex property fixes it
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
get: function( elem ) { get: function( elem ) {
var parent = elem.parentNode; var parent = elem.parentNode;
if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex; if ( parent ) {
parent.selectedIndex;
// Make sure that it also works with optgroups, see #5701
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
} }
return null; return null;
} }
...@@ -106,4 +135,9 @@ jQuery.each( [ ...@@ -106,4 +135,9 @@ jQuery.each( [
jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
} ); } );
// IE6/7 call enctype encoding
if ( !support.enctype ) {
jQuery.propFix.enctype = "encoding";
}
} ); } );
...@@ -4,25 +4,64 @@ define( [ ...@@ -4,25 +4,64 @@ define( [
], function( document, support ) { ], function( document, support ) {
( function() { ( function() {
var input = document.createElement( "input" ), var a,
input = document.createElement( "input" ),
div = document.createElement( "div" ),
select = document.createElement( "select" ), select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) ); opt = select.appendChild( document.createElement( "option" ) );
input.type = "checkbox"; // Setup
div = document.createElement( "div" );
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
a = div.getElementsByTagName( "a" )[ 0 ];
// Support: Android<4.4 // Support: Windows Web Apps (WWA)
// Default value for a checkbox should be "on" // `type` must use .setAttribute for WWA (#14901)
support.checkOn = input.value !== ""; input.setAttribute( "type", "checkbox" );
div.appendChild( input );
// Support: IE<=11+ a = div.getElementsByTagName( "a" )[ 0 ];
// Must access selectedIndex to make default options select
// First batch of tests.
a.style.cssText = "top:1px";
// Test setAttribute on camelCase class.
// If it works, we need attrFixes when doing get/setAttribute (ie6/7)
support.getSetAttribute = div.className !== "t";
// Get the style information from getAttribute
// (IE uses .cssText instead)
support.style = /top/.test( a.getAttribute( "style" ) );
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
support.hrefNormalized = a.getAttribute( "href" ) === "/a";
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
support.checkOn = !!input.value;
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
support.optSelected = opt.selected; support.optSelected = opt.selected;
// Support: IE<=11+ // Tests for enctype support on a form (#6743)
// An input loses its value after becoming a radio support.enctype = !!document.createElement( "form" ).enctype;
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as disabled)
select.disabled = true;
support.optDisabled = !opt.disabled;
// Support: IE8 only
// Check if we can trust getAttribute("value")
input = document.createElement( "input" ); input = document.createElement( "input" );
input.setAttribute( "value", "" );
support.input = input.getAttribute( "value" ) === "";
// Check if an input maintains its value after becoming a radio
input.value = "t"; input.value = "t";
input.type = "radio"; input.setAttribute( "type", "radio" );
support.radioValue = input.value === "t"; support.radioValue = input.value === "t";
} )(); } )();
......
...@@ -16,7 +16,8 @@ jQuery.fn.extend( { ...@@ -16,7 +16,8 @@ jQuery.fn.extend( {
hooks = jQuery.valHooks[ elem.type ] || hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ]; jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && if (
hooks &&
"get" in hooks && "get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined ( ret = hooks.get( elem, "value" ) ) !== undefined
) { ) {
...@@ -27,10 +28,10 @@ jQuery.fn.extend( { ...@@ -27,10 +28,10 @@ jQuery.fn.extend( {
return typeof ret === "string" ? return typeof ret === "string" ?
// Handle most common string cases // handle most common string cases
ret.replace( rreturn, "" ) : ret.replace( rreturn, "" ) :
// Handle cases where value is null/undef or number // handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
...@@ -55,10 +56,8 @@ jQuery.fn.extend( { ...@@ -55,10 +56,8 @@ jQuery.fn.extend( {
// Treat null/undefined as ""; convert numbers to string // Treat null/undefined as ""; convert numbers to string
if ( val == null ) { if ( val == null ) {
val = ""; val = "";
} else if ( typeof val === "number" ) { } else if ( typeof val === "number" ) {
val += ""; val += "";
} else if ( jQuery.isArray( val ) ) { } else if ( jQuery.isArray( val ) ) {
val = jQuery.map( val, function( value ) { val = jQuery.map( val, function( value ) {
return value == null ? "" : value + ""; return value == null ? "" : value + "";
...@@ -79,10 +78,13 @@ jQuery.extend( { ...@@ -79,10 +78,13 @@ jQuery.extend( {
valHooks: { valHooks: {
option: { option: {
get: function( elem ) { get: function( elem ) {
var val = jQuery.find.attr( elem, "value" );
return val != null ?
val :
// Support: IE<11 // Support: IE10-11+
// option.value not trimmed (#14858) // option.text throws exceptions (#14686, #14858)
return jQuery.trim( elem.value ); jQuery.trim( jQuery.text( elem ) );
} }
}, },
select: { select: {
...@@ -90,7 +92,7 @@ jQuery.extend( { ...@@ -90,7 +92,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", one = elem.type === "select-one" || index < 0,
values = one ? null : [], values = one ? null : [],
max = one ? index + 1 : options.length, max = one ? index + 1 : options.length,
i = index < 0 ? i = index < 0 ?
...@@ -101,11 +103,13 @@ jQuery.extend( { ...@@ -101,11 +103,13 @@ jQuery.extend( {
for ( ; i < max; i++ ) { for ( ; i < max; i++ ) {
option = options[ i ]; option = options[ i ];
// IE8-9 doesn't update selected after form reset (#2551) // oldIE doesn't update selected after form reset (#2551)
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
!option.disabled && ( support.optDisabled ?
!option.disabled :
option.getAttribute( "disabled" ) === null ) &&
( !option.parentNode.disabled || ( !option.parentNode.disabled ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
...@@ -133,10 +137,24 @@ jQuery.extend( { ...@@ -133,10 +137,24 @@ jQuery.extend( {
while ( i-- ) { while ( i-- ) {
option = options[ i ]; option = options[ i ];
if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
) {
optionSet = true; // Support: IE6
// When new option element is added to select box we need to
// force reflow of newly added node in order to workaround delay
// of initialization properties
try {
option.selected = optionSet = true;
} catch ( _ ) {
// Will be executed only in IE6
option.scrollHeight;
}
} else {
option.selected = false;
} }
} }
...@@ -144,7 +162,8 @@ jQuery.extend( { ...@@ -144,7 +162,8 @@ jQuery.extend( {
if ( !optionSet ) { if ( !optionSet ) {
elem.selectedIndex = -1; elem.selectedIndex = -1;
} }
return values;
return options;
} }
} }
} }
......
...@@ -190,9 +190,9 @@ jQuery.Callbacks = function( options ) { ...@@ -190,9 +190,9 @@ jQuery.Callbacks = function( options ) {
// Also disable .add unless we have memory (since it would have no effect) // Also disable .add unless we have memory (since it would have no effect)
// Abort any pending executions // Abort any pending executions
lock: function() { lock: function() {
locked = queue = []; locked = true;
if ( !memory && !firing ) { if ( !memory ) {
list = memory = ""; self.disable();
} }
return this; return this;
}, },
......
define( [ define( [
"./var/arr", "./var/deletedIds",
"./var/document", "./var/document",
"./var/slice", "./var/slice",
"./var/concat", "./var/concat",
...@@ -8,10 +8,9 @@ define( [ ...@@ -8,10 +8,9 @@ define( [
"./var/class2type", "./var/class2type",
"./var/toString", "./var/toString",
"./var/hasOwn", "./var/hasOwn",
"./var/support", "./var/support"
"./core/DOMEval" ], function( deletedIds, document, slice, concat, push, indexOf,
], function( arr, document, slice, concat, class2type, toString, hasOwn, support ) {
push, indexOf, class2type, toString, hasOwn, support, DOMEval ) {
var var
version = "@VERSION", version = "@VERSION",
...@@ -24,13 +23,13 @@ var ...@@ -24,13 +23,13 @@ var
return new jQuery.fn.init( selector, context ); return new jQuery.fn.init( selector, context );
}, },
// Support: Android<4.1 // Support: Android<4.1, IE<9
// Make sure we trim BOM and NBSP // Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
// Matches dashed string for camelizing // Matches dashed string for camelizing
rmsPrefix = /^-ms-/, rmsPrefix = /^-ms-/,
rdashAlpha = /-([a-z])/g, rdashAlpha = /-([\da-z])/gi,
// Used by jQuery.camelCase as callback to replace() // Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) { fcamelCase = function( all, letter ) {
...@@ -44,6 +43,9 @@ jQuery.fn = jQuery.prototype = { ...@@ -44,6 +43,9 @@ 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,
...@@ -72,6 +74,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -72,6 +74,7 @@ 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;
...@@ -113,12 +116,12 @@ jQuery.fn = jQuery.prototype = { ...@@ -113,12 +116,12 @@ jQuery.fn = jQuery.prototype = {
// For internal use only. // For internal use only.
// Behaves like an Array's method, not like a jQuery method. // Behaves like an Array's method, not like a jQuery method.
push: push, push: push,
sort: arr.sort, sort: deletedIds.sort,
splice: arr.splice splice: deletedIds.splice
}; };
jQuery.extend = jQuery.fn.extend = function() { jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone, var src, copyIsArray, copy, name, options, clone,
target = arguments[ 0 ] || {}, target = arguments[ 0 ] || {},
i = 1, i = 1,
length = arguments.length, length = arguments.length,
...@@ -128,7 +131,7 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -128,7 +131,7 @@ jQuery.extend = jQuery.fn.extend = function() {
if ( typeof target === "boolean" ) { if ( typeof target === "boolean" ) {
deep = target; deep = target;
// Skip the boolean and the target // skip the boolean and the target
target = arguments[ i ] || {}; target = arguments[ i ] || {};
i++; i++;
} }
...@@ -138,7 +141,7 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -138,7 +141,7 @@ jQuery.extend = jQuery.fn.extend = function() {
target = {}; target = {};
} }
// Extend jQuery itself if only one argument is passed // extend jQuery itself if only one argument is passed
if ( i === length ) { if ( i === length ) {
target = this; target = this;
i--; i--;
...@@ -200,72 +203,103 @@ jQuery.extend( { ...@@ -200,72 +203,103 @@ jQuery.extend( {
noop: function() {}, noop: function() {},
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
isFunction: function( obj ) { isFunction: function( obj ) {
return jQuery.type( obj ) === "function"; return jQuery.type( obj ) === "function";
}, },
isArray: Array.isArray, isArray: Array.isArray || function( obj ) {
return jQuery.type( obj ) === "array";
},
isWindow: function( obj ) { isWindow: function( obj ) {
return obj != null && obj === obj.window; /* jshint eqeqeq: false */
return obj != null && obj == obj.window;
}, },
isNumeric: function( obj ) { isNumeric: function( obj ) {
// As of jQuery 3.0, isNumeric is limited to // parseFloat NaNs numeric-cast false positives (null|true|false|"")
// strings and numbers (primitives or objects) // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// that can be coerced to finite numbers (gh-2662) // subtraction forces infinities to NaN
var type = jQuery.type( obj ); // adding 1 corrects loss of precision from parseFloat (#15100)
return ( type === "number" || type === "string" ) && var realStringObj = obj && obj.toString();
( obj - parseFloat( obj ) + 1 ) >= 0; return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
},
isEmptyObject: function( obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
}, },
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
var key;
// Not plain objects: // Must be an Object.
// - Any object or value whose internal [[Class]] property is not "[object Object]" // Because of IE, we also have to check the presence of the constructor property.
// - DOM nodes // Make sure that DOM nodes and window objects don't pass through, as well
// - window if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false; return false;
} }
if ( obj.constructor && try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call( obj, "constructor" ) &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false; return false;
} }
// If the function hasn't returned already, we're confident that // Support: IE<9
// |obj| is a plain object, created by {} or constructed with new Object // Handle iteration over inherited properties before own properties.
return true; if ( !support.ownFirst ) {
}, for ( key in obj ) {
return hasOwn.call( obj, key );
isEmptyObject: function( obj ) { }
var name;
for ( name in obj ) {
return false;
} }
return true;
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
for ( key in obj ) {}
return key === undefined || hasOwn.call( obj, key );
}, },
type: function( obj ) { type: function( obj ) {
if ( obj == null ) { if ( obj == null ) {
return obj + ""; return obj + "";
} }
// 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;
}, },
// Evaluates a script in a global context // Workarounds based on findings by Jim Driscoll
globalEval: function( code ) { // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
DOMEval( code ); globalEval: function( data ) {
if ( data && jQuery.trim( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
} )( data );
}
}, },
// Convert dashed to camelCase; used by the css and data modules // Convert dashed to camelCase; used by the css and data modules
// Support: IE9-11+
// Microsoft forgot to hump their vendor prefix (#9572) // Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) { camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
...@@ -296,7 +330,7 @@ jQuery.extend( { ...@@ -296,7 +330,7 @@ jQuery.extend( {
return obj; return obj;
}, },
// Support: Android<4.1 // Support: Android<4.1, IE<9
trim: function( text ) { trim: function( text ) {
return text == null ? return text == null ?
"" : "" :
...@@ -322,18 +356,43 @@ jQuery.extend( { ...@@ -322,18 +356,43 @@ jQuery.extend( {
}, },
inArray: function( elem, arr, i ) { inArray: function( elem, arr, i ) {
return arr == null ? -1 : indexOf.call( arr, elem, i ); var len;
if ( arr ) {
if ( indexOf ) {
return indexOf.call( arr, elem, i );
}
len = arr.length;
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
for ( ; i < len; i++ ) {
// Skip accessing in sparse arrays
if ( i in arr && arr[ i ] === elem ) {
return i;
}
}
}
return -1;
}, },
// 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,
i = first.length; i = first.length;
for ( ; j < len; j++ ) { while ( j < len ) {
first[ i++ ] = second[ j ]; first[ i++ ] = second[ j++ ];
}
// Support: IE<9
// Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
if ( len !== len ) {
while ( second[ j ] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
} }
first.length = i; first.length = i;
...@@ -398,7 +457,7 @@ jQuery.extend( { ...@@ -398,7 +457,7 @@ jQuery.extend( {
// Bind a function to a context, optionally partially applying any // Bind a function to a context, optionally partially applying any
// arguments. // arguments.
proxy: function( fn, context ) { proxy: function( fn, context ) {
var tmp, args, proxy; var args, proxy, tmp;
if ( typeof context === "string" ) { if ( typeof context === "string" ) {
tmp = fn[ context ]; tmp = fn[ context ];
...@@ -424,7 +483,9 @@ jQuery.extend( { ...@@ -424,7 +483,9 @@ jQuery.extend( {
return proxy; return proxy;
}, },
now: Date.now, now: function() {
return +( new Date() );
},
// jQuery.support is not used in Core but other projects attach their // jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist. // properties to it so it needs to exist.
...@@ -437,7 +498,7 @@ jQuery.extend( { ...@@ -437,7 +498,7 @@ jQuery.extend( {
// three lines. // three lines.
/* jshint ignore: start */ /* jshint ignore: start */
if ( typeof Symbol === "function" ) { if ( typeof Symbol === "function" ) {
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
} }
/* jshint ignore: end */ /* jshint ignore: end */
......
...@@ -6,7 +6,7 @@ define( [ ...@@ -6,7 +6,7 @@ define( [
// The value/s can optionally be executed if it's a function // The value/s can optionally be executed if it's a function
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0, var i = 0,
len = elems.length, length = elems.length,
bulk = key == null; bulk = key == null;
// Sets many values // Sets many values
...@@ -41,11 +41,11 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { ...@@ -41,11 +41,11 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
} }
if ( fn ) { if ( fn ) {
for ( ; i < len; i++ ) { for ( ; i < length; i++ ) {
fn( fn(
elems[ i ], key, raw ? elems[ i ],
value : key,
value.call( elems[ i ], i, fn( elems[ i ], key ) ) raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
); );
} }
} }
...@@ -57,7 +57,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { ...@@ -57,7 +57,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
// Gets // Gets
bulk ? bulk ?
fn.call( elems ) : fn.call( elems ) :
len ? fn( elems[ 0 ], key ) : emptyGet; length ? fn( elems[ 0 ], key ) : emptyGet;
}; };
return access; return access;
......
...@@ -12,8 +12,7 @@ var rootjQuery, ...@@ -12,8 +12,7 @@ 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 <)
// Shortcut simple #id case for speed rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
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;
...@@ -23,14 +22,14 @@ var rootjQuery, ...@@ -23,14 +22,14 @@ var rootjQuery,
return this; return this;
} }
// Method init() accepts an alternate rootjQuery // init accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101) // so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery; root = root || rootjQuery;
// Handle HTML strings // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
if ( selector[ 0 ] === "<" && if ( selector.charAt( 0 ) === "<" &&
selector[ selector.length - 1 ] === ">" && selector.charAt( selector.length - 1 ) === ">" &&
selector.length >= 3 ) { selector.length >= 3 ) {
// Assume that strings that start and end with <> are HTML and skip the regex check // Assume that strings that start and end with <> are HTML and skip the regex check
...@@ -47,7 +46,7 @@ var rootjQuery, ...@@ -47,7 +46,7 @@ var rootjQuery,
if ( match[ 1 ] ) { if ( match[ 1 ] ) {
context = context instanceof jQuery ? context[ 0 ] : context; context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat // scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present // Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML( jQuery.merge( this, jQuery.parseHTML(
match[ 1 ], match[ 1 ],
...@@ -76,12 +75,23 @@ var rootjQuery, ...@@ -76,12 +75,23 @@ var rootjQuery,
} else { } else {
elem = document.getElementById( match[ 2 ] ); elem = document.getElementById( match[ 2 ] );
if ( elem ) { // Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Inject the element directly into the jQuery object // Handle the case where IE and Opera return items
this[ 0 ] = elem; // by name instead of ID
if ( elem.id !== match[ 2 ] ) {
return rootjQuery.find( selector );
}
// Otherwise, we inject the element directly into the jQuery object
this.length = 1; this.length = 1;
this[ 0 ] = elem;
} }
this.context = document;
this.selector = selector;
return this; return this;
} }
...@@ -97,20 +107,25 @@ var rootjQuery, ...@@ -97,20 +107,25 @@ var rootjQuery,
// HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
} else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
this[ 0 ] = selector; this.context = this[ 0 ] = selector;
this.length = 1; this.length = 1;
return this; return this;
// HANDLE: $(function) // HANDLE: $(function)
// Shortcut for document ready // Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) { } else if ( jQuery.isFunction( selector ) ) {
return root.ready !== undefined ? return typeof root.ready !== "undefined" ?
root.ready( selector ) : root.ready( selector ) :
// Execute immediately if ready is not present // Execute immediately if ready is not present
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 );
}; };
......
...@@ -8,21 +8,21 @@ define( [ ...@@ -8,21 +8,21 @@ define( [
"./support" "./support"
], function( jQuery, document, rsingleTag, buildFragment, support ) { ], function( jQuery, document, rsingleTag, buildFragment, support ) {
// Argument "data" should be string of html // data: string of html
// context (optional): If specified, the fragment will be created in this context, // context (optional): If specified, the fragment will be created in this context,
// 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 ( typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
return []; return null;
} }
if ( typeof context === "boolean" ) { if ( typeof context === "boolean" ) {
keepScripts = context; keepScripts = context;
context = false; context = false;
} }
// Stop scripts or inline event handlers from being executed immediately // document.implementation stops scripts or inline event handlers from
// by using document.implementation // being executed immediately
context = context || ( support.createHTMLDocument ? context = context || ( support.createHTMLDocument ?
document.implementation.createHTMLDocument( "" ) : document.implementation.createHTMLDocument( "" ) :
document ); document );
......
define( [ define( [
"../core", "../core",
"../var/document", "../var/document",
"../core/init",
"../deferred" "../deferred"
], function( jQuery, document ) { ], function( jQuery, document ) {
...@@ -51,16 +52,42 @@ jQuery.extend( { ...@@ -51,16 +52,42 @@ 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" );
}
} }
} ); } );
/**
* Clean-up method for dom ready events
*/
function detach() {
if ( document.addEventListener ) {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
} else {
document.detachEvent( "onreadystatechange", completed );
window.detachEvent( "onload", completed );
}
}
/** /**
* The ready event handler and self cleanup method * The ready event handler and self cleanup method
*/ */
function completed() { function completed() {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed ); // readyState === "complete" is good enough for us to call the dom ready in oldIE
jQuery.ready(); if ( document.addEventListener ||
window.event.type === "load" ||
document.readyState === "complete" ) {
detach();
jQuery.ready();
}
} }
jQuery.ready.promise = function( obj ) { jQuery.ready.promise = function( obj ) {
...@@ -70,7 +97,7 @@ jQuery.ready.promise = function( obj ) { ...@@ -70,7 +97,7 @@ jQuery.ready.promise = function( obj ) {
// Catch cases where $(document).ready() is called // Catch cases where $(document).ready() is called
// after the browser event has already occurred. // after the browser event has already occurred.
// Support: IE9-10 only // Support: IE6-10
// Older IE sometimes signals "interactive" too soon // Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" || if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
...@@ -78,13 +105,53 @@ jQuery.ready.promise = function( obj ) { ...@@ -78,13 +105,53 @@ jQuery.ready.promise = function( obj ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready ); window.setTimeout( jQuery.ready );
} else { // Standards-based browsers support DOMContentLoaded
} else if ( document.addEventListener ) {
// Use the handy event callback // Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed ); document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work // A fallback to window.onload, that will always work
window.addEventListener( "load", completed ); window.addEventListener( "load", completed );
// If IE event model is used
} else {
// Ensure firing before onload, maybe late but safe also for iframes
document.attachEvent( "onreadystatechange", completed );
// A fallback to window.onload, that will always work
window.attachEvent( "onload", completed );
// If IE and not a frame
// continually check to see if the document is ready
var top = false;
try {
top = window.frameElement == null && document.documentElement;
} catch ( e ) {}
if ( top && top.doScroll ) {
( function doScrollCheck() {
if ( !jQuery.isReady ) {
try {
// Use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll( "left" );
} catch ( e ) {
return window.setTimeout( doScrollCheck, 50 );
}
// detach all dom ready events
detach();
// and execute any waiting functions
jQuery.ready();
}
} )();
}
} }
} }
return readyList.promise( obj ); return readyList.promise( obj );
......
...@@ -9,9 +9,12 @@ define( [ ...@@ -9,9 +9,12 @@ define( [
// Because of that, this security measure has to be disabled in Safari 8. // Because of that, this security measure has to be disabled in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137337 // https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = ( function() { support.createHTMLDocument = ( function() {
var body = document.implementation.createHTMLDocument( "" ).body; if ( !document.implementation.createHTMLDocument ) {
body.innerHTML = "<form></form><form></form>"; return false;
return body.childNodes.length === 2; }
var doc = document.implementation.createHTMLDocument( "" );
doc.body.innerHTML = "<form></form><form></form>";
return doc.body.childNodes.length === 2;
} )(); } )();
return support; return support;
......
define( function() { define( function() {
// Match a standalone tag // Match a standalone tag
return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
} ); } );
...@@ -8,10 +8,10 @@ define( [ ...@@ -8,10 +8,10 @@ define( [
"./css/var/rnumnonpx", "./css/var/rnumnonpx",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/var/isHidden", "./css/var/isHidden",
"./css/var/getStyles",
"./css/var/swap", "./css/var/swap",
"./css/curCSS", "./css/curCSS",
"./css/adjustCSS", "./css/adjustCSS",
"./css/defaultDisplay",
"./css/addGetHookIf", "./css/addGetHookIf",
"./css/support", "./css/support",
...@@ -19,33 +19,44 @@ define( [ ...@@ -19,33 +19,44 @@ define( [
"./core/ready", "./core/ready",
"./selector" // contains "./selector" // contains
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, ], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand,
isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) { isHidden, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support ) {
var var
// Swappable if display is none or starts with table // BuildExclude
// except "table", "table-cell", or "table-caption" getStyles = curCSS.getStyles,
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity\s*=\s*([^)]*)/i,
// swappable if display is none or starts with table except
// "table", "table-cell", or "table-caption"
// see here for display values:
// https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/, rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
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", "Moz", "ms" ], cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style; emptyStyle = document.createElement( "div" ).style;
// Return a css property mapped to a potentially vendor prefixed property // BuildExclude
curCSS = curCSS.curCSS;
// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( name ) { function vendorPropName( name ) {
// Shortcut for names that are not vendor prefixed // shortcut for names that are not vendor prefixed
if ( name in emptyStyle ) { if ( name in emptyStyle ) {
return name; return name;
} }
// Check for vendor prefixed names // check for vendor prefixed names
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
i = cssPrefixes.length; i = cssPrefixes.length;
while ( i-- ) { while ( i-- ) {
...@@ -56,15 +67,69 @@ function vendorPropName( name ) { ...@@ -56,15 +67,69 @@ function vendorPropName( name ) {
} }
} }
function setPositiveNumber( elem, value, subtract ) { 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 ] = jQuery._data( elem, "olddisplay" );
display = elem.style.display;
if ( show ) {
// Any relative (+/-) values have already been // Reset the inline display of this element to learn if it is
// normalized at this point // being hidden by cascaded rules or not
var matches = rcssNum.exec( value ); 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 ] =
jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
}
} else {
hidden = isHidden( elem );
if ( display && display !== "none" || !hidden ) {
jQuery._data(
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;
}
function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value );
return matches ? return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks // Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
value; value;
} }
...@@ -81,7 +146,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -81,7 +146,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// Both box models exclude margin, so add it if we want it // both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
} }
...@@ -93,16 +158,16 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -93,16 +158,16 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
} }
// At this point, extra isn't border nor margin, so remove border // at this point, extra isn't border nor margin, so remove border
if ( extra !== "margin" ) { if ( extra !== "margin" ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
} else { } else {
// At this point, extra isn't content, so add padding // at this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// At this point, extra isn't content nor padding, so add border // at this point, extra isn't content nor padding, so add border
if ( extra !== "padding" ) { if ( extra !== "padding" ) {
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
...@@ -115,26 +180,26 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -115,26 +180,26 @@ 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 val, var valueIsBorderBox = true,
valueIsBorderBox = true, val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ), styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = support.boxSizing &&
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
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) { if ( val <= 0 || val == null ) {
...@@ -150,7 +215,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -150,7 +215,7 @@ function getWidthOrHeight( elem, name, extra ) {
return val; return val;
} }
// Check for style in case a browser which returns unreliable values // we need the check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style // for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox && valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] ); ( support.boxSizingReliable() || val === elem.style[ name ] );
...@@ -159,7 +224,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -159,7 +224,7 @@ function getWidthOrHeight( elem, name, extra ) {
val = parseFloat( val ) || 0; val = parseFloat( val ) || 0;
} }
// Use the active box-sizing model to add/subtract irrelevant styles // use the active box-sizing model to add/subtract irrelevant styles
return ( val + return ( val +
augmentWidthOrHeight( augmentWidthOrHeight(
elem, elem,
...@@ -208,7 +273,9 @@ jQuery.extend( { ...@@ -208,7 +273,9 @@ jQuery.extend( {
// Add in properties whose names you wish to fix before // Add in properties whose names you wish to fix before
// setting or getting the value // setting or getting the value
cssProps: { cssProps: {
"float": "cssFloat"
// normalize float css property
"float": support.cssFloat ? "cssFloat" : "styleFloat"
}, },
// Get and set the style property on a DOM Node // Get and set the style property on a DOM Node
...@@ -227,7 +294,8 @@ jQuery.extend( { ...@@ -227,7 +294,8 @@ jQuery.extend( {
name = jQuery.cssProps[ origName ] || name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
// Gets hook for the prefixed version, then unprefixed version // gets hook for the prefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// Check if we're setting a value // Check if we're setting a value
...@@ -242,7 +310,7 @@ jQuery.extend( { ...@@ -242,7 +310,7 @@ jQuery.extend( {
type = "number"; type = "number";
} }
// Make sure that null and NaN values aren't set (#7116) // Make sure that null and NaN values aren't set. See: #7116
if ( value == null || value !== value ) { if ( value == null || value !== value ) {
return; return;
} }
...@@ -252,8 +320,9 @@ jQuery.extend( { ...@@ -252,8 +320,9 @@ jQuery.extend( {
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
} }
// Support: IE9-11+ // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
// background-* props affect original clone's values // but it would mean to define eight
// (for every problematic property) identical functions
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit"; style[ name ] = "inherit";
} }
...@@ -262,7 +331,11 @@ jQuery.extend( { ...@@ -262,7 +331,11 @@ jQuery.extend( {
if ( !hooks || !( "set" in hooks ) || if ( !hooks || !( "set" in hooks ) ||
( value = hooks.set( elem, value, extra ) ) !== undefined ) { ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
style[ name ] = value; // Support: IE
// Swallow errors from 'invalid' CSS values (#5509)
try {
style[ name ] = value;
} catch ( e ) {}
} }
} else { } else {
...@@ -280,14 +353,15 @@ jQuery.extend( { ...@@ -280,14 +353,15 @@ jQuery.extend( {
}, },
css: function( elem, name, extra, styles ) { css: function( elem, name, extra, styles ) {
var val, num, hooks, var num, val, hooks,
origName = jQuery.camelCase( name ); origName = jQuery.camelCase( name );
// Make sure that we're working with the right name // Make sure that we're working with the right name
name = jQuery.cssProps[ origName ] || name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
// Try prefixed name followed by the unprefixed name // gets hook for the prefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// If a hook was provided get the computed value from there // If a hook was provided get the computed value from there
...@@ -300,12 +374,12 @@ jQuery.extend( { ...@@ -300,12 +374,12 @@ jQuery.extend( {
val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
} }
// Convert "normal" to computed value //convert "normal" to computed value
if ( val === "normal" && name in cssNormalTransform ) { if ( val === "normal" && name in cssNormalTransform ) {
val = cssNormalTransform[ name ]; val = cssNormalTransform[ name ];
} }
// Make numeric if forced or a qualifier was provided and val looks numeric // Return, converting to number if forced or a qualifier was provided and val looks numeric
if ( extra === "" || extra ) { if ( extra === "" || extra ) {
num = parseFloat( val ); num = parseFloat( val );
return extra === true || isFinite( num ) ? num || 0 : val; return extra === true || isFinite( num ) ? num || 0 : val;
...@@ -319,17 +393,10 @@ jQuery.each( [ "height", "width" ], function( i, name ) { ...@@ -319,17 +393,10 @@ jQuery.each( [ "height", "width" ], function( i, name ) {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
if ( computed ) { if ( computed ) {
// 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 // however, it must have a current display style that would benefit from this
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 );
} ) : } ) :
...@@ -338,38 +405,97 @@ jQuery.each( [ "height", "width" ], function( i, name ) { ...@@ -338,38 +405,97 @@ jQuery.each( [ "height", "width" ], function( i, name ) {
}, },
set: function( elem, value, extra ) { set: function( elem, value, extra ) {
var matches, var styles = extra && getStyles( elem );
styles = extra && getStyles( elem ), return setPositiveNumber( elem, value, extra ?
subtract = extra && augmentWidthOrHeight( augmentWidthOrHeight(
elem, elem,
name, name,
extra, extra,
jQuery.css( elem, "boxSizing", false, styles ) === "border-box", support.boxSizing &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles styles
); ) : 0
);
}
};
} );
if ( !support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {
// Convert to pixels if value adjustment is needed // IE uses filters for opacity
if ( subtract && ( matches = rcssNum.exec( value ) ) && return ropacity.test( ( computed && elem.currentStyle ?
( matches[ 3 ] || "px" ) !== "px" ) { elem.currentStyle.filter :
elem.style.filter ) || "" ) ?
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
computed ? "1" : "";
},
elem.style[ name ] = value; set: function( elem, value ) {
value = jQuery.css( elem, name ); var style = elem.style,
currentStyle = elem.currentStyle,
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
filter = currentStyle && currentStyle.filter || style.filter || "";
// IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level
style.zoom = 1;
// if setting opacity to 1, and no other filters exist -
// attempt to remove filter attribute #6652
// if value === "", then remove inline opacity #12685
if ( ( value >= 1 || value === "" ) &&
jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
style.removeAttribute ) {
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
// if "filter:" is present at all, clearType is disabled, we want to avoid this
// style.removeAttribute is IE Only, but so apparently is this code path...
style.removeAttribute( "filter" );
// if there is no filter style applied in a css rule
// or unset inline opacity, we are done
if ( value === "" || currentStyle && !currentStyle.filter ) {
return;
}
} }
return setPositiveNumber( elem, value, subtract ); // otherwise, set new filter values
style.filter = ralpha.test( filter ) ?
filter.replace( ralpha, opacity ) :
filter + " " + opacity;
} }
}; };
} ); }
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) {
if ( computed ) {
return swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}
}
);
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
return ( parseFloat( curCSS( elem, "marginLeft" ) ) || return (
elem.getBoundingClientRect().left - parseFloat( curCSS( elem, "marginLeft" ) ) ||
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left; // Support: IE<=11+
} ) // Running getBoundingClientRect on a disconnected node in IE throws an error
) + "px"; // Support: IE8 only
// getClientRects() errors on disconnected elems
( jQuery.contains( elem.ownerDocument, elem ) ?
elem.getBoundingClientRect().left -
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left;
} ) :
0
)
) + "px";
} }
} }
); );
...@@ -385,7 +511,7 @@ jQuery.each( { ...@@ -385,7 +511,7 @@ jQuery.each( {
var i = 0, var i = 0,
expanded = {}, expanded = {},
// Assumes a single number if not a string // assumes a single number if not a string
parts = typeof value === "string" ? value.split( " " ) : [ value ]; parts = typeof value === "string" ? value.split( " " ) : [ value ];
for ( ; i < 4; i++ ) { for ( ; i < 4; i++ ) {
...@@ -424,6 +550,25 @@ jQuery.fn.extend( { ...@@ -424,6 +550,25 @@ 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();
}
} );
} }
} ); } );
......
define( [ define( [
"exports",
"../core", "../core",
"../var/documentElement",
"./var/rnumnonpx", "./var/rnumnonpx",
"./var/rmargin", "./var/rmargin",
"./var/getStyles",
"./support", "./support",
"../selector" // Get jQuery.contains "../selector" // contains
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) { ], function( exports, jQuery, documentElement, rnumnonpx, rmargin, support ) {
function curCSS( elem, name, computed ) { var getStyles, curCSS,
var width, minWidth, maxWidth, ret, rposition = /^(top|right|bottom|left)$/;
style = elem.style;
computed = computed || getStyles( elem ); if ( window.getComputedStyle ) {
getStyles = function( elem ) {
// Support: IE9 // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
// getPropertyValue is only needed for .css('filter') (#12537) // IE throws on elements created in popups
if ( computed ) { // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
ret = computed.getPropertyValue( name ) || computed[ name ]; var view = elem.ownerDocument.defaultView;
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { if ( !view || !view.opener ) {
view = window;
}
return view.getComputedStyle( elem );
};
curCSS = function( elem, name, computed ) {
var width, minWidth, maxWidth, ret,
style = elem.style;
computed = computed || getStyles( elem );
// getPropertyValue is only needed for .css('filter') in IE9, see #12537
ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
// Support: Opera 12.1x only
// Fall back to style even without computed
// computed is undefined for elems on document fragments
if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
ret = jQuery.style( elem, name ); ret = jQuery.style( elem, name );
} }
// A tribute to the "awesome hack by Dean Edwards" if ( computed ) {
// Android Browser returns percentage for some values,
// but width seems to be reliably pixels. // A tribute to the "awesome hack by Dean Edwards"
// This is against the CSSOM draft spec: // Chrome < 17 and Safari 5.0 uses "computed value"
// http://dev.w3.org/csswg/cssom/#resolved-values // instead of "used value" for margin-right
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { // Safari 5.1.7 (at least) returns percentage for a larger set of values,
// but width seems to be reliably pixels
// this is against the CSSOM draft spec:
// http://dev.w3.org/csswg/cssom/#resolved-values
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
// Remember the original values
width = style.width;
minWidth = style.minWidth;
maxWidth = style.maxWidth;
// Put in the new values to get a computed value out
style.minWidth = style.maxWidth = style.width = ret;
ret = computed.width;
// Revert the changed values
style.width = width;
style.minWidth = minWidth;
style.maxWidth = maxWidth;
}
}
// Support: IE
// IE returns zIndex value as an integer.
return ret === undefined ?
ret :
ret + "";
};
} else if ( documentElement.currentStyle ) {
getStyles = function( elem ) {
return elem.currentStyle;
};
curCSS = function( elem, name, computed ) {
var left, rs, rsLeft, ret,
style = elem.style;
computed = computed || getStyles( elem );
ret = computed ? computed[ name ] : undefined;
// Avoid setting ret to empty string here
// so we don't default to auto
if ( ret == null && style && style[ name ] ) {
ret = style[ name ];
}
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
// but not position css attributes, as those are
// proportional to the parent element instead
// and we can't measure the parent instead because it
// might trigger a "stacking dolls" problem
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
// Remember the original values // Remember the original values
width = style.width; left = style.left;
minWidth = style.minWidth; rs = elem.runtimeStyle;
maxWidth = style.maxWidth; rsLeft = rs && rs.left;
// Put in the new values to get a computed value out // Put in the new values to get a computed value out
style.minWidth = style.maxWidth = style.width = ret; if ( rsLeft ) {
ret = computed.width; rs.left = elem.currentStyle.left;
}
style.left = name === "fontSize" ? "1em" : ret;
ret = style.pixelLeft + "px";
// Revert the changed values // Revert the changed values
style.width = width; style.left = left;
style.minWidth = minWidth; if ( rsLeft ) {
style.maxWidth = maxWidth; rs.left = rsLeft;
}
} }
}
return ret !== undefined ? // Support: IE
// Support: IE9-11+
// IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
ret + "" : return ret === undefined ?
ret; ret :
ret + "" || "auto";
};
} }
return curCSS; exports.getStyles = getStyles;
exports.curCSS = curCSS;
} ); } );
...@@ -51,7 +51,7 @@ function defaultDisplay( nodeName ) { ...@@ -51,7 +51,7 @@ function defaultDisplay( nodeName ) {
.appendTo( doc.documentElement ); .appendTo( doc.documentElement );
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
doc = iframe[ 0 ].contentDocument; doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
// Support: IE // Support: IE
doc.write(); doc.write();
......
define( [ define( [
"../core", "../core",
"../selector" "./support",
], function( jQuery ) { "../selector",
"../css"
], function( jQuery, support ) {
function getDisplay( elem ) {
return elem.style && elem.style.display || jQuery.css( elem, "display" );
}
function filterHidden( elem ) {
while ( elem && elem.nodeType === 1 ) {
if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
return true;
}
elem = elem.parentNode;
}
return false;
}
jQuery.expr.filters.hidden = function( elem ) { jQuery.expr.filters.hidden = function( elem ) {
return !jQuery.expr.filters.visible( elem );
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements
return support.reliableHiddenOffsets() ?
( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
!elem.getClientRects().length ) :
filterHidden( elem );
}; };
jQuery.expr.filters.visible = function( elem ) { jQuery.expr.filters.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); return !jQuery.expr.filters.hidden( elem );
}; };
} ); } );
define( [ define( [], function() {
"../core",
"../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,
values = [], values = [],
...@@ -44,35 +14,23 @@ function showHide( elements, show ) { ...@@ -44,35 +14,23 @@ 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 ) ) {
values[ index ] = getDefaultDisplay( elem ); // Restore a pre-hide() value if we have one
values[ index ] = jQuery._data( elem, "display" ) || "";
} }
} else { } else {
if ( display !== "none" ) { if ( display !== "none" ) {
values[ index ] = "none"; values[ index ] = "none";
// Remember what we're overwriting // Remember the value we're replacing
dataPriv.set( elem, "display", display ); jQuery._data( elem, "display", display );
} }
} }
} }
// Set the display of the elements in a second loop to avoid constant reflow // Set the display of the elements in a second loop
// 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 ];
...@@ -82,27 +40,6 @@ function showHide( elements, show ) { ...@@ -82,27 +40,6 @@ function showHide( elements, show ) {
return elements; return elements;
} }
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; return showHide;
} ); } );
...@@ -6,7 +6,8 @@ define( [ ...@@ -6,7 +6,8 @@ define( [
], function( jQuery, document, documentElement, support ) { ], function( jQuery, document, documentElement, support ) {
( function() { ( function() {
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
...@@ -15,74 +16,166 @@ define( [ ...@@ -15,74 +16,166 @@ define( [
return; return;
} }
// Support: IE9-11+ div.style.cssText = "float:left;opacity:.5";
// Style of cloned element affects source element cloned (#8908)
// Support: IE<9
// Make sure that element opacity exists (as opposed to filter)
support.opacity = div.style.opacity === "0.5";
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support.cssFloat = !!div.style.cssFloat;
div.style.backgroundClip = "content-box"; div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = ""; div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box"; support.clearCloneStyle = div.style.backgroundClip === "content-box";
container = document.createElement( "div" );
container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
"padding:0;margin-top:1px;position:absolute"; "padding:0;margin-top:1px;position:absolute";
div.innerHTML = "";
container.appendChild( div ); container.appendChild( div );
// Executing both pixelPosition & boxSizingReliable tests require only one layout // Support: Firefox<29, Android 2.3
// so they're executed at the same time to save the second computation. // Vendor-prefix box-sizing
function computeStyleTests() { support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
div.style.cssText = div.style.WebkitBoxSizing === "";
"box-sizing:border-box;" +
"position:relative;display:block;" +
"margin:auto;border:1px;padding:1px;" +
"top:1%;width:50%";
div.innerHTML = "";
documentElement.appendChild( container );
var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%";
reliableMarginLeftVal = divStyle.marginLeft === "2px";
boxSizingReliableVal = divStyle.width === "4px";
// Support: Android 4.0 - 4.3 only
// Some styles come back with percentage values, even though they shouldn't
div.style.marginRight = "50%";
pixelMarginRightVal = divStyle.marginRight === "4px";
documentElement.removeChild( container );
}
jQuery.extend( support, { jQuery.extend( support, {
pixelPosition: function() { reliableHiddenOffsets: function() {
if ( pixelPositionVal == null ) {
// This test is executed only once but we still do memoizing computeStyleTests();
// since we can use the boxSizingReliable pre-computing. }
// No need to check if the test was already performed, though. return reliableHiddenOffsetsVal;
computeStyleTests();
return pixelPositionVal;
}, },
boxSizingReliable: function() { boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
// We're checking for pixelPositionVal here instead of boxSizingReliableVal
// since that compresses better and they're computed together anyway.
if ( pixelPositionVal == null ) {
computeStyleTests(); computeStyleTests();
} }
return boxSizingReliableVal; return boxSizingReliableVal;
}, },
pixelMarginRight: function() { pixelMarginRight: function() {
// Support: Android 4.0-4.3 // Support: Android 4.0-4.3
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal if ( pixelPositionVal == null ) {
// since that compresses better and they're computed together anyway.
if ( boxSizingReliableVal == null ) {
computeStyleTests(); computeStyleTests();
} }
return pixelMarginRightVal; return pixelMarginRightVal;
}, },
pixelPosition: function() {
if ( pixelPositionVal == null ) {
computeStyleTests();
}
return pixelPositionVal;
},
reliableMarginRight: function() {
// Support: Android 2.3
if ( pixelPositionVal == null ) {
computeStyleTests();
}
return reliableMarginRightVal;
},
reliableMarginLeft: function() { reliableMarginLeft: function() {
// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
if ( boxSizingReliableVal == null ) { if ( pixelPositionVal == null ) {
computeStyleTests(); computeStyleTests();
} }
return reliableMarginLeftVal; return reliableMarginLeftVal;
} }
} ); } );
function computeStyleTests() {
var contents, divStyle,
documentElement = document.documentElement;
// Setup
documentElement.appendChild( container );
div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;box-sizing:border-box;" +
"position:relative;display:block;" +
"margin:auto;border:1px;padding:1px;" +
"top:1%;width:50%";
// Support: IE<9
// Assume reasonable values in the absence of getComputedStyle
pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
pixelMarginRightVal = reliableMarginRightVal = true;
// Check for getComputedStyle so that this code is not run in IE<9.
if ( window.getComputedStyle ) {
divStyle = window.getComputedStyle( div );
pixelPositionVal = ( divStyle || {} ).top !== "1%";
reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
// Support: Android 4.0 - 4.3 only
// Some styles come back with percentage values, even though they shouldn't
div.style.marginRight = "50%";
pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
// Support: Android 2.3 only
// 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
contents = div.appendChild( document.createElement( "div" ) );
// Reset CSS: box-sizing; display; margin; border; padding
contents.style.cssText = div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
contents.style.marginRight = contents.style.width = "0";
div.style.width = "1px";
reliableMarginRightVal =
!parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
div.removeChild( contents );
}
// Support: IE6-8
// First check that getClientRects works as expected
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div.style.display = "none";
reliableHiddenOffsetsVal = div.getClientRects().length === 0;
if ( reliableHiddenOffsetsVal ) {
div.style.display = "";
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
contents = div.getElementsByTagName( "td" );
contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
if ( reliableHiddenOffsetsVal ) {
contents[ 0 ].style.display = "";
contents[ 1 ].style.display = "none";
reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
}
}
// Teardown
documentElement.removeChild( container );
}
} )(); } )();
return support; return support;
......
define( [ define( [
"./core", "./core",
"./core/access", "./var/deletedIds",
"./data/var/dataPriv", "./data/support",
"./data/var/dataUser" "./data/var/acceptData"
], function( jQuery, access, dataPriv, dataUser ) { ], function( jQuery, deletedIds, support, acceptData ) {
// Implementation Summary
//
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
// 2. Improve the module's maintainability by reducing the storage
// paths to a single mechanism.
// 3. Use the same single mechanism to support "private" and "user" data.
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /[A-Z]/g; rmultiDash = /([A-Z])/g;
function dataAttr( elem, key, data ) { function dataAttr( elem, key, data ) {
var name;
// If nothing was found internally, try to fetch any // If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute // data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) { if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
data = elem.getAttribute( name ); data = elem.getAttribute( name );
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
...@@ -40,35 +31,249 @@ function dataAttr( elem, key, data ) { ...@@ -40,35 +31,249 @@ function dataAttr( elem, key, data ) {
} catch ( e ) {} } catch ( e ) {}
// Make sure we set the data so it isn't changed later // Make sure we set the data so it isn't changed later
dataUser.set( elem, key, data ); jQuery.data( elem, key, data );
} else { } else {
data = undefined; data = undefined;
} }
} }
return data; return data;
} }
// checks a cache object for emptiness
function isEmptyDataObject( obj ) {
var name;
for ( name in obj ) {
// if the public data object is empty, the private is still empty
if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
continue;
}
if ( name !== "toJSON" ) {
return false;
}
}
return true;
}
function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
if ( !acceptData( elem ) ) {
return;
}
var ret, thisCache,
internalKey = jQuery.expando,
// We have to handle DOM nodes and JS objects differently because IE6-7
// can't GC object references properly across the DOM-JS boundary
isNode = elem.nodeType,
// Only DOM nodes need the global jQuery cache; JS object data is
// attached directly to the object so GC can occur automatically
cache = isNode ? jQuery.cache : elem,
// Only defining an ID for JS objects if its cache already exists allows
// the code to shortcut on the same path as a DOM node with no cache
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
// Avoid doing any more work than we need to when trying to get data on an
// object that has no data at all
if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
data === undefined && typeof name === "string" ) {
return;
}
if ( !id ) {
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
} else {
id = internalKey;
}
}
if ( !cache[ id ] ) {
// Avoid exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
}
// An object can be passed to jQuery.data instead of a key/value pair; this gets
// shallow copied over onto the existing cache
if ( typeof name === "object" || typeof name === "function" ) {
if ( pvt ) {
cache[ id ] = jQuery.extend( cache[ id ], name );
} else {
cache[ id ].data = jQuery.extend( cache[ id ].data, name );
}
}
thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
// data.
if ( !pvt ) {
if ( !thisCache.data ) {
thisCache.data = {};
}
thisCache = thisCache.data;
}
if ( data !== undefined ) {
thisCache[ jQuery.camelCase( name ) ] = data;
}
// Check for both converted-to-camel and non-converted data property names
// If a data property was specified
if ( typeof name === "string" ) {
// First Try to find as-is property data
ret = thisCache[ name ];
// Test for null|undefined property data
if ( ret == null ) {
// Try to find the camelCased property
ret = thisCache[ jQuery.camelCase( name ) ];
}
} else {
ret = thisCache;
}
return ret;
}
function internalRemoveData( elem, name, pvt ) {
if ( !acceptData( elem ) ) {
return;
}
var thisCache, i,
isNode = elem.nodeType,
// See jQuery.data for more information
cache = isNode ? jQuery.cache : elem,
id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
// If there is already no cache entry for this object, there is no
// purpose in continuing
if ( !cache[ id ] ) {
return;
}
if ( name ) {
thisCache = pvt ? cache[ id ] : cache[ id ].data;
if ( thisCache ) {
// Support array or space separated string names for data keys
if ( !jQuery.isArray( name ) ) {
// try the string as a key before any manipulation
if ( name in thisCache ) {
name = [ name ];
} else {
// split the camel cased version by spaces unless a key with the spaces exists
name = jQuery.camelCase( name );
if ( name in thisCache ) {
name = [ name ];
} else {
name = name.split( " " );
}
}
} else {
// If "name" is an array of keys...
// When data is initially created, via ("key", "val") signature,
// keys will be converted to 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 = name.concat( jQuery.map( name, jQuery.camelCase ) );
}
i = name.length;
while ( i-- ) {
delete thisCache[ name[ i ] ];
}
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
return;
}
}
}
// See jQuery.data for more information
if ( !pvt ) {
delete cache[ id ].data;
// Don't destroy the parent cache unless the internal data object
// had been the only thing left in it
if ( !isEmptyDataObject( cache[ id ] ) ) {
return;
}
}
// Destroy the cache
if ( isNode ) {
jQuery.cleanData( [ elem ], true );
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
/* jshint eqeqeq: false */
} else if ( support.deleteExpando || cache != cache.window ) {
/* jshint eqeqeq: true */
delete cache[ id ];
// When all else fails, undefined
} else {
cache[ id ] = undefined;
}
}
jQuery.extend( { jQuery.extend( {
cache: {},
// The following elements (space-suffixed to avoid Object.prototype collisions)
// throw uncatchable exceptions if you attempt to set expando properties
noData: {
"applet ": true,
"embed ": true,
// ...but Flash objects (which have this classid) *can* handle expandos
"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
},
hasData: function( elem ) { hasData: function( elem ) {
return dataUser.hasData( elem ) || dataPriv.hasData( elem ); elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
return !!elem && !isEmptyDataObject( elem );
}, },
data: function( elem, name, data ) { data: function( elem, name, data ) {
return dataUser.access( elem, name, data ); return internalData( elem, name, data );
}, },
removeData: function( elem, name ) { removeData: function( elem, name ) {
dataUser.remove( elem, name ); return internalRemoveData( elem, name );
}, },
// TODO: Now that all calls to _data and _removeData have been replaced // For internal use only.
// with direct calls to dataPriv methods, these can be deprecated.
_data: function( elem, name, data ) { _data: function( elem, name, data ) {
return dataPriv.access( elem, name, data ); return internalData( elem, name, data, true );
}, },
_removeData: function( elem, name ) { _removeData: function( elem, name ) {
dataPriv.remove( elem, name ); return internalRemoveData( elem, name, true );
} }
} ); } );
...@@ -78,12 +283,15 @@ jQuery.fn.extend( { ...@@ -78,12 +283,15 @@ jQuery.fn.extend( {
elem = this[ 0 ], elem = this[ 0 ],
attrs = elem && elem.attributes; attrs = elem && elem.attributes;
// Special expections of .data basically thwart jQuery.access,
// so implement the relevant behavior ourselves
// Gets all values // Gets all values
if ( key === undefined ) { if ( key === undefined ) {
if ( this.length ) { if ( this.length ) {
data = dataUser.get( elem ); data = jQuery.data( elem );
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
i = attrs.length; i = attrs.length;
while ( i-- ) { while ( i-- ) {
...@@ -97,7 +305,7 @@ jQuery.fn.extend( { ...@@ -97,7 +305,7 @@ jQuery.fn.extend( {
} }
} }
} }
dataPriv.set( elem, "hasDataAttrs", true ); jQuery._data( elem, "parsedAttrs", true );
} }
} }
...@@ -107,50 +315,25 @@ jQuery.fn.extend( { ...@@ -107,50 +315,25 @@ jQuery.fn.extend( {
// Sets multiple values // Sets multiple values
if ( typeof key === "object" ) { if ( typeof key === "object" ) {
return this.each( function() { return this.each( function() {
dataUser.set( this, key ); jQuery.data( this, key );
} ); } );
} }
return access( this, function( value ) { return arguments.length > 1 ?
var data;
// The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the
// `value` parameter was not undefined. An empty jQuery object
// will result in `undefined` for elem = this[ 0 ] which will
// throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) {
// Attempt to get data from the cache
// The key will always be camelCased in Data
data = dataUser.get( elem, key );
if ( data !== undefined ) {
return data;
}
// Attempt to "discover" the data in // Sets one value
// HTML5 custom data-* attrs
data = dataAttr( elem, key );
if ( data !== undefined ) {
return data;
}
// We tried really hard, but the data doesn't exist.
return;
}
// Set the data...
this.each( function() { this.each( function() {
jQuery.data( this, key, value );
} ) :
// We always store the camelCased key // Gets one value
dataUser.set( this, key, value ); // Try to fetch any internally stored data first
} ); elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
}, null, value, arguments.length > 1, null, true );
}, },
removeData: function( key ) { removeData: function( key ) {
return this.each( function() { return this.each( function() {
dataUser.remove( this, key ); jQuery.removeData( this, key );
} ); } );
} }
} ); } );
......
define( function() { define( [
"../../core"
], function( jQuery ) {
/** /**
* Determines whether an object can have data * Determines whether an object can have data
*/ */
return function( owner ) { return function( elem ) {
var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
nodeType = +elem.nodeType || 1;
// Accepts only: // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
// - Node return nodeType !== 1 && nodeType !== 9 ?
// - Node.ELEMENT_NODE false :
// - Node.DOCUMENT_NODE
// - Object // Nodes accept data unless otherwise specified; rejection can be conditional
// - Any !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
/* jshint -W018 */
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
}; };
} ); } );
...@@ -4,26 +4,15 @@ define( [ ...@@ -4,26 +4,15 @@ define( [
"./callbacks" "./callbacks"
], function( jQuery, slice ) { ], function( jQuery, slice ) {
function Identity( v ) {
return v;
}
function Thrower( ex ) {
throw ex;
}
jQuery.extend( { jQuery.extend( {
Deferred: function( func ) { Deferred: function( func ) {
var tuples = [ var tuples = [
// action, add listener, callbacks, // action, add listener, listener list, final state
// ... .then handlers, argument index, [final state] [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
[ "notify", "progress", jQuery.Callbacks( "memory" ), [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
jQuery.Callbacks( "memory" ), 2 ], [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
], ],
state = "pending", state = "pending",
promise = { promise = {
...@@ -34,23 +23,13 @@ jQuery.extend( { ...@@ -34,23 +23,13 @@ jQuery.extend( {
deferred.done( arguments ).fail( arguments ); deferred.done( arguments ).fail( arguments );
return this; return this;
}, },
"catch": function( fn ) { then: function( /* fnDone, fnFail, fnProgress */ ) {
return promise.then( null, fn );
},
// Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments; var fns = arguments;
return jQuery.Deferred( function( newDefer ) { return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// Map tuples (progress, done, fail) to arguments (done, fail, progress) // deferred[ done | fail | progress ] for forwarding actions to newDefer
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[ 1 ] ]( function() { deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments ); var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) { if ( returned && jQuery.isFunction( returned.promise ) ) {
...@@ -69,172 +48,6 @@ jQuery.extend( { ...@@ -69,172 +48,6 @@ jQuery.extend( {
fns = null; fns = null;
} ).promise(); } ).promise();
}, },
then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0;
function resolve( depth, deferred, handler, special ) {
return function() {
var that = this === promise ? undefined : this,
args = arguments,
mightThrow = function() {
var returned, then;
// Support: Promises/A+ section 2.3.3.3.3
// https://promisesaplus.com/#point-59
// Ignore double-resolution attempts
if ( depth < maxDepth ) {
return;
}
returned = handler.apply( that, args );
// Support: Promises/A+ section 2.3.1
// https://promisesaplus.com/#point-48
if ( returned === deferred.promise() ) {
throw new TypeError( "Thenable self-resolution" );
}
// Support: Promises/A+ sections 2.3.3.1, 3.5
// https://promisesaplus.com/#point-54
// https://promisesaplus.com/#point-75
// Retrieve `then` only once
then = returned &&
// Support: Promises/A+ section 2.3.4
// https://promisesaplus.com/#point-64
// Only check objects and functions for thenability
( typeof returned === "object" ||
typeof returned === "function" ) &&
returned.then;
// Handle a returned thenable
if ( jQuery.isFunction( then ) ) {
// Special processors (notify) just wait for resolution
if ( special ) {
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special )
);
// Normal processors (resolve) also hook into progress
} else {
// ...and disregard older resolution values
maxDepth++;
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special ),
resolve( maxDepth, deferred, Identity,
deferred.notify )
);
}
// Handle all other returned values
} else {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Identity ) {
that = undefined;
args = [ returned ];
}
// Process the value(s)
// Default process is resolve
( special || deferred.resolveWith )(
that || deferred.promise(), args );
}
},
// Only normal processors (resolve) catch and reject exceptions
process = special ?
mightThrow :
function() {
try {
mightThrow();
} catch ( e ) {
if ( jQuery.Deferred.exceptionHook ) {
jQuery.Deferred.exceptionHook( e,
process.stackTrace );
}
// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Thrower ) {
that = undefined;
args = [ e ];
}
deferred.rejectWith( that || deferred.promise(),
args );
}
}
};
// Support: Promises/A+ section 2.3.3.3.1
// https://promisesaplus.com/#point-57
// Re-resolve promises immediately to dodge false rejection from
// subsequent errors
if ( depth ) {
process();
} else {
// Call an optional hook to record the stack, in case of exception
// since it's otherwise lost when execution goes async
if ( jQuery.Deferred.getStackHook ) {
process.stackTrace = jQuery.Deferred.getStackHook();
}
window.setTimeout( process );
}
};
}
return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add(
resolve(
0,
newDefer,
jQuery.isFunction( onProgress ) ?
onProgress :
Identity,
newDefer.notifyWith
)
);
// fulfilled_handlers.add( ... )
tuples[ 1 ][ 3 ].add(
resolve(
0,
newDefer,
jQuery.isFunction( onFulfilled ) ?
onFulfilled :
Identity
)
);
// rejected_handlers.add( ... )
tuples[ 2 ][ 3 ].add(
resolve(
0,
newDefer,
jQuery.isFunction( onRejected ) ?
onRejected :
Thrower
)
);
} ).promise();
},
// Get a promise for this deferred // Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object // If obj is provided, the promise aspect is added to the object
...@@ -244,51 +57,33 @@ jQuery.extend( { ...@@ -244,51 +57,33 @@ jQuery.extend( {
}, },
deferred = {}; deferred = {};
// Keep pipe for back-compat
promise.pipe = promise.then;
// Add list-specific methods // Add list-specific methods
jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
var list = tuple[ 2 ], var list = tuple[ 2 ],
stateString = tuple[ 5 ]; stateString = tuple[ 3 ];
// promise.progress = list.add // promise[ done | fail | progress ] = list.add
// promise.done = list.add
// promise.fail = list.add
promise[ tuple[ 1 ] ] = list.add; promise[ tuple[ 1 ] ] = list.add;
// Handle state // Handle state
if ( stateString ) { if ( stateString ) {
list.add( list.add( function() {
function() {
// state = "resolved" (i.e., fulfilled)
// state = "rejected"
state = stateString;
},
// rejected_callbacks.disable // state = [ resolved | rejected ]
// fulfilled_callbacks.disable state = stateString;
tuples[ 3 - i ][ 2 ].disable,
// progress_callbacks.lock // [ reject_list | resolve_list ].disable; progress_list.lock
tuples[ 0 ][ 2 ].lock }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
);
} }
// progress_handlers.fire // deferred[ resolve | reject | notify ]
// fulfilled_handlers.fire
// rejected_handlers.fire
list.add( tuple[ 3 ].fire );
// deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[ 0 ] ] = function() { deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
return this; return this;
}; };
// deferred.notifyWith = list.fireWith
// deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith
deferred[ tuple[ 0 ] + "With" ] = list.fireWith; deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
} ); } );
...@@ -305,65 +100,58 @@ jQuery.extend( { ...@@ -305,65 +100,58 @@ jQuery.extend( {
}, },
// Deferred helper // Deferred helper
when: function() { when: function( subordinate /* , ..., subordinateN */ ) {
var method, resolveContexts, var i = 0,
i = 0,
resolveValues = slice.call( arguments ), resolveValues = slice.call( arguments ),
length = resolveValues.length, length = resolveValues.length,
// the count of uncompleted subordinates // the count of uncompleted subordinates
remaining = length, remaining = length !== 1 ||
( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
// the master Deferred. // the master Deferred.
master = jQuery.Deferred(), // If resolveValues consist of only a single Deferred, just use that.
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
// Update function for both resolving subordinates // Update function for both resolve and progress values
updateFunc = function( i ) { updateFunc = function( i, contexts, values ) {
return function( value ) { return function( value ) {
resolveContexts[ i ] = this; contexts[ i ] = this;
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( !( --remaining ) ) { if ( values === progressValues ) {
master.resolveWith( deferred.notifyWith( contexts, values );
resolveContexts.length === 1 ? resolveContexts[ 0 ] : resolveContexts,
resolveValues } else if ( !( --remaining ) ) {
); deferred.resolveWith( contexts, values );
} }
}; };
}; },
progressValues, progressContexts, resolveContexts;
// Add listeners to promise-like subordinates; treat others as resolved // add listeners to Deferred subordinates; treat others as resolved
if ( length > 0 ) { if ( length > 1 ) {
progressValues = new Array( length );
progressContexts = new Array( length );
resolveContexts = new Array( length ); resolveContexts = new Array( length );
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
// jQuery.Deferred - treated specially to get resolve-sync behavior resolveValues[ i ].promise()
if ( resolveValues[ i ] && .progress( updateFunc( i, progressContexts, progressValues ) )
jQuery.isFunction( ( method = resolveValues[ i ].promise ) ) ) { .done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( deferred.reject );
method.call( resolveValues[ i ] )
.done( updateFunc( i ) )
.fail( master.reject );
// Other thenables
} else if ( resolveValues[ i ] &&
jQuery.isFunction( ( method = resolveValues[ i ].then ) ) ) {
method.call(
resolveValues[ i ],
updateFunc( i ),
master.reject
);
} else { } else {
updateFunc( i )( resolveValues[ i ] ); --remaining;
} }
} }
}
// If we're not waiting on anything, resolve the master // if we're not waiting on anything, resolve the master
} else { if ( !remaining ) {
master.resolveWith(); deferred.resolveWith( resolveContexts, resolveValues );
} }
return master.promise(); return deferred.promise();
} }
} ); } );
......
define( [ define( [
"./core" "./core",
"./traversing"
], function( jQuery ) { ], function( jQuery ) {
jQuery.fn.extend( { jQuery.fn.extend( {
...@@ -23,4 +24,11 @@ jQuery.fn.extend( { ...@@ -23,4 +24,11 @@ jQuery.fn.extend( {
} }
} ); } );
// The number of elements contained in the matched element set
jQuery.fn.size = function() {
return this.length;
};
jQuery.fn.andSelf = jQuery.fn.addBack;
} ); } );
...@@ -7,9 +7,9 @@ define( [ ...@@ -7,9 +7,9 @@ define( [
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) { function( defaultExtra, funcName ) {
// Margin is only for outerHeight, outerWidth // margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) { jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
...@@ -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 ) ) {
// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
return funcName.indexOf( "outer" ) === 0 ? // isn't a whole lot we can do. See pull request at this URL for discussion:
elem[ "inner" + name ] : // https://github.com/jquery/jquery/pull/764
elem.document.documentElement[ "client" + name ]; return elem.document.documentElement[ "client" + name ];
} }
// Get document width or height // Get document width or height
...@@ -31,6 +31,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -31,6 +31,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
// whichever is greatest // whichever is greatest
// unfortunately, this causes bug #3838 in IE6/8 only,
// but there is currently no good, small way to fix it.
return Math.max( return Math.max(
elem.body[ "scroll" + name ], doc[ "scroll" + name ], elem.body[ "scroll" + name ], doc[ "scroll" + name ],
elem.body[ "offset" + name ], doc[ "offset" + name ], elem.body[ "offset" + name ], doc[ "offset" + name ],
...@@ -45,7 +47,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -45,7 +47,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 ); }, type, chainable ? margin : undefined, chainable, null );
}; };
} ); } );
} ); } );
......
define( [ define( [
"./core", "./core",
"./var/document", "./effects/support",
"./var/rcssNum", "./var/rcssNum",
"./var/rnotwhite", "./var/rnotwhite",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/var/isHidden", "./css/var/isHidden",
"./css/var/swap",
"./css/adjustCSS", "./css/adjustCSS",
"./data/var/dataPriv", "./css/defaultDisplay",
"./css/showHide",
"./var/document",
"./core/init", "./core/init",
"./effects/Tween",
"./queue", "./queue",
"./deferred",
"./traversing",
"./manipulation",
"./css", "./css",
"./effects/Tween" "./deferred",
], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap, "./traversing"
adjustCSS, dataPriv, showHide ) { ], function( jQuery, support, rcssNum, rnotwhite,
cssExpand, isHidden, adjustCSS, defaultDisplay ) {
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() {
...@@ -43,11 +34,11 @@ function createFxNow() { ...@@ -43,11 +34,11 @@ function createFxNow() {
// Generate parameters to create a standard animation // Generate parameters to create a standard animation
function genFx( type, includeWidth ) { function genFx( type, includeWidth ) {
var which, var which,
i = 0, attrs = { height: type },
attrs = { height: type }; i = 0;
// If we include width, step value is 1 to do all cssExpand values, // if we include width, step value is 1 to do all cssExpand values,
// otherwise step value is 2 to skip over Left and Right // if we don't include width, step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0; includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4 ; i += 2 - includeWidth ) { for ( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ]; which = cssExpand[ i ];
...@@ -69,7 +60,7 @@ function createTween( value, prop, animation ) { ...@@ -69,7 +60,7 @@ function createTween( value, prop, animation ) {
for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// We're done with this property // we're done with this property
return tween; return tween;
} }
} }
...@@ -77,15 +68,14 @@ function createTween( value, prop, animation ) { ...@@ -77,15 +68,14 @@ 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, hooks, oldfire, propTween, restoreDisplay, display, var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
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 = jQuery._data( elem, "fxshow" );
// Queue-skipping animations hijack the fx hooks // handle queue: false promises
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,7 +91,8 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -101,7 +91,8 @@ function defaultPrefilter( elem, props, opts ) {
anim.always( function() { anim.always( function() {
// Ensure the complete handler is called before this completes // doing this makes sure that the complete handler will be called
// before this completes
anim.always( function() { anim.always( function() {
hooks.unqueued--; hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
...@@ -111,136 +102,112 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -111,136 +102,112 @@ function defaultPrefilter( elem, props, opts ) {
} ); } );
} }
// Detect show/hide animations // height/width overflow pass
for ( prop in props ) { if ( elem.nodeType === 1 && ( "height" in props || "width" 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;
// Ignore all other no-op show/hide data // Make sure that nothing sneaks out
} else { // Record all 3 overflow attributes because IE does not
continue; // change the overflow attribute when overflowX and
} // 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 ];
// Identify a display type, preferring old show/hide data over the CSS cascade // Set display property to inline-block for height/width
restoreDisplay = dataShow && dataShow.display; // animations on inline elements that are having width/height animated
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 {
// Get nonempty value(s) by temporarily forcing visibility // Test default display if display is currently "none"
showHide( [ elem ], true ); checkDisplay = display === "none" ?
restoreDisplay = elem.style.display || restoreDisplay; jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
display = jQuery.css( elem, "display" );
showHide( [ elem ] );
}
}
// Animate inline elements as inline-block if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
if ( jQuery.css( elem, "float" ) === "none" ) { // inline-level elements accept inline-block;
// block-level elements need to be inline with layout
// Restore the original display value at the end of pure show/hide animations if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
if ( !propTween ) {
anim.done( function() {
style.display = restoreDisplay;
} );
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
}
}
style.display = "inline-block"; style.display = "inline-block";
} else {
style.zoom = 1;
} }
} }
} }
if ( opts.overflow ) { if ( opts.overflow ) {
style.overflow = "hidden"; style.overflow = "hidden";
anim.always( function() { if ( !support.shrinkWrapBlocks() ) {
style.overflow = opts.overflow[ 0 ]; anim.always( function() {
style.overflowX = opts.overflow[ 1 ]; style.overflow = opts.overflow[ 0 ];
style.overflowY = opts.overflow[ 2 ]; style.overflowX = opts.overflow[ 1 ];
} ); style.overflowY = opts.overflow[ 2 ];
} );
}
} }
// Implement show/hide animations // show/hide pass
propTween = false; for ( prop in props ) {
for ( prop in orig ) { value = props[ prop ];
if ( rfxtypes.exec( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// General show/hide setup for this element animation // If there is dataShow left over from a stopped hide or show
if ( !propTween ) { // and we are going to proceed with show, we should pretend to be hidden
if ( dataShow ) { if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
if ( "hidden" in dataShow ) { hidden = true;
hidden = dataShow.hidden; } else {
continue;
} }
} else {
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
} }
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
// Store hidden/visible for toggle so `.stop().toggle()` "reverses" // Any non-fx value stops us from restoring the original display value
if ( toggle ) { } else {
dataShow.hidden = !hidden; display = undefined;
} }
}
// Show elements before animating them if ( !jQuery.isEmptyObject( orig ) ) {
if ( hidden ) { if ( dataShow ) {
showHide( [ elem ], true ); if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
} }
} else {
dataShow = jQuery._data( elem, "fxshow", {} );
}
/* jshint -W083 */ // store state if its toggle - enables .stop().toggle() to "reverse"
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() {
// Per-property setup var prop;
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); jQuery._removeData( elem, "fxshow" );
if ( !( prop in dataShow ) ) { for ( prop in orig ) {
dataShow[ prop ] = propTween.start; jQuery.style( elem, prop, orig[ prop ] );
if ( hidden ) { }
propTween.end = propTween.start; } );
propTween.start = prop === "width" || prop === "height" ? 1 : 0; for ( prop in orig ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
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;
} }
} }
...@@ -267,8 +234,8 @@ function propFilter( props, specialEasing ) { ...@@ -267,8 +234,8 @@ function propFilter( props, specialEasing ) {
value = hooks.expand( value ); value = hooks.expand( value );
delete props[ name ]; delete props[ name ];
// Not quite $.extend, this won't overwrite existing keys. // not quite $.extend, this wont overwrite keys already present.
// Reusing 'index' because we have the correct "name" // also - reusing 'index' from above because we have the correct "name"
for ( index in value ) { for ( index in value ) {
if ( !( index in props ) ) { if ( !( index in props ) ) {
props[ index ] = value[ index ]; props[ index ] = value[ index ];
...@@ -288,7 +255,7 @@ function Animation( elem, properties, options ) { ...@@ -288,7 +255,7 @@ function Animation( elem, properties, options ) {
length = Animation.prefilters.length, length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() { deferred = jQuery.Deferred().always( function() {
// Don't match elem in the :animated selector // don't match elem in the :animated selector
delete tick.elem; delete tick.elem;
} ), } ),
tick = function() { tick = function() {
...@@ -339,7 +306,7 @@ function Animation( elem, properties, options ) { ...@@ -339,7 +306,7 @@ function Animation( elem, properties, options ) {
stop: function( gotoEnd ) { stop: function( gotoEnd ) {
var index = 0, var index = 0,
// If we are going to the end, we want to run all the tweens // if we are going to the end, we want to run all the tweens
// otherwise we skip this part // otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0; length = gotoEnd ? animation.tweens.length : 0;
if ( stopped ) { if ( stopped ) {
...@@ -350,7 +317,8 @@ function Animation( elem, properties, options ) { ...@@ -350,7 +317,8 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( 1 ); animation.tweens[ index ].run( 1 );
} }
// Resolve when we played the last frame; otherwise, reject // resolve when we played the last frame
// otherwise, reject
if ( gotoEnd ) { if ( gotoEnd ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] ); deferred.notifyWith( elem, [ animation, 1, 0 ] );
deferred.resolveWith( elem, [ animation, gotoEnd ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] );
...@@ -444,17 +412,11 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -444,17 +412,11 @@ jQuery.speed = function( speed, easing, fn ) {
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
}; };
// Go to the end state if fx are off or if document is hidden opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
if ( jQuery.fx.off || document.hidden ) { opt.duration in jQuery.fx.speeds ?
opt.duration = 0; jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
} 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 ) {
opt.queue = "fx"; opt.queue = "fx";
} }
...@@ -478,10 +440,10 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -478,10 +440,10 @@ jQuery.speed = function( speed, easing, fn ) {
jQuery.fn.extend( { jQuery.fn.extend( {
fadeTo: function( speed, to, easing, callback ) { fadeTo: function( speed, to, easing, callback ) {
// Show any hidden elements after setting opacity to 0 // show any hidden elements after setting opacity to 0
return this.filter( isHidden ).css( "opacity", 0 ).show() return this.filter( isHidden ).css( "opacity", 0 ).show()
// Animate to the value specified // animate to the value specified
.end().animate( { opacity: to }, speed, easing, callback ); .end().animate( { opacity: to }, speed, easing, callback );
}, },
animate: function( prop, speed, easing, callback ) { animate: function( prop, speed, easing, callback ) {
...@@ -493,7 +455,7 @@ jQuery.fn.extend( { ...@@ -493,7 +455,7 @@ jQuery.fn.extend( {
var anim = Animation( this, jQuery.extend( {}, prop ), optall ); var anim = Animation( this, jQuery.extend( {}, prop ), optall );
// Empty animations, or finishing resolves immediately // Empty animations, or finishing resolves immediately
if ( empty || dataPriv.get( this, "finish" ) ) { if ( empty || jQuery._data( this, "finish" ) ) {
anim.stop( true ); anim.stop( true );
} }
}; };
...@@ -523,7 +485,7 @@ jQuery.fn.extend( { ...@@ -523,7 +485,7 @@ jQuery.fn.extend( {
var dequeue = true, var dequeue = true,
index = type != null && type + "queueHooks", index = type != null && type + "queueHooks",
timers = jQuery.timers, timers = jQuery.timers,
data = dataPriv.get( this ); data = jQuery._data( this );
if ( index ) { if ( index ) {
if ( data[ index ] && data[ index ].stop ) { if ( data[ index ] && data[ index ].stop ) {
...@@ -547,9 +509,9 @@ jQuery.fn.extend( { ...@@ -547,9 +509,9 @@ jQuery.fn.extend( {
} }
} }
// Start the next in the queue if the last step wasn't forced. // start the next in the queue if the last step wasn't forced
// Timers currently will call their complete callbacks, which // timers currently will call their complete callbacks, which will dequeue
// will dequeue but only if they were gotoEnd. // but only if they were gotoEnd
if ( dequeue || !gotoEnd ) { if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
} }
...@@ -561,23 +523,23 @@ jQuery.fn.extend( { ...@@ -561,23 +523,23 @@ jQuery.fn.extend( {
} }
return this.each( function() { return this.each( function() {
var index, var index,
data = dataPriv.get( this ), data = jQuery._data( this ),
queue = data[ type + "queue" ], queue = data[ type + "queue" ],
hooks = data[ type + "queueHooks" ], hooks = data[ type + "queueHooks" ],
timers = jQuery.timers, timers = jQuery.timers,
length = queue ? queue.length : 0; length = queue ? queue.length : 0;
// Enable finishing flag on private data // enable finishing flag on private data
data.finish = true; data.finish = true;
// Empty the queue first // empty the queue first
jQuery.queue( this, type, [] ); jQuery.queue( this, type, [] );
if ( hooks && hooks.stop ) { if ( hooks && hooks.stop ) {
hooks.stop.call( this, true ); hooks.stop.call( this, true );
} }
// Look for any active animations, and finish them // look for any active animations, and finish them
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && timers[ index ].queue === type ) { if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
timers[ index ].anim.stop( true ); timers[ index ].anim.stop( true );
...@@ -585,14 +547,14 @@ jQuery.fn.extend( { ...@@ -585,14 +547,14 @@ jQuery.fn.extend( {
} }
} }
// Look for any animations in the old queue and finish them // look for any animations in the old queue and finish them
for ( index = 0; index < length; index++ ) { for ( index = 0; index < length; index++ ) {
if ( queue[ index ] && queue[ index ].finish ) { if ( queue[ index ] && queue[ index ].finish ) {
queue[ index ].finish.call( this ); queue[ index ].finish.call( this );
} }
} }
// Turn off finishing flag // turn off finishing flag
delete data.finish; delete data.finish;
} ); } );
} }
...@@ -624,8 +586,8 @@ jQuery.each( { ...@@ -624,8 +586,8 @@ jQuery.each( {
jQuery.timers = []; jQuery.timers = [];
jQuery.fx.tick = function() { jQuery.fx.tick = function() {
var timer, var timer,
i = 0, timers = jQuery.timers,
timers = jQuery.timers; i = 0;
fxNow = jQuery.now(); fxNow = jQuery.now();
...@@ -654,21 +616,15 @@ jQuery.fx.timer = function( timer ) { ...@@ -654,21 +616,15 @@ 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.requestAnimationFrame ? timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
window.requestAnimationFrame( raf ) :
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
} }
}; };
jQuery.fx.stop = function() { jQuery.fx.stop = function() {
if ( window.cancelAnimationFrame ) { window.clearInterval( timerId );
window.cancelAnimationFrame( timerId );
} else {
window.clearInterval( timerId );
}
timerId = null; timerId = null;
}; };
......
...@@ -27,12 +27,17 @@ Tween.prototype = { ...@@ -27,12 +27,17 @@ Tween.prototype = {
Tween.propHooks._default.get( this ); Tween.propHooks._default.get( this );
}, },
run: function( percent ) { run: function( percent ) {
var hooks = Tween.propHooks[ this.prop ]; var eased,
hooks = Tween.propHooks[ this.prop ];
this.pos = this.options.duration ? if ( this.options.duration ) {
jQuery.easing[ this.easing ]( percent ) : this.pos = eased = jQuery.easing[ this.easing ](
percent; percent, this.options.duration * percent, 0, 1, this.options.duration
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 );
...@@ -61,10 +66,10 @@ Tween.propHooks = { ...@@ -61,10 +66,10 @@ Tween.propHooks = {
return tween.elem[ tween.prop ]; return tween.elem[ tween.prop ];
} }
// Passing an empty string as a 3rd parameter to .css will automatically // passing an empty string as a 3rd parameter to .css will automatically
// attempt a parseFloat and fallback to a string if the parse fails. // attempt a parseFloat and fallback to a string if the parse fails
// Simple values such as "10px" are parsed to Float; // so, simple values such as "10px" are parsed to Float.
// complex values such as "rotate(1rad)" are returned as-is. // complex values such as "rotate(1rad)" are returned as is.
result = jQuery.css( tween.elem, tween.prop, "" ); result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0. // Empty strings, null, undefined and "auto" are converted to 0.
...@@ -72,9 +77,8 @@ Tween.propHooks = { ...@@ -72,9 +77,8 @@ Tween.propHooks = {
}, },
set: function( tween ) { set: function( tween ) {
// Use step hook for back compat. // use step hook for back compat - use cssHook if its there - use .style if its
// Use cssHook if its there. // available and use plain properties where available
// Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) { if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween ); jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.nodeType === 1 && } else if ( tween.elem.nodeType === 1 &&
...@@ -88,8 +92,9 @@ Tween.propHooks = { ...@@ -88,8 +92,9 @@ Tween.propHooks = {
} }
}; };
// Support: IE9 // Support: IE <=9
// Panic based approach to setting things on disconnected nodes // Panic based approach to setting things on disconnected nodes
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
set: function( tween ) { set: function( tween ) {
if ( tween.elem.nodeType && tween.elem.parentNode ) { if ( tween.elem.nodeType && tween.elem.parentNode ) {
......
...@@ -2,16 +2,20 @@ define( [ ...@@ -2,16 +2,20 @@ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
"./var/hasOwn",
"./var/slice", "./var/slice",
"./data/var/dataPriv", "./event/support",
"./data/var/acceptData",
"./core/init", "./core/init",
"./data",
"./selector" "./selector"
], function( jQuery, document, rnotwhite, slice, dataPriv ) { ], function( jQuery, document, rnotwhite, hasOwn, slice, support, acceptData ) {
var var rformElems = /^(?:input|select|textarea)$/i,
rkeyEvent = /^key/, rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)/; rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
function returnTrue() { function returnTrue() {
...@@ -70,6 +74,8 @@ function on( elem, types, selector, data, fn, one ) { ...@@ -70,6 +74,8 @@ function on( elem, types, selector, data, fn, one ) {
} }
if ( fn === false ) { if ( fn === false ) {
fn = returnFalse; fn = returnFalse;
} else if ( !fn ) {
return elem;
} }
if ( one === 1 ) { if ( one === 1 ) {
...@@ -98,11 +104,10 @@ jQuery.event = { ...@@ -98,11 +104,10 @@ jQuery.event = {
global: {}, global: {},
add: function( elem, types, handler, data, selector ) { add: function( elem, types, handler, data, selector ) {
var tmp, events, t, handleObjIn,
var handleObjIn, eventHandle, tmp, special, eventHandle, handleObj,
events, t, handleObj, handlers, type, namespaces, origType,
special, handlers, type, namespaces, origType, elemData = jQuery._data( elem );
elemData = dataPriv.get( elem );
// Don't attach events to noData or text/comment nodes (but allow plain objects) // Don't attach events to noData or text/comment nodes (but allow plain objects)
if ( !elemData ) { if ( !elemData ) {
...@@ -130,9 +135,15 @@ jQuery.event = { ...@@ -130,9 +135,15 @@ jQuery.event = {
// Discard the second event of a jQuery.event.trigger() and // Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded // when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? return typeof jQuery !== "undefined" &&
jQuery.event.dispatch.apply( elem, arguments ) : undefined; ( !e || jQuery.event.triggered !== e.type ) ?
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
undefined;
}; };
// Add elem as a property of the handle fn to prevent a memory leak
// with IE non-native events
eventHandle.elem = elem;
} }
// Handle multiple events separated by a space // Handle multiple events separated by a space
...@@ -174,12 +185,16 @@ jQuery.event = { ...@@ -174,12 +185,16 @@ jQuery.event = {
handlers = events[ type ] = []; handlers = events[ type ] = [];
handlers.delegateCount = 0; handlers.delegateCount = 0;
// Only use addEventListener if the special events handler returns false // Only use addEventListener/attachEvent if the special events handler returns false
if ( !special.setup || if ( !special.setup ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) { special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
// Bind the global event handler to the element
if ( elem.addEventListener ) { if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle ); elem.addEventListener( type, eventHandle, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, eventHandle );
} }
} }
} }
...@@ -203,15 +218,17 @@ jQuery.event = { ...@@ -203,15 +218,17 @@ jQuery.event = {
jQuery.event.global[ type ] = true; jQuery.event.global[ type ] = true;
} }
// Nullify elem to prevent memory leaks in IE
elem = null;
}, },
// Detach an event or set of events from an element // Detach an event or set of events from an element
remove: function( elem, types, handler, selector, mappedTypes ) { remove: function( elem, types, handler, selector, mappedTypes ) {
var j, handleObj, tmp,
var j, origCount, tmp, origCount, t, events,
events, t, handleObj, special, handlers, type,
special, handlers, type, namespaces, origType, namespaces, origType,
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); elemData = jQuery.hasData( elem ) && jQuery._data( elem );
if ( !elemData || !( events = elemData.events ) ) { if ( !elemData || !( events = elemData.events ) ) {
return; return;
...@@ -273,10 +290,159 @@ jQuery.event = { ...@@ -273,10 +290,159 @@ jQuery.event = {
} }
} }
// Remove data and the expando if it's no longer used // Remove the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) { if ( jQuery.isEmptyObject( events ) ) {
dataPriv.remove( elem, "handle events" ); delete elemData.handle;
// removeData also checks for emptiness and clears the expando if empty
// so use it instead of delete
jQuery._removeData( elem, "events" );
}
},
trigger: function( event, data, elem, onlyHandlers ) {
var handle, ontype, cur,
bubbleType, special, tmp, i,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split( "." );
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (#9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
jQuery._data( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
}
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if (
( !special._default ||
special._default.apply( eventPath.pop(), data ) === false
) && acceptData( elem )
) {
// Call a native DOM method on the target with the same name name as the event.
// Can't use an .isFunction() check here because IE6/7 fails that test.
// Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
try {
elem[ type ]();
} catch ( e ) {
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
}
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
} }
return event.result;
}, },
dispatch: function( event ) { dispatch: function( event ) {
...@@ -287,7 +453,7 @@ jQuery.event = { ...@@ -287,7 +453,7 @@ jQuery.event = {
var i, j, ret, matched, handleObj, var i, j, ret, matched, handleObj,
handlerQueue = [], handlerQueue = [],
args = slice.call( arguments ), args = slice.call( arguments ),
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {}; special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event // Use the fix-ed jQuery.Event rather than the (read-only) native event
...@@ -354,7 +520,9 @@ jQuery.event = { ...@@ -354,7 +520,9 @@ jQuery.event = {
if ( delegateCount && cur.nodeType && if ( delegateCount && cur.nodeType &&
( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
for ( ; cur !== this; cur = cur.parentNode || this ) { /* jshint eqeqeq: false */
for ( ; cur != this; cur = cur.parentNode || this ) {
/* jshint eqeqeq: true */
// Don't check non-elements (#13208) // Don't check non-elements (#13208)
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
...@@ -390,6 +558,52 @@ jQuery.event = { ...@@ -390,6 +558,52 @@ jQuery.event = {
return handlerQueue; return handlerQueue;
}, },
fix: function( event ) {
if ( event[ jQuery.expando ] ) {
return event;
}
// Create a writable copy of the event object and normalize some properties
var i, prop, copy,
type = event.type,
originalEvent = event,
fixHook = this.fixHooks[ type ];
if ( !fixHook ) {
this.fixHooks[ type ] = fixHook =
rmouseEvent.test( type ) ? this.mouseHooks :
rkeyEvent.test( type ) ? this.keyHooks :
{};
}
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
event = new jQuery.Event( originalEvent );
i = copy.length;
while ( i-- ) {
prop = copy[ i ];
event[ prop ] = originalEvent[ prop ];
}
// Support: IE<9
// Fix target property (#1925)
if ( !event.target ) {
event.target = originalEvent.srcElement || document;
}
// Support: Safari 6-8+
// Target should not be a text node (#504, #13143)
if ( event.target.nodeType === 3 ) {
event.target = event.target.parentNode;
}
// Support: IE<9
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
event.metaKey = !!event.metaKey;
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
},
// Includes some event props shared by KeyEvent and MouseEvent // Includes some event props shared by KeyEvent and MouseEvent
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
...@@ -410,11 +624,12 @@ jQuery.event = { ...@@ -410,11 +624,12 @@ jQuery.event = {
}, },
mouseHooks: { mouseHooks: {
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
"screenX screenY toElement" ).split( " " ), "pageX pageY screenX screenY toElement" ).split( " " ),
filter: function( event, original ) { filter: function( event, original ) {
var eventDoc, doc, body, var body, eventDoc, doc,
button = original.button; button = original.button,
fromElement = original.fromElement;
// Calculate pageX/Y if missing and clientX/Y available // Calculate pageX/Y if missing and clientX/Y available
if ( event.pageX == null && original.clientX != null ) { if ( event.pageX == null && original.clientX != null ) {
...@@ -430,6 +645,13 @@ jQuery.event = { ...@@ -430,6 +645,13 @@ jQuery.event = {
( doc && doc.clientTop || body && body.clientTop || 0 ); ( doc && doc.clientTop || body && body.clientTop || 0 );
} }
// Add relatedTarget, if necessary
if ( !event.relatedTarget && fromElement ) {
event.relatedTarget = fromElement === event.target ?
original.toElement :
fromElement;
}
// Add which for click: 1 === left; 2 === middle; 3 === right // Add which for click: 1 === left; 2 === middle; 3 === right
// Note: button is not normalized, so don't use it // Note: button is not normalized, so don't use it
if ( !event.which && button !== undefined ) { if ( !event.which && button !== undefined ) {
...@@ -440,42 +662,6 @@ jQuery.event = { ...@@ -440,42 +662,6 @@ jQuery.event = {
} }
}, },
fix: function( event ) {
if ( event[ jQuery.expando ] ) {
return event;
}
// Create a writable copy of the event object and normalize some properties
var i, prop, copy,
type = event.type,
originalEvent = event,
fixHook = this.fixHooks[ type ];
if ( !fixHook ) {
this.fixHooks[ type ] = fixHook =
rmouseEvent.test( type ) ? this.mouseHooks :
rkeyEvent.test( type ) ? this.keyHooks :
{};
}
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
event = new jQuery.Event( originalEvent );
i = copy.length;
while ( i-- ) {
prop = copy[ i ];
event[ prop ] = originalEvent[ prop ];
}
// Support: Safari 6-8+
// Target should not be a text node (#504, #13143)
if ( event.target.nodeType === 3 ) {
event.target = event.target.parentNode;
}
return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
},
special: { special: {
load: { load: {
...@@ -487,8 +673,15 @@ jQuery.event = { ...@@ -487,8 +673,15 @@ jQuery.event = {
// Fire native event if possible so blur/focus sequence is correct // Fire native event if possible so blur/focus sequence is correct
trigger: function() { trigger: function() {
if ( this !== safeActiveElement() && this.focus ) { if ( this !== safeActiveElement() && this.focus ) {
this.focus(); try {
return false; this.focus();
return false;
} catch ( e ) {
// Support: IE<9
// If we error on focus to hidden element (#1486, #12518),
// let .trigger() run the handlers
}
} }
}, },
delegateType: "focusin" delegateType: "focusin"
...@@ -506,7 +699,7 @@ jQuery.event = { ...@@ -506,7 +699,7 @@ jQuery.event = {
// For checkbox, fire native event so checked state will be right // For checkbox, fire native event so checked state will be right
trigger: function() { trigger: function() {
if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
this.click(); this.click();
return false; return false;
} }
...@@ -528,17 +721,60 @@ jQuery.event = { ...@@ -528,17 +721,60 @@ jQuery.event = {
} }
} }
} }
} },
};
// Piggyback on a donor event to simulate a different one
simulate: function( type, elem, event ) {
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true
// Previously, `originalEvent: {}` was set here, so stopPropagation call
// would not be triggered on donor event, since in our own
// jQuery.event.stopPropagation function we had a check for existence of
// originalEvent.stopPropagation method, so, consequently it would be a noop.
//
// Guard for simulated events was moved to jQuery.event.stopPropagation function
// since `originalEvent` should point to the original event for the
// constancy with other events and for more focused logic
}
);
jQuery.removeEvent = function( elem, type, handle ) { jQuery.event.trigger( e, null, elem );
// This "if" is needed for plain objects if ( e.isDefaultPrevented() ) {
if ( elem.removeEventListener ) { event.preventDefault();
elem.removeEventListener( type, handle ); }
} }
}; };
jQuery.removeEvent = document.removeEventListener ?
function( elem, type, handle ) {
// This "if" is needed for plain objects
if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle );
}
} :
function( elem, type, handle ) {
var name = "on" + type;
if ( elem.detachEvent ) {
// #8545, #7054, preventing memory leaks for custom events in IE6-8
// detachEvent needed property on element, by name of that event,
// to properly expose it to GC
if ( typeof elem[ name ] === "undefined" ) {
elem[ name ] = null;
}
elem.detachEvent( name, handle );
}
};
jQuery.Event = function( src, props ) { jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword // Allow instantiation without the 'new' keyword
...@@ -556,7 +792,7 @@ jQuery.Event = function( src, props ) { ...@@ -556,7 +792,7 @@ jQuery.Event = function( src, props ) {
this.isDefaultPrevented = src.defaultPrevented || this.isDefaultPrevented = src.defaultPrevented ||
src.defaultPrevented === undefined && src.defaultPrevented === undefined &&
// Support: Android<4.0 // Support: IE < 9, Android < 4.0
src.returnValue === false ? src.returnValue === false ?
returnTrue : returnTrue :
returnFalse; returnFalse;
...@@ -590,9 +826,18 @@ jQuery.Event.prototype = { ...@@ -590,9 +826,18 @@ jQuery.Event.prototype = {
var e = this.originalEvent; var e = this.originalEvent;
this.isDefaultPrevented = returnTrue; this.isDefaultPrevented = returnTrue;
if ( !e ) {
return;
}
if ( e ) { // If preventDefault exists, run it on the original event
if ( e.preventDefault ) {
e.preventDefault(); e.preventDefault();
// Support: IE
// Otherwise set the returnValue property of the original event to false
} else {
e.returnValue = false;
} }
}, },
stopPropagation: function() { stopPropagation: function() {
...@@ -600,16 +845,25 @@ jQuery.Event.prototype = { ...@@ -600,16 +845,25 @@ jQuery.Event.prototype = {
this.isPropagationStopped = returnTrue; this.isPropagationStopped = returnTrue;
if ( e ) { if ( !e || this.isSimulated ) {
return;
}
// If stopPropagation exists, run it on the original event
if ( e.stopPropagation ) {
e.stopPropagation(); e.stopPropagation();
} }
// Support: IE
// Set the cancelBubble property of the original event to true
e.cancelBubble = true;
}, },
stopImmediatePropagation: function() { stopImmediatePropagation: function() {
var e = this.originalEvent; var e = this.originalEvent;
this.isImmediatePropagationStopped = returnTrue; this.isImmediatePropagationStopped = returnTrue;
if ( e ) { if ( e && e.stopImmediatePropagation ) {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
} }
...@@ -653,6 +907,171 @@ jQuery.each( { ...@@ -653,6 +907,171 @@ jQuery.each( {
}; };
} ); } );
// IE submit delegation
if ( !support.submit ) {
jQuery.event.special.submit = {
setup: function() {
// Only need this for delegated form submit events
if ( jQuery.nodeName( this, "form" ) ) {
return false;
}
// Lazy-add a submit handler when a descendant form may potentially be submitted
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
// Node name check avoids a VML-related crash in IE (#9807)
var elem = e.target,
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
// Support: IE <=8
// We use jQuery.prop instead of elem.form
// to allow fixing the IE8 delegated submit issue (gh-2332)
// by 3rd party polyfills/workarounds.
jQuery.prop( elem, "form" ) :
undefined;
if ( form && !jQuery._data( form, "submit" ) ) {
jQuery.event.add( form, "submit._submit", function( event ) {
event._submitBubble = true;
} );
jQuery._data( form, "submit", true );
}
} );
// return undefined since we don't need an event listener
},
postDispatch: function( event ) {
// If form was submitted by the user, bubble the event up the tree
if ( event._submitBubble ) {
delete event._submitBubble;
if ( this.parentNode && !event.isTrigger ) {
jQuery.event.simulate( "submit", this.parentNode, event );
}
}
},
teardown: function() {
// Only need this for delegated form submit events
if ( jQuery.nodeName( this, "form" ) ) {
return false;
}
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
jQuery.event.remove( this, "._submit" );
}
};
}
// IE change delegation and checkbox/radio fix
if ( !support.change ) {
jQuery.event.special.change = {
setup: function() {
if ( rformElems.test( this.nodeName ) ) {
// IE doesn't fire change on a check/radio until blur; trigger it on click
// after a propertychange. Eat the blur-change in special.change.handle.
// This still fires onchange a second time for check/radio after blur.
if ( this.type === "checkbox" || this.type === "radio" ) {
jQuery.event.add( this, "propertychange._change", function( event ) {
if ( event.originalEvent.propertyName === "checked" ) {
this._justChanged = true;
}
} );
jQuery.event.add( this, "click._change", function( event ) {
if ( this._justChanged && !event.isTrigger ) {
this._justChanged = false;
}
// Allow triggered, simulated change events (#11500)
jQuery.event.simulate( "change", this, event );
} );
}
return false;
}
// Delegated event; lazy-add a change handler on descendant inputs
jQuery.event.add( this, "beforeactivate._change", function( e ) {
var elem = e.target;
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
jQuery.event.add( elem, "change._change", function( event ) {
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
jQuery.event.simulate( "change", this.parentNode, event );
}
} );
jQuery._data( elem, "change", true );
}
} );
},
handle: function( event ) {
var elem = event.target;
// Swallow native change events from checkbox/radio, we already triggered them above
if ( this !== elem || event.isSimulated || event.isTrigger ||
( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
return event.handleObj.handler.apply( this, arguments );
}
},
teardown: function() {
jQuery.event.remove( this, "._change" );
return !rformElems.test( this.nodeName );
}
};
}
// Support: Firefox
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
//
// Support: Chrome, Safari
// focus(in | out) events fire after focus & blur events,
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
};
jQuery.event.special[ fix ] = {
setup: function() {
var doc = this.ownerDocument || this,
attaches = jQuery._data( doc, fix );
if ( !attaches ) {
doc.addEventListener( orig, handler, true );
}
jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
var doc = this.ownerDocument || this,
attaches = jQuery._data( doc, fix ) - 1;
if ( !attaches ) {
doc.removeEventListener( orig, handler, true );
jQuery._removeData( doc, fix );
} else {
jQuery._data( doc, fix, attaches );
}
}
};
} );
}
jQuery.fn.extend( { jQuery.fn.extend( {
on: function( types, selector, data, fn ) { on: function( types, selector, data, fn ) {
...@@ -696,6 +1115,18 @@ jQuery.fn.extend( { ...@@ -696,6 +1115,18 @@ jQuery.fn.extend( {
return this.each( function() { return this.each( function() {
jQuery.event.remove( this, types, fn, selector ); jQuery.event.remove( this, types, fn, selector );
} ); } );
},
trigger: function( type, data ) {
return this.each( function() {
jQuery.event.trigger( type, data, this );
} );
},
triggerHandler: function( type, data ) {
var elem = this[ 0 ];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
} }
} ); } );
......
define( [ define( [
"../core", "../core",
"../event"
"../event",
"./trigger"
], function( jQuery ) { ], function( jQuery ) {
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ), "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
function( i, name ) { function( i, name ) {
// Handle event binding // Handle event binding
......
define( [ define( [
"../var/document",
"../var/support" "../var/support"
], function( support ) { ], function( document, support ) {
support.focusin = "onfocusin" in window; ( function() {
var i, eventName,
div = document.createElement( "div" );
// Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
for ( i in { submit: true, change: true, focusin: true } ) {
eventName = "on" + i;
if ( !( support[ i ] = eventName in window ) ) {
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
div.setAttribute( eventName, "t" );
support[ i ] = div.attributes[ eventName ].expando === false;
}
}
// Null elements to avoid leaks in IE.
div = null;
} )();
return support; return support;
......
...@@ -18,8 +18,8 @@ jQuery.noConflict = function( deep ) { ...@@ -18,8 +18,8 @@ jQuery.noConflict = function( deep ) {
return jQuery; return jQuery;
}; };
// Expose jQuery and $ identifiers, even in AMD // Expose jQuery and $ identifiers, even in
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (#13566)
if ( !noGlobal ) { if ( !noGlobal ) {
window.jQuery = window.$ = jQuery; window.jQuery = window.$ = jQuery;
......
/*! /*!
* jQuery JavaScript Library v@VERSION * jQuery JavaScript Library v@VERSION
* https://jquery.com/ * http://jquery.com/
* *
* Includes Sizzle.js * Includes Sizzle.js
* https://sizzlejs.com/ * http://sizzlejs.com/
* *
* Copyright jQuery Foundation and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* https://jquery.org/license * http://jquery.org/license
* *
* Date: @DATE * Date: @DATE
*/ */
......
...@@ -4,15 +4,14 @@ define( [ ...@@ -4,15 +4,14 @@ define( [
"./traversing", "./traversing",
"./callbacks", "./callbacks",
"./deferred", "./deferred",
"./deferred/exceptionHook",
"./core/ready", "./core/ready",
"./support",
"./data", "./data",
"./queue", "./queue",
"./queue/delay", "./queue/delay",
"./attributes", "./attributes",
"./event", "./event",
"./event/alias", "./event/alias",
"./event/focusin",
"./manipulation", "./manipulation",
"./manipulation/_evalUrl", "./manipulation/_evalUrl",
"./wrap", "./wrap",
......
define( [ define( [
"./core", "./core",
"./var/document",
"./var/concat", "./var/concat",
"./var/push", "./var/push",
"./var/deletedIds",
"./core/access", "./core/access",
"./manipulation/var/rcheckableType", "./manipulation/var/rcheckableType",
"./manipulation/var/rtagName", "./manipulation/var/rtagName",
"./manipulation/var/rscriptType", "./manipulation/var/rscriptType",
"./manipulation/var/rleadingWhitespace",
"./manipulation/var/nodeNames",
"./manipulation/createSafeFragment",
"./manipulation/wrapMap", "./manipulation/wrapMap",
"./manipulation/getAll", "./manipulation/getAll",
"./manipulation/setGlobalEval", "./manipulation/setGlobalEval",
"./manipulation/buildFragment", "./manipulation/buildFragment",
"./manipulation/support", "./manipulation/support",
"./data/var/dataPriv",
"./data/var/dataUser",
"./data/var/acceptData", "./data/var/acceptData",
"./core/DOMEval",
"./core/init", "./core/init",
"./traversing", "./traversing",
"./selector", "./selector",
"./event" "./event"
], function( jQuery, concat, push, access, ], function( jQuery, document, concat, push, deletedIds, access,
rcheckableType, rtagName, rscriptType, rcheckableType, rtagName, rscriptType, rleadingWhitespace, nodeNames,
wrapMap, getAll, setGlobalEval, buildFragment, support, createSafeFragment, wrapMap, getAll, setGlobalEval,
dataPriv, dataUser, acceptData, DOMEval ) { buildFragment, support, acceptData ) {
var var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/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.
...@@ -37,78 +40,126 @@ var ...@@ -37,78 +40,126 @@ var
// checked="checked" or checked // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptTypeMasked = /^true\/(.*)/, rscriptTypeMasked = /^true\/(.*)/,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
safeFragment = createSafeFragment( document ),
fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
// Support: IE<8
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) { function manipulationTarget( elem, content ) {
if ( jQuery.nodeName( elem, "table" ) && return jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
}
return elem; elem.getElementsByTagName( "tbody" )[ 0 ] ||
elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
elem;
} }
// Replace/restore the type attribute of script elements for safe DOM manipulation // Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) { function disableScript( elem ) {
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
return elem; return elem;
} }
function restoreScript( elem ) { function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type ); var match = rscriptTypeMasked.exec( elem.type );
if ( match ) { if ( match ) {
elem.type = match[ 1 ]; elem.type = match[ 1 ];
} else { } else {
elem.removeAttribute( "type" ); elem.removeAttribute( "type" );
} }
return elem; return elem;
} }
function cloneCopyEvent( src, dest ) { function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
if ( dest.nodeType !== 1 ) {
return; return;
} }
// 1. Copy private data: events, handlers, etc. var type, i, l,
if ( dataPriv.hasData( src ) ) { oldData = jQuery._data( src ),
pdataOld = dataPriv.access( src ); curData = jQuery._data( dest, oldData ),
pdataCur = dataPriv.set( dest, pdataOld ); events = oldData.events;
events = pdataOld.events;
if ( events ) { if ( events ) {
delete pdataCur.handle; delete curData.handle;
pdataCur.events = {}; curData.events = {};
for ( type in events ) { for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] ); jQuery.event.add( dest, type, events[ type ][ i ] );
}
} }
} }
} }
// 2. Copy user data // make the cloned public data object a copy from the original
if ( dataUser.hasData( src ) ) { if ( curData.data ) {
udataOld = dataUser.access( src ); curData.data = jQuery.extend( {}, curData.data );
udataCur = jQuery.extend( {}, udataOld );
dataUser.set( dest, udataCur );
} }
} }
// Fix IE bugs, see support tests function fixCloneNodeIssues( src, dest ) {
function fixInput( src, dest ) { var nodeName, e, data;
var nodeName = dest.nodeName.toLowerCase();
// We do not need to do anything for non-Elements
if ( dest.nodeType !== 1 ) {
return;
}
nodeName = dest.nodeName.toLowerCase();
// IE6-8 copies events bound via attachEvent when using cloneNode.
if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
data = jQuery._data( dest );
for ( e in data.events ) {
jQuery.removeEvent( dest, e, data.handle );
}
// Event data gets referenced instead of copied if the expando gets copied too
dest.removeAttribute( jQuery.expando );
}
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
if ( nodeName === "script" && dest.text !== src.text ) {
disableScript( dest ).text = src.text;
restoreScript( dest );
// IE6-10 improperly clones children of object elements using classid.
// IE10 throws NoModificationAllowedError if parent is null, #12132.
} else if ( nodeName === "object" ) {
if ( dest.parentNode ) {
dest.outerHTML = src.outerHTML;
}
// This path appears unavoidable for IE9. When cloning an object
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
dest.innerHTML = src.innerHTML;
}
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
// IE6-8 fails to persist the checked state of a cloned checkbox
// or radio button. Worse, IE6-7 fail to give the cloned element
// a checked appearance if the defaultChecked value isn't also set
dest.defaultChecked = dest.checked = src.checked;
// IE6-7 get confused and end up setting the value of a cloned
// checkbox/radio button to an empty string instead of "on"
if ( dest.value !== src.value ) {
dest.value = src.value;
}
// Fails to persist the checked state of a cloned checkbox or radio button. // IE6-8 fails to return the selected option to the default selected
if ( nodeName === "input" && rcheckableType.test( src.type ) ) { // state when cloning options
dest.checked = src.checked; } else if ( nodeName === "option" ) {
dest.defaultSelected = dest.selected = src.defaultSelected;
// Fails to return the selected option to the default selected state when cloning options // IE6-8 fails to set the defaultValue to the correct value when
// cloning other types of input fields
} else if ( nodeName === "input" || nodeName === "textarea" ) { } else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue; dest.defaultValue = src.defaultValue;
} }
...@@ -119,7 +170,8 @@ function domManip( collection, args, callback, ignored ) { ...@@ -119,7 +170,8 @@ function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays // Flatten any nested arrays
args = concat.apply( [], args ); args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc, var first, node, hasScripts,
scripts, doc, fragment,
i = 0, i = 0,
l = collection.length, l = collection.length,
iNoClone = l - 1, iNoClone = l - 1,
...@@ -183,7 +235,7 @@ function domManip( collection, args, callback, ignored ) { ...@@ -183,7 +235,7 @@ function domManip( collection, args, callback, ignored ) {
for ( i = 0; i < hasScripts; i++ ) { for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ]; node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) && if ( rscriptType.test( node.type || "" ) &&
!dataPriv.access( node, "globalEval" ) && !jQuery._data( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) { jQuery.contains( doc, node ) ) {
if ( node.src ) { if ( node.src ) {
...@@ -193,11 +245,17 @@ function domManip( collection, args, callback, ignored ) { ...@@ -193,11 +245,17 @@ function domManip( collection, args, callback, ignored ) {
jQuery._evalUrl( node.src ); jQuery._evalUrl( node.src );
} }
} else { } else {
DOMEval( node.textContent.replace( rcleanScript, "" ), doc ); jQuery.globalEval(
( node.text || node.textContent || node.innerHTML || "" )
.replace( rcleanScript, "" )
);
} }
} }
} }
} }
// Fix #11809: Avoid leaking memory
fragment = first = null;
} }
} }
...@@ -206,10 +264,11 @@ function domManip( collection, args, callback, ignored ) { ...@@ -206,10 +264,11 @@ function domManip( collection, args, callback, ignored ) {
function remove( elem, selector, keepData ) { function remove( elem, selector, keepData ) {
var node, var node,
nodes = selector ? jQuery.filter( selector, elem ) : elem, elems = selector ? jQuery.filter( selector, elem ) : elem,
i = 0; i = 0;
for ( ; ( node = nodes[ i ] ) != null; i++ ) { for ( ; ( node = elems[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) { if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) ); jQuery.cleanData( getAll( node ) );
} }
...@@ -231,20 +290,34 @@ jQuery.extend( { ...@@ -231,20 +290,34 @@ jQuery.extend( {
}, },
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var i, l, srcElements, destElements, var destElements, node, clone, i, srcElements,
clone = elem.cloneNode( true ),
inPage = jQuery.contains( elem.ownerDocument, elem ); inPage = jQuery.contains( elem.ownerDocument, elem );
// Fix IE cloning issues if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
!jQuery.isXMLDoc( elem ) ) {
clone = elem.cloneNode( true );
// IE<=8 does not properly clone detached, unknown element nodes
} else {
fragmentDiv.innerHTML = elem.outerHTML;
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
}
if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone ); destElements = getAll( clone );
srcElements = getAll( elem ); srcElements = getAll( elem );
for ( i = 0, l = srcElements.length; i < l; i++ ) { // Fix all IE cloning issues
fixInput( srcElements[ i ], destElements[ i ] ); for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
// Ensure that the destination node is not null; Fixes #9587
if ( destElements[ i ] ) {
fixCloneNodeIssues( node, destElements[ i ] );
}
} }
} }
...@@ -254,8 +327,8 @@ jQuery.extend( { ...@@ -254,8 +327,8 @@ jQuery.extend( {
srcElements = srcElements || getAll( elem ); srcElements = srcElements || getAll( elem );
destElements = destElements || getAll( clone ); destElements = destElements || getAll( clone );
for ( i = 0, l = srcElements.length; i < l; i++ ) { for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
cloneCopyEvent( srcElements[ i ], destElements[ i ] ); cloneCopyEvent( node, destElements[ i ] );
} }
} else { } else {
cloneCopyEvent( elem, clone ); cloneCopyEvent( elem, clone );
...@@ -268,18 +341,27 @@ jQuery.extend( { ...@@ -268,18 +341,27 @@ jQuery.extend( {
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
} }
destElements = srcElements = node = null;
// Return the cloned set // Return the cloned set
return clone; return clone;
}, },
cleanData: function( elems ) { cleanData: function( elems, /* internal */ forceAcceptData ) {
var data, elem, type, var elem, type, id, data,
special = jQuery.event.special, i = 0,
i = 0; internalKey = jQuery.expando,
cache = jQuery.cache,
attributes = support.attributes,
special = jQuery.event.special;
for ( ; ( elem = elems[ i ] ) != null; i++ ) {
if ( forceAcceptData || acceptData( elem ) ) {
id = elem[ internalKey ];
data = id && cache[ id ];
for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { if ( data ) {
if ( acceptData( elem ) ) {
if ( ( data = elem[ dataPriv.expando ] ) ) {
if ( data.events ) { if ( data.events ) {
for ( type in data.events ) { for ( type in data.events ) {
if ( special[ type ] ) { if ( special[ type ] ) {
...@@ -292,15 +374,27 @@ jQuery.extend( { ...@@ -292,15 +374,27 @@ jQuery.extend( {
} }
} }
// Support: Chrome <= 35-45+ // Remove cache only if it was not already removed by jQuery.event.remove
// Assign undefined instead of using delete, see Data#remove if ( cache[ id ] ) {
elem[ dataPriv.expando ] = undefined;
} delete cache[ id ];
if ( elem[ dataUser.expando ] ) {
// Support: IE<9
// IE does not allow us to delete expando properties from nodes
// IE creates expando attributes along with the property
// IE does not have a removeAttribute function on Document nodes
if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
elem.removeAttribute( internalKey );
// Support: Chrome <= 35-45+ // Webkit & Blink performance suffers when deleting properties
// Assign undefined instead of using delete, see Data#remove // from DOM nodes, so set to undefined instead
elem[ dataUser.expando ] = undefined; // https://code.google.com/p/chromium/issues/detail?id=378607
} else {
elem[ internalKey ] = undefined;
}
deletedIds.push( id );
}
} }
} }
} }
...@@ -308,6 +402,10 @@ jQuery.extend( { ...@@ -308,6 +402,10 @@ 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 );
}, },
...@@ -320,11 +418,9 @@ jQuery.fn.extend( { ...@@ -320,11 +418,9 @@ jQuery.fn.extend( {
return access( this, function( value ) { return access( this, function( value ) {
return value === undefined ? return value === undefined ?
jQuery.text( this ) : jQuery.text( this ) :
this.empty().each( function() { this.empty().append(
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
this.textContent = value; );
}
} );
}, null, value, arguments.length ); }, null, value, arguments.length );
}, },
...@@ -367,13 +463,21 @@ jQuery.fn.extend( { ...@@ -367,13 +463,21 @@ jQuery.fn.extend( {
i = 0; i = 0;
for ( ; ( elem = this[ i ] ) != null; i++ ) { for ( ; ( elem = this[ i ] ) != null; i++ ) {
if ( elem.nodeType === 1 ) {
// Prevent memory leaks // Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) ); jQuery.cleanData( getAll( elem, false ) );
}
// Remove any remaining nodes
while ( elem.firstChild ) {
elem.removeChild( elem.firstChild );
}
// Remove any remaining nodes // If this is a select, ensure that it displays empty (#12336)
elem.textContent = ""; // Support: IE<9
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
elem.options.length = 0;
} }
} }
...@@ -395,21 +499,25 @@ jQuery.fn.extend( { ...@@ -395,21 +499,25 @@ jQuery.fn.extend( {
i = 0, i = 0,
l = this.length; l = this.length;
if ( value === undefined && elem.nodeType === 1 ) { if ( value === undefined ) {
return elem.innerHTML; return elem.nodeType === 1 ?
elem.innerHTML.replace( rinlinejQuery, "" ) :
undefined;
} }
// See if we can take a shortcut and just use innerHTML // See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
value = jQuery.htmlPrefilter( value ); value = jQuery.htmlPrefilter( value );
try { try {
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
elem = this[ i ] || {};
// Remove element nodes and prevent memory leaks // Remove element nodes and prevent memory leaks
elem = this[ i ] || {};
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) ); jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value; elem.innerHTML = value;
...@@ -456,17 +564,16 @@ jQuery.each( { ...@@ -456,17 +564,16 @@ jQuery.each( {
}, function( name, original ) { }, function( name, original ) {
jQuery.fn[ name ] = function( selector ) { jQuery.fn[ name ] = function( selector ) {
var elems, var elems,
i = 0,
ret = [], ret = [],
insert = jQuery( selector ), insert = jQuery( selector ),
last = insert.length - 1, last = insert.length - 1;
i = 0;
for ( ; i <= last; i++ ) { for ( ; i <= last; i++ ) {
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: Android<4.1, PhantomJS<2 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
// .get() because push.apply(_, arraylike) throws on ancient WebKit
push.apply( ret, elems.get() ); push.apply( ret, elems.get() );
} }
......
define( [ define( [
"../core", "../core",
"./var/rcheckableType",
"./var/rtagName", "./var/rtagName",
"./var/rscriptType", "./var/rscriptType",
"./var/rleadingWhitespace",
"./createSafeFragment",
"./wrapMap", "./wrapMap",
"./getAll", "./getAll",
"./setGlobalEval" "./setGlobalEval",
], function( jQuery, rtagName, rscriptType, wrapMap, getAll, setGlobalEval ) { "./support"
], function( jQuery, rcheckableType, rtagName, rscriptType, rleadingWhitespace,
createSafeFragment, wrapMap, getAll, setGlobalEval, support ) {
var rhtml = /<|&#?\w+;/; var rhtml = /<|&#?\w+;/,
rtbody = /<tbody/i;
function fixDefaultChecked( elem ) {
if ( rcheckableType.test( elem.type ) ) {
elem.defaultChecked = elem.checked;
}
}
function buildFragment( elems, context, scripts, selection, ignored ) { function buildFragment( elems, context, scripts, selection, ignored ) {
var elem, tmp, tag, wrap, contains, j, var j, elem, contains,
fragment = context.createDocumentFragment(), tmp, tag, tbody, wrap,
l = elems.length,
// Ensure a safe fragment
safe = createSafeFragment( context ),
nodes = [], nodes = [],
i = 0, i = 0;
l = elems.length;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
elem = elems[ i ]; elem = elems[ i ];
...@@ -23,9 +39,6 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -23,9 +39,6 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
// Add nodes directly // Add nodes directly
if ( jQuery.type( elem ) === "object" ) { if ( jQuery.type( elem ) === "object" ) {
// Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node // Convert non-html into a text node
...@@ -34,11 +47,12 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -34,11 +47,12 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
// Convert html into DOM nodes // Convert html into DOM nodes
} else { } else {
tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); tmp = tmp || safe.appendChild( context.createElement( "div" ) );
// Deserialize a standard representation // Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default; wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
// Descend through wrappers to the right content // Descend through wrappers to the right content
...@@ -47,21 +61,59 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -47,21 +61,59 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
tmp = tmp.lastChild; tmp = tmp.lastChild;
} }
// Support: Android<4.1, PhantomJS<2 // Manually add leading whitespace removed by IE
// push.apply(_, arraylike) throws on ancient WebKit if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
jQuery.merge( nodes, tmp.childNodes ); nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
}
// Remove IE's autoinserted <tbody> from table fragments
if ( !support.tbody ) {
// String was a <table>, *may* have spurious <tbody>
elem = tag === "table" && !rtbody.test( elem ) ?
tmp.firstChild :
// String was a bare <thead> or <tfoot>
wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
tmp :
0;
// Remember the top-level container j = elem && elem.childNodes.length;
tmp = fragment.firstChild; while ( j-- ) {
if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
!tbody.childNodes.length ) {
// Ensure the created nodes are orphaned (#12392) elem.removeChild( tbody );
}
}
}
jQuery.merge( nodes, tmp.childNodes );
// Fix #12392 for WebKit and IE > 9
tmp.textContent = ""; tmp.textContent = "";
// Fix #12392 for oldIE
while ( tmp.firstChild ) {
tmp.removeChild( tmp.firstChild );
}
// Remember the top-level container for proper cleanup
tmp = safe.lastChild;
} }
} }
} }
// Remove wrapper from fragment // Fix #11356: Clear elements from fragment
fragment.textContent = ""; if ( tmp ) {
safe.removeChild( tmp );
}
// Reset defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
if ( !support.appendChecked ) {
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
}
i = 0; i = 0;
while ( ( elem = nodes[ i++ ] ) ) { while ( ( elem = nodes[ i++ ] ) ) {
...@@ -71,13 +123,14 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -71,13 +123,14 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
if ( ignored ) { if ( ignored ) {
ignored.push( elem ); ignored.push( elem );
} }
continue; continue;
} }
contains = jQuery.contains( elem.ownerDocument, elem ); contains = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment // Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" ); tmp = getAll( safe.appendChild( elem ), "script" );
// Preserve script evaluation history // Preserve script evaluation history
if ( contains ) { if ( contains ) {
...@@ -95,7 +148,9 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -95,7 +148,9 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
} }
} }
return fragment; tmp = null;
return safe;
} }
return buildFragment; return buildFragment;
......
...@@ -3,18 +3,30 @@ define( [ ...@@ -3,18 +3,30 @@ define( [
], function( jQuery ) { ], function( jQuery ) {
function getAll( context, tag ) { function getAll( context, tag ) {
var elems, elem,
// Support: IE9-11+ i = 0,
// Use typeof to avoid zero-argument method invocation on host objects (#15151) found = typeof context.getElementsByTagName !== "undefined" ?
var ret = typeof context.getElementsByTagName !== "undefined" ?
context.getElementsByTagName( tag || "*" ) : context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ? typeof context.querySelectorAll !== "undefined" ?
context.querySelectorAll( tag || "*" ) : context.querySelectorAll( tag || "*" ) :
[]; undefined;
if ( !found ) {
for ( found = [], elems = context.childNodes || context;
( elem = elems[ i ] ) != null;
i++
) {
if ( !tag || jQuery.nodeName( elem, tag ) ) {
found.push( elem );
} else {
jQuery.merge( found, getAll( elem, tag ) );
}
}
}
return tag === undefined || tag && jQuery.nodeName( context, tag ) ? return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) : jQuery.merge( [ context ], found ) :
ret; found;
} }
return getAll; return getAll;
......
define( [ define( [
"../data/var/dataPriv" "../core"
], function( dataPriv ) { ], function( jQuery ) {
// Mark scripts as having already been evaluated // Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) { function setGlobalEval( elems, refElements ) {
var i = 0, var elem,
l = elems.length; i = 0;
for ( ; ( elem = elems[ i ] ) != null; i++ ) {
for ( ; i < l; i++ ) { jQuery._data(
dataPriv.set( elem,
elems[ i ],
"globalEval", "globalEval",
!refElements || dataPriv.get( refElements[ i ], "globalEval" ) !refElements || jQuery._data( refElements[ i ], "globalEval" )
); );
} }
} }
......
define( [ define( [
"../core",
"../var/document", "../var/document",
"../var/support" "../var/support"
], function( document, support ) { ], function( jQuery, document, support ) {
( function() { ( function() {
var fragment = document.createDocumentFragment(), var div = document.createElement( "div" ),
div = fragment.appendChild( document.createElement( "div" ) ), fragment = document.createDocumentFragment(),
input = document.createElement( "input" ); input = document.createElement( "input" );
// Support: Android 4.0-4.3 // Setup
// Check state lost if the name is set (#11217) div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
// IE strips leading whitespace when .innerHTML is used
support.leadingWhitespace = div.firstChild.nodeType === 3;
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
support.tbody = !div.getElementsByTagName( "tbody" ).length;
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
support.html5Clone =
document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
input.type = "checkbox";
input.checked = true;
fragment.appendChild( input );
support.appendChecked = input.checked;
// Make sure textarea (and checkbox) defaultValue is properly cloned
// Support: IE6-IE11+
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
// #11217 - WebKit loses check when the name is after the checked attribute
fragment.appendChild( div );
// 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)
input = document.createElement( "input" );
input.setAttribute( "type", "radio" ); input.setAttribute( "type", "radio" );
input.setAttribute( "checked", "checked" ); input.setAttribute( "checked", "checked" );
input.setAttribute( "name", "t" ); input.setAttribute( "name", "t" );
div.appendChild( input ); div.appendChild( input );
// Support: Android<4.2 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
// Older WebKit doesn't clone checked state correctly in fragments // old 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;
// Support: IE<=11+ // Support: IE<9
// Make sure textarea (and checkbox) defaultValue is properly cloned // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
div.innerHTML = "<textarea>x</textarea>"; support.noCloneEvent = !!div.addEventListener;
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
// Support: IE<9
// Since attributes and properties are the same in IE,
// cleanData must set properties to undefined rather than use removeAttribute
div[ jQuery.expando ] = 1;
support.attributes = !div.getAttribute( jQuery.expando );
} )(); } )();
return support; return support;
......
define( function() { define( function() {
return ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); return ( /<([\w:-]+)/ );
} ); } );
define( function() { define( [
"./support"
], function( support ) {
// We have to close these tags to support XHTML (#13200) // We have to close these tags to support XHTML (#13200)
var wrapMap = { var wrapMap = {
// Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ], option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
area: [ 1, "<map>", "</map>" ],
// XHTML parsers do not magically insert elements in the // Support: IE8
// same way that tag soup parsers do. So we cannot shorten param: [ 1, "<object>", "</object>" ],
// this by omitting <tbody> or other required elements.
thead: [ 1, "<table>", "</table>" ], thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ], tr: [ 2, "<table><tbody>", "</tbody></table>" ],
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ] // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
_default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
}; };
// Support: IE9 // Support: IE8-IE9
wrapMap.optgroup = wrapMap.option; wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
......
...@@ -13,11 +13,18 @@ define( [ ...@@ -13,11 +13,18 @@ define( [
"./selector" // contains "./selector" // contains
], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) { ], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) {
// BuildExclude
curCSS = curCSS.curCSS;
/** /**
* Gets a window from an element * Gets a window from an element
*/ */
function getWindow( elem ) { function getWindow( elem ) {
return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; return jQuery.isWindow( elem ) ?
elem :
elem.nodeType === 9 ?
elem.defaultView || elem.parentWindow :
false;
} }
jQuery.offset = { jQuery.offset = {
...@@ -27,7 +34,7 @@ jQuery.offset = { ...@@ -27,7 +34,7 @@ jQuery.offset = {
curElem = jQuery( elem ), curElem = jQuery( elem ),
props = {}; props = {};
// Set position first, in-case top/left are set even on static elem // set position first, in-case top/left are set even on static elem
if ( position === "static" ) { if ( position === "static" ) {
elem.style.position = "relative"; elem.style.position = "relative";
} }
...@@ -36,15 +43,14 @@ jQuery.offset = { ...@@ -36,15 +43,14 @@ jQuery.offset = {
curCSSTop = jQuery.css( elem, "top" ); curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" ); curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) && calculatePosition = ( position === "absolute" || position === "fixed" ) &&
( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
// Need to be able to calculate position if either // need to be able to calculate position if either top or left
// top or left is auto and position is either absolute or fixed // is auto and position is either absolute or fixed
if ( calculatePosition ) { if ( calculatePosition ) {
curPosition = curElem.position(); curPosition = curElem.position();
curTop = curPosition.top; curTop = curPosition.top;
curLeft = curPosition.left; curLeft = curPosition.left;
} else { } else {
curTop = parseFloat( curCSSTop ) || 0; curTop = parseFloat( curCSSTop ) || 0;
curLeft = parseFloat( curCSSLeft ) || 0; curLeft = parseFloat( curCSSLeft ) || 0;
...@@ -65,7 +71,6 @@ jQuery.offset = { ...@@ -65,7 +71,6 @@ jQuery.offset = {
if ( "using" in options ) { if ( "using" in options ) {
options.using.call( elem, props ); options.using.call( elem, props );
} else { } else {
curElem.css( props ); curElem.css( props );
} }
...@@ -74,8 +79,6 @@ jQuery.offset = { ...@@ -74,8 +79,6 @@ 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 :
...@@ -84,36 +87,32 @@ jQuery.fn.extend( { ...@@ -84,36 +87,32 @@ jQuery.fn.extend( {
} ); } );
} }
var docElem, win, rect, doc, var docElem, win,
elem = this[ 0 ]; box = { top: 0, left: 0 },
elem = this[ 0 ],
doc = elem && elem.ownerDocument;
if ( !elem ) { if ( !doc ) {
return; return;
} }
// Support: IE<=11+ docElem = doc.documentElement;
// 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 element is not hidden (display: none) // Make sure it's not a disconnected DOM node
if ( rect.width || rect.height ) { if ( !jQuery.contains( docElem, elem ) ) {
doc = elem.ownerDocument; return box;
win = getWindow( doc );
docElem = doc.documentElement;
return {
top: rect.top + win.pageYOffset - docElem.clientTop,
left: rect.left + win.pageXOffset - docElem.clientLeft
};
} }
// Return zeros for disconnected and hidden elements (gh-2310) // If we don't have gBCR, just use 0,0 rather than error
return rect; // BlackBerry 5, iOS 3 (original iPhone)
if ( typeof elem.getBoundingClientRect !== "undefined" ) {
box = elem.getBoundingClientRect();
}
win = getWindow( doc );
return {
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
};
}, },
position: function() { position: function() {
...@@ -122,16 +121,15 @@ jQuery.fn.extend( { ...@@ -122,16 +121,15 @@ jQuery.fn.extend( {
} }
var offsetParent, offset, var offsetParent, offset,
elem = this[ 0 ], parentOffset = { top: 0, left: 0 },
parentOffset = { top: 0, left: 0 }; elem = this[ 0 ];
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
// because it is its only offset parent // because it is its only offset parent
if ( jQuery.css( elem, "position" ) === "fixed" ) { if ( jQuery.css( elem, "position" ) === "fixed" ) {
// Assume getBoundingClientRect is there when computed position is fixed // we assume that getBoundingClientRect is available when computed position is fixed
offset = elem.getBoundingClientRect(); offset = elem.getBoundingClientRect();
} else { } else {
// Get *real* offsetParent // Get *real* offsetParent
...@@ -144,38 +142,27 @@ jQuery.fn.extend( { ...@@ -144,38 +142,27 @@ jQuery.fn.extend( {
} }
// Add offsetParent borders // Add offsetParent borders
// Subtract offsetParent scroll positions parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) - parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
offsetParent.scrollTop();
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) -
offsetParent.scrollLeft();
} }
// Subtract parent offsets and element margins // Subtract parent offsets and element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
return { return {
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
}; };
}, },
// This method will return documentElement in the following cases:
// 1) For the element inside the iframe without offsetParent, this method will return
// documentElement of the parent window
// 2) For the hidden or detached element
// 3) For body or html element, i.e. in case of the html node - it will return itself
//
// but those exceptions were never presented as a real life use-cases
// and might be considered as more preferable results.
//
// This logic, however, is not guaranteed and can change at any point in the future
offsetParent: function() { offsetParent: function() {
return this.map( function() { return this.map( function() {
var offsetParent = this.offsetParent; var offsetParent = this.offsetParent;
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
jQuery.css( offsetParent, "position" ) === "static" ) ) {
offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
} }
return offsetParent || documentElement; return offsetParent || documentElement;
} ); } );
} }
...@@ -183,42 +170,43 @@ jQuery.fn.extend( { ...@@ -183,42 +170,43 @@ jQuery.fn.extend( {
// Create scrollLeft and scrollTop methods // Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
var top = "pageYOffset" === prop; var top = /Y/.test( prop );
jQuery.fn[ method ] = function( val ) { jQuery.fn[ method ] = function( val ) {
return access( this, function( elem, method, val ) { return access( this, function( elem, method, val ) {
var win = getWindow( elem ); var win = getWindow( elem );
if ( val === undefined ) { if ( val === undefined ) {
return win ? win[ prop ] : elem[ method ]; return win ? ( prop in win ) ? win[ prop ] :
win.document.documentElement[ method ] :
elem[ method ];
} }
if ( win ) { if ( win ) {
win.scrollTo( win.scrollTo(
!top ? val : win.pageXOffset, !top ? val : jQuery( win ).scrollLeft(),
top ? val : win.pageYOffset top ? val : jQuery( win ).scrollTop()
); );
} else { } else {
elem[ method ] = val; elem[ method ] = val;
} }
}, method, val, arguments.length ); }, method, val, arguments.length, null );
}; };
} ); } );
// Support: Safari<7-8+, Chrome<37-44+ // Support: Safari<7-8+, Chrome<37-44+
// Add the top/left cssHooks using jQuery.fn.position // Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 // getComputedStyle returns percent when specified for top/left/bottom/right
// getComputedStyle returns percent when specified for top/left/bottom/right; // rather than make the css module depend on the offset module, we just check for it here
// rather than make the css module depend on the offset module, just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
computed = curCSS( elem, prop ); computed = curCSS( elem, prop );
// If curCSS returns percentage, fallback to offset // if curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ? return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" : jQuery( elem ).position()[ prop ] + "px" :
computed; computed;
......
define( [ define( [
"./core", "./core",
"./data/var/dataPriv",
"./deferred", "./deferred",
"./callbacks" "./callbacks"
], function( jQuery, dataPriv ) { ], function( jQuery ) {
jQuery.extend( { jQuery.extend( {
queue: function( elem, type, data ) { queue: function( elem, type, data ) {
...@@ -11,12 +10,12 @@ jQuery.extend( { ...@@ -11,12 +10,12 @@ jQuery.extend( {
if ( elem ) { if ( elem ) {
type = ( type || "fx" ) + "queue"; type = ( type || "fx" ) + "queue";
queue = dataPriv.get( elem, type ); queue = jQuery._data( elem, type );
// Speed up dequeue by getting out quickly if this is just a lookup // Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) { if ( data ) {
if ( !queue || jQuery.isArray( data ) ) { if ( !queue || jQuery.isArray( data ) ) {
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
} else { } else {
queue.push( data ); queue.push( data );
} }
...@@ -50,7 +49,7 @@ jQuery.extend( { ...@@ -50,7 +49,7 @@ jQuery.extend( {
queue.unshift( "inprogress" ); queue.unshift( "inprogress" );
} }
// Clear up the last queue stop function // clear up the last queue stop function
delete hooks.stop; delete hooks.stop;
fn.call( elem, next, hooks ); fn.call( elem, next, hooks );
} }
...@@ -60,12 +59,14 @@ jQuery.extend( { ...@@ -60,12 +59,14 @@ jQuery.extend( {
} }
}, },
// Not public - generate a queueHooks object, or return the current one // not intended for public consumption - generates a queueHooks object,
// or returns the current one
_queueHooks: function( elem, type ) { _queueHooks: function( elem, type ) {
var key = type + "queueHooks"; var key = type + "queueHooks";
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { return jQuery._data( elem, key ) || jQuery._data( elem, key, {
empty: jQuery.Callbacks( "once memory" ).add( function() { empty: jQuery.Callbacks( "once memory" ).add( function() {
dataPriv.remove( elem, [ type + "queue", key ] ); jQuery._removeData( elem, type + "queue" );
jQuery._removeData( elem, key );
} ) } )
} ); } );
} }
...@@ -90,7 +91,7 @@ jQuery.fn.extend( { ...@@ -90,7 +91,7 @@ jQuery.fn.extend( {
this.each( function() { this.each( function() {
var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
// Ensure a hooks for this queue // ensure a hooks for this queue
jQuery._queueHooks( this, type ); jQuery._queueHooks( this, type );
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
...@@ -128,7 +129,7 @@ jQuery.fn.extend( { ...@@ -128,7 +129,7 @@ jQuery.fn.extend( {
type = type || "fx"; type = type || "fx";
while ( i-- ) { while ( i-- ) {
tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); tmp = jQuery._data( elements[ i ], type + "queueHooks" );
if ( tmp && tmp.empty ) { if ( tmp && tmp.empty ) {
count++; count++;
tmp.empty.add( resolve ); tmp.empty.add( resolve );
......
...@@ -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.
// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ // http://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";
......
define( [ define( [
"./core", "./core",
"sizzle" "../external/sizzle/dist/sizzle"
], function( jQuery, Sizzle ) { ], function( jQuery, Sizzle ) {
jQuery.find = Sizzle; jQuery.find = Sizzle;
......
...@@ -6,7 +6,7 @@ define( [ ...@@ -6,7 +6,7 @@ define( [
"./attributes/prop" "./attributes/prop"
], function( jQuery, rcheckableType ) { ], function( jQuery, rcheckableType ) {
var var r20 = /%20/g,
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( "&" ); return s.join( "&" ).replace( r20, "+" );
}; };
jQuery.fn.extend( { jQuery.fn.extend( {
...@@ -102,7 +102,7 @@ jQuery.fn.extend( { ...@@ -102,7 +102,7 @@ jQuery.fn.extend( {
.filter( function() { .filter( function() {
var type = this.type; var type = this.type;
// Use .is( ":disabled" ) so that fieldset[disabled] works // Use .is(":disabled") so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) && return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) ); ( this.checked || !rcheckableType.test( type ) );
......
define( [ define( [
"./core", "./core",
"./var/indexOf",
"./traversing/var/dir", "./traversing/var/dir",
"./traversing/var/siblings", "./traversing/var/siblings",
"./traversing/var/rneedsContext", "./traversing/var/rneedsContext",
"./core/init", "./core/init",
"./traversing/findFilter", "./traversing/findFilter",
"./selector" "./selector"
], function( jQuery, indexOf, dir, siblings, rneedsContext ) { ], function( jQuery, dir, siblings, rneedsContext ) {
var rparentsprev = /^(?:parents|prev(?:Until|All))/, var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// Methods guaranteed to produce a unique set when starting from a unique set // methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = { guaranteedUnique = {
children: true, children: true,
contents: true, contents: true,
...@@ -21,12 +20,12 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/, ...@@ -21,12 +20,12 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
jQuery.fn.extend( { jQuery.fn.extend( {
has: function( target ) { has: function( target ) {
var targets = jQuery( target, this ), var i,
l = targets.length; targets = jQuery( target, this ),
len = targets.length;
return this.filter( function() { return this.filter( function() {
var i = 0; for ( i = 0; i < len; i++ ) {
for ( ; i < l; i++ ) {
if ( jQuery.contains( this, targets[ i ] ) ) { if ( jQuery.contains( this, targets[ i ] ) ) {
return true; return true;
} }
...@@ -39,24 +38,23 @@ jQuery.fn.extend( { ...@@ -39,24 +38,23 @@ jQuery.fn.extend( {
i = 0, i = 0,
l = this.length, l = this.length,
matched = [], matched = [],
targets = typeof selectors !== "string" && jQuery( selectors ); pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
jQuery( selectors, context || this.context ) :
0;
// Positional selectors never match, since there's no _selection_ context for ( ; i < l; i++ ) {
if ( !rneedsContext.test( selectors ) ) { for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
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 && ( targets ? if ( cur.nodeType < 11 && ( pos ?
targets.index( cur ) > -1 : pos.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;
}
} }
} }
} }
...@@ -64,7 +62,8 @@ jQuery.fn.extend( { ...@@ -64,7 +62,8 @@ jQuery.fn.extend( {
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
}, },
// Determine the position of an element within the set // Determine the position of an element within
// the matched set of elements
index: function( elem ) { index: function( elem ) {
// No argument, return index in parent // No argument, return index in parent
...@@ -72,17 +71,16 @@ jQuery.fn.extend( { ...@@ -72,17 +71,16 @@ jQuery.fn.extend( {
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
} }
// Index in selector // index in selector
if ( typeof elem === "string" ) { if ( typeof elem === "string" ) {
return indexOf.call( jQuery( elem ), this[ 0 ] ); return jQuery.inArray( this[ 0 ], jQuery( elem ) );
} }
// Locate the position of the desired element // Locate the position of the desired element
return indexOf.call( this, return jQuery.inArray(
// If it receives a jQuery object, the first element is used // If it receives a jQuery object, the first element is used
elem.jquery ? elem[ 0 ] : elem elem.jquery ? elem[ 0 ] : elem, this );
);
}, },
add: function( selector, context ) { add: function( selector, context ) {
...@@ -101,7 +99,10 @@ jQuery.fn.extend( { ...@@ -101,7 +99,10 @@ jQuery.fn.extend( {
} ); } );
function sibling( cur, dir ) { function sibling( cur, dir ) {
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} do {
cur = cur[ dir ];
} while ( cur && cur.nodeType !== 1 );
return cur; return cur;
} }
...@@ -141,34 +142,36 @@ jQuery.each( { ...@@ -141,34 +142,36 @@ jQuery.each( {
return siblings( elem.firstChild ); return siblings( elem.firstChild );
}, },
contents: function( elem ) { contents: function( elem ) {
return elem.contentDocument || jQuery.merge( [], elem.childNodes ); return jQuery.nodeName( elem, "iframe" ) ?
elem.contentDocument || elem.contentWindow.document :
jQuery.merge( [], elem.childNodes );
} }
}, function( name, fn ) { }, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) { jQuery.fn[ name ] = function( until, selector ) {
var matched = jQuery.map( this, fn, until ); var ret = jQuery.map( this, fn, until );
if ( name.slice( -5 ) !== "Until" ) { if ( name.slice( -5 ) !== "Until" ) {
selector = until; selector = until;
} }
if ( selector && typeof selector === "string" ) { if ( selector && typeof selector === "string" ) {
matched = jQuery.filter( selector, matched ); ret = jQuery.filter( selector, ret );
} }
if ( this.length > 1 ) { if ( this.length > 1 ) {
// Remove duplicates // Remove duplicates
if ( !guaranteedUnique[ name ] ) { if ( !guaranteedUnique[ name ] ) {
jQuery.uniqueSort( matched ); ret = jQuery.uniqueSort( ret );
} }
// Reverse order for parents* and prev-derivatives // Reverse order for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) { if ( rparentsprev.test( name ) ) {
matched.reverse(); ret = ret.reverse();
} }
} }
return this.pushStack( matched ); return this.pushStack( ret );
}; };
} ); } );
......
...@@ -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 && elem.nodeType === 1; return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
} ); } );
} }
...@@ -54,9 +54,9 @@ jQuery.filter = function( expr, elems, not ) { ...@@ -54,9 +54,9 @@ jQuery.filter = function( expr, elems, not ) {
jQuery.fn.extend( { jQuery.fn.extend( {
find: function( selector ) { find: function( selector ) {
var i, var i,
len = this.length,
ret = [], ret = [],
self = this; self = this,
len = self.length;
if ( typeof selector !== "string" ) { if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter( function() { return this.pushStack( jQuery( selector ).filter( function() {
...@@ -72,7 +72,10 @@ jQuery.fn.extend( { ...@@ -72,7 +72,10 @@ jQuery.fn.extend( {
jQuery.find( selector, self[ i ], ret ); jQuery.find( selector, self[ i ], ret );
} }
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret ); // Needed because $( selector, context ) becomes $( context ).find( selector )
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 ) );
......
define( [ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.concat; return deletedIds.concat;
} ); } );
define( [ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.indexOf; return deletedIds.indexOf;
} ); } );
define( [ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.push; return deletedIds.push;
} ); } );
define( [ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.slice; return deletedIds.slice;
} ); } );
...@@ -7,15 +7,16 @@ define( [ ...@@ -7,15 +7,16 @@ define( [
jQuery.fn.extend( { jQuery.fn.extend( {
wrapAll: function( html ) { wrapAll: function( html ) {
var wrap; if ( jQuery.isFunction( html ) ) {
return this.each( function( i ) {
jQuery( this ).wrapAll( html.call( this, i ) );
} );
}
if ( this[ 0 ] ) { if ( this[ 0 ] ) {
if ( jQuery.isFunction( html ) ) {
html = html.call( this[ 0 ] );
}
// The elements to wrap the target around // The elements to wrap the target around
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
if ( this[ 0 ].parentNode ) { if ( this[ 0 ].parentNode ) {
wrap.insertBefore( this[ 0 ] ); wrap.insertBefore( this[ 0 ] );
...@@ -24,8 +25,8 @@ jQuery.fn.extend( { ...@@ -24,8 +25,8 @@ jQuery.fn.extend( {
wrap.map( function() { wrap.map( function() {
var elem = this; var elem = this;
while ( elem.firstElementChild ) { while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
elem = elem.firstElementChild; elem = elem.firstChild;
} }
return elem; return elem;
...@@ -63,11 +64,12 @@ jQuery.fn.extend( { ...@@ -63,11 +64,12 @@ jQuery.fn.extend( {
} ); } );
}, },
unwrap: function( selector ) { unwrap: function() {
this.parent( selector ).not( "body" ).each( function() { return this.parent().each( function() {
jQuery( this ).replaceWith( this.childNodes ); if ( !jQuery.nodeName( this, "body" ) ) {
} ); jQuery( this ).replaceWith( this.childNodes );
return this; }
} ).end();
} }
} ); } );
......
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