Commit efbdc6e3 authored by Timmy Willison's avatar Timmy Willison

Release 1.12.0

parent 2c92869b
...@@ -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>
...@@ -36,7 +36,7 @@ Justin Meyer <justinbmeyer@gmail.com> ...@@ -36,7 +36,7 @@ Justin Meyer <justinbmeyer@gmail.com>
Ben Alman <cowboy@rj3.net> Ben Alman <cowboy@rj3.net>
James Padolsey <cla@padolsey.net> James Padolsey <cla@padolsey.net>
David Petersen <public@petersendidit.com> David Petersen <public@petersendidit.com>
Batiste Bieler <batiste@gmail.com> Batiste Bieler <batiste.bieler@gmail.com>
Alexander Farkas <info@corrupt-system.de> Alexander Farkas <info@corrupt-system.de>
Rick Waldron <waldron.rick@gmail.com> Rick Waldron <waldron.rick@gmail.com>
Filipe Fortes <filipe@fortes.com> Filipe Fortes <filipe@fortes.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,6 +246,18 @@ Calvin Metcalf <calvin.metcalf@gmail.com> ...@@ -256,6 +246,18 @@ 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>
Bruno Pérel <brunoperel@gmail.com>
Reed Loden <reed@reedloden.com>
Daniel Nill <daniellnill@gmail.com>
Yongwoo Jeon <yongwoo.jeon@navercorp.com>
Sean Henderson <seanh.za@gmail.com>
Adrian Olek <adrianolek@gmail.com>
Richard Kraaijenhagen <stdin+git@riichard.com>
Gary Ye <garysye@gmail.com>
Christian Grete <webmaster@christiangrete.com>
Liza Ramo <liza.h.ramo@gmail.com>
Joelle Fleurantin <joasqueeniebee@gmail.com>
Julian Alexander Murillo <julian.alexander.murillo@gmail.com>
Jun Sun <klsforever@gmail.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-alpha1", "version": "1.12.0",
"main": "dist/jquery.js", "main": "dist/jquery.js",
"homepage": "http://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-alpha1/AUTHORS.txt" "url": "https://github.com/jquery/jquery/blob/1.12-stable/AUTHORS.txt"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -32,28 +32,25 @@ ...@@ -32,28 +32,25 @@
"grunt-cli": "0.1.13", "grunt-cli": "0.1.13",
"grunt-compare-size": "0.4.0", "grunt-compare-size": "0.4.0",
"grunt-contrib-jshint": "0.11.2", "grunt-contrib-jshint": "0.11.2",
"grunt-contrib-uglify": "0.7.0", "grunt-contrib-uglify": "0.9.2",
"grunt-contrib-watch": "0.6.1", "grunt-contrib-watch": "0.6.1",
"grunt-git-authors": "2.0.1", "grunt-git-authors": "2.0.1",
"grunt-jscs-checker": "0.8.1", "grunt-jscs": "2.1.0",
"grunt-jsonlint": "1.0.4", "grunt-jsonlint": "1.0.4",
"grunt-npmcopy": "0.1.0", "grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2", "gzip-js": "0.3.2",
"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",
"requirejs": "2.1.17", "requirejs": "2.1.17",
"sinon": "1.10.3", "sinon": "1.12.2",
"sizzle": "2.2.0", "sizzle": "2.2.1",
"strip-json-comments": "1.0.3",
"testswarm": "1.1.0", "testswarm": "1.1.0",
"win-spawn": "2.0.0" "win-spawn": "2.0.0"
}, },
"jsdomVersions": {
"node": "3.1.2",
"iojs": "5.3.0"
},
"scripts": { "scripts": {
"build": "npm install && grunt", "build": "npm install && grunt",
"start": "grunt watch", "start": "grunt watch",
...@@ -72,6 +69,7 @@ ...@@ -72,6 +69,7 @@
"CSS", "CSS",
"Data", "Data",
"Deferred", "Deferred",
"Deprecated",
"Dimensions", "Dimensions",
"Effects", "Effects",
"Event", "Event",
......
...@@ -10,14 +10,21 @@ ...@@ -10,14 +10,21 @@
"undef": true, "undef": true,
"unused": true, "unused": true,
"evil": true,
"sub": true, "sub": true,
// Support: IE < 10, Android < 4.1
// The above browsers are failing a lot of tests in the ES5
// test suite at http://test262.ecmascript.org.
"es3": true,
"globals": { "globals": {
"window": true, "window": true,
"JSON": false,
"jQuery": true, "jQuery": true,
"define": true, "define": false,
"module": true, "module": false,
"noGlobal": true "noGlobal": true
} }
} }
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
"./ajax/var/location", "./ajax/var/location",
"./ajax/var/nonce", "./ajax/var/nonce",
"./ajax/var/rquery", "./ajax/var/rquery",
"./core/init", "./core/init",
"./ajax/parseJSON", "./ajax/parseJSON",
"./ajax/parseXML", "./ajax/parseXML",
...@@ -14,11 +15,15 @@ define([ ...@@ -14,11 +15,15 @@ define([
var var
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)
...@@ -41,9 +46,11 @@ var ...@@ -41,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 ) {
...@@ -61,16 +68,18 @@ function addToPrefiltersOrTransports( structure ) { ...@@ -61,16 +68,18 @@ function addToPrefiltersOrTransports( structure ) {
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
if ( jQuery.isFunction( func ) ) { if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression // For each dataType in the dataTypeExpression
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 );
// Otherwise append // Otherwise append
} else { } else {
(structure[ dataType ] = structure[ dataType ] || []).push( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
} }
} }
} }
...@@ -97,7 +106,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX ...@@ -97,7 +106,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
} else if ( seekingTransport ) { } else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport ); return !( selected = dataTypeOrTransport );
} }
}); } );
return selected; return selected;
} }
...@@ -108,12 +117,12 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX ...@@ -108,12 +117,12 @@ 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 ) {
if ( src[ key ] !== undefined ) { if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
} }
} }
if ( deep ) { if ( deep ) {
...@@ -128,8 +137,7 @@ function ajaxExtend( target, src ) { ...@@ -128,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;
...@@ -137,7 +145,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { ...@@ -137,7 +145,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
while ( dataTypes[ 0 ] === "*" ) { while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift(); dataTypes.shift();
if ( ct === undefined ) { if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
} }
} }
...@@ -155,9 +163,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) { ...@@ -155,9 +163,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
if ( dataTypes[ 0 ] in responses ) { if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ]; finalDataType = dataTypes[ 0 ];
} else { } else {
// Try convertible dataTypes // Try convertible dataTypes
for ( type in responses ) { for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type; finalDataType = type;
break; break;
} }
...@@ -165,6 +174,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { ...@@ -165,6 +174,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
firstDataType = type; firstDataType = type;
} }
} }
// Or just use first one // Or just use first one
finalDataType = finalDataType || firstDataType; finalDataType = finalDataType || firstDataType;
} }
...@@ -186,6 +196,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) { ...@@ -186,6 +196,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
function ajaxConvert( s, response, jqXHR, isSuccess ) { function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev, var conv2, current, conv, tmp, prev,
converters = {}, converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion // Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice(); dataTypes = s.dataTypes.slice();
...@@ -215,7 +226,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -215,7 +226,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( current ) { if ( current ) {
// There's only work to do if current dataType is non-auto // There's only work to do if current dataType is non-auto
if ( current === "*" ) { if ( current === "*" ) {
current = prev; current = prev;
...@@ -238,6 +249,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -238,6 +249,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
conv = converters[ prev + " " + tmp[ 0 ] ] || conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ]; converters[ "* " + tmp[ 0 ] ];
if ( conv ) { if ( conv ) {
// Condense equivalence converters // Condense equivalence converters
if ( conv === true ) { if ( conv === true ) {
conv = converters[ conv2 ]; conv = converters[ conv2 ];
...@@ -257,7 +269,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -257,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 {
...@@ -277,7 +289,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) { ...@@ -277,7 +289,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
return { state: "success", data: response }; return { state: "success", data: response };
} }
jQuery.extend({ jQuery.extend( {
// Counter for holding the number of active queries // Counter for holding the number of active queries
active: 0, active: 0,
...@@ -287,9 +299,9 @@ jQuery.extend({ ...@@ -287,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,
...@@ -315,9 +327,9 @@ jQuery.extend({ ...@@ -315,9 +327,9 @@ jQuery.extend({
}, },
contents: { contents: {
xml: /xml/, xml: /\bxml\b/,
html: /html/, html: /\bhtml/,
json: /json/ json: /\bjson\b/
}, },
responseFields: { responseFields: {
...@@ -381,41 +393,60 @@ jQuery.extend({ ...@@ -381,41 +393,60 @@ 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,
// To know if global events are to be dispatched // To know if global events are to be dispatched
fireGlobals, fireGlobals,
// Loop variable
i, transport,
// Response headers
responseHeaders,
// Create the final options object // Create the final options object
s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
// Callbacks context // Callbacks context
callbackContext = s.context || s, callbackContext = s.context || s,
// Context for global events is callbackContext if it is a DOM node or jQuery collection // Context for global events is callbackContext if it is a DOM node or jQuery collection
globalEventContext = s.context && globalEventContext = s.context &&
( callbackContext.nodeType || callbackContext.jquery ) ? ( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery( callbackContext ) : jQuery( callbackContext ) :
jQuery.event, jQuery.event,
// Deferreds // Deferreds
deferred = jQuery.Deferred(), deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks("once memory"), completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks // Status-dependent callbacks
statusCode = s.statusCode || {}, statusCode = s.statusCode || {},
// Headers (they are sent all at once) // Headers (they are sent all at once)
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {}, requestHeadersNames = {},
// The jqXHR state // The jqXHR state
state = 0, state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
readyState: 0, readyState: 0,
...@@ -426,8 +457,8 @@ jQuery.extend({ ...@@ -426,8 +457,8 @@ jQuery.extend({
if ( state === 2 ) { if ( state === 2 ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( (match = rheaders.exec( responseHeadersString )) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
} }
} }
match = responseHeaders[ key.toLowerCase() ]; match = responseHeaders[ key.toLowerCase() ];
...@@ -464,10 +495,12 @@ jQuery.extend({ ...@@ -464,10 +495,12 @@ jQuery.extend({
if ( map ) { if ( map ) {
if ( state < 2 ) { if ( state < 2 ) {
for ( code in map ) { for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones // 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 { } else {
// Execute the appropriate callbacks // Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] ); jqXHR.always( map[ jqXHR.status ] );
} }
...@@ -487,14 +520,17 @@ jQuery.extend({ ...@@ -487,14 +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;
// Remove hash character (#7531: and string promotion) // Remove hash character (#7531: and string promotion)
// Add protocol if not provided (prefilters might expect it) // 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 ) + "" ).replace( rhash, "" ) 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;
...@@ -502,24 +538,14 @@ jQuery.extend({ ...@@ -502,24 +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
...@@ -541,7 +567,7 @@ jQuery.extend({ ...@@ -541,7 +567,7 @@ jQuery.extend({
// Watch for a new set of requests // Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) { if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger("ajaxStart"); jQuery.event.trigger( "ajaxStart" );
} }
// Uppercase the type // Uppercase the type
...@@ -560,6 +586,7 @@ jQuery.extend({ ...@@ -560,6 +586,7 @@ jQuery.extend({
// If data is available, append data to url // If data is available, append data to url
if ( s.data ) { if ( s.data ) {
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); cacheURL = ( 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;
} }
...@@ -594,8 +621,8 @@ jQuery.extend({ ...@@ -594,8 +621,8 @@ jQuery.extend({
// Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader( jqXHR.setRequestHeader(
"Accept", "Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[0] ] + s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ] s.accepts[ "*" ]
); );
...@@ -613,13 +640,13 @@ jQuery.extend({ ...@@ -613,13 +640,13 @@ jQuery.extend({
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 );
...@@ -642,8 +669,8 @@ jQuery.extend({ ...@@ -642,8 +669,8 @@ jQuery.extend({
// Timeout // Timeout
if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
timeoutTimer = window.setTimeout(function() { timeoutTimer = window.setTimeout( function() {
jqXHR.abort("timeout"); jqXHR.abort( "timeout" );
}, s.timeout ); }, s.timeout );
} }
...@@ -651,9 +678,11 @@ jQuery.extend({ ...@@ -651,9 +678,11 @@ jQuery.extend({
state = 1; state = 1;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Propagate exception as error if not done // Propagate exception as error if not done
if ( state < 2 ) { if ( state < 2 ) {
done( -1, e ); done( -1, e );
// Simply rethrow otherwise // Simply rethrow otherwise
} else { } else {
throw e; throw e;
...@@ -705,11 +734,11 @@ jQuery.extend({ ...@@ -705,11 +734,11 @@ jQuery.extend({
// 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.
if ( s.ifModified ) { if ( s.ifModified ) {
modified = jqXHR.getResponseHeader("Last-Modified"); modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) { if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified; jQuery.lastModified[ cacheURL ] = modified;
} }
modified = jqXHR.getResponseHeader("etag"); modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) { if ( modified ) {
jQuery.etag[ cacheURL ] = modified; jQuery.etag[ cacheURL ] = modified;
} }
...@@ -731,7 +760,9 @@ jQuery.extend({ ...@@ -731,7 +760,9 @@ jQuery.extend({
isSuccess = !error; isSuccess = !error;
} }
} 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";
...@@ -766,9 +797,10 @@ jQuery.extend({ ...@@ -766,9 +797,10 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter // Handle the global AJAX counter
if ( !( --jQuery.active ) ) { if ( !( --jQuery.active ) ) {
jQuery.event.trigger("ajaxStop"); jQuery.event.trigger( "ajaxStop" );
} }
} }
} }
...@@ -783,11 +815,12 @@ jQuery.extend({ ...@@ -783,11 +815,12 @@ jQuery.extend({
getScript: function( url, callback ) { getScript: function( url, callback ) {
return jQuery.get( url, undefined, callback, "script" ); return jQuery.get( url, undefined, callback, "script" );
} }
}); } );
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;
...@@ -795,7 +828,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) { ...@@ -795,7 +828,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
} }
// The url can be an options object (which then must have .url) // The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend({ return jQuery.ajax( jQuery.extend( {
url: url, url: url,
type: method, type: method,
dataType: type, dataType: type,
...@@ -803,7 +836,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) { ...@@ -803,7 +836,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
success: callback success: callback
}, jQuery.isPlainObject( url ) && url ) ); }, jQuery.isPlainObject( url ) && url ) );
}; };
}); } );
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"./var/nonce", "./var/nonce",
"./var/rquery", "./var/rquery",
...@@ -9,14 +9,14 @@ var oldCallbacks = [], ...@@ -9,14 +9,14 @@ var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/; rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings // Default jsonp settings
jQuery.ajaxSetup({ jQuery.ajaxSetup( {
jsonp: "callback", jsonp: "callback",
jsonpCallback: function() { jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true; this[ callback ] = true;
return callback; return callback;
} }
}); } );
// Detect, normalize options and install callbacks for jsonp requests // Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
...@@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
"url" : "url" :
typeof s.data === "string" && typeof s.data === "string" &&
( s.contentType || "" ) ( s.contentType || "" )
.indexOf("application/x-www-form-urlencoded") === 0 && .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data" rjsonp.test( s.data ) && "data"
); );
...@@ -46,7 +46,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -46,7 +46,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
} }
// Use data converter to retrieve json after script execution // Use data converter to retrieve json after script execution
s.converters["script json"] = function() { s.converters[ "script json" ] = function() {
if ( !responseContainer ) { if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" ); jQuery.error( callbackName + " was not called" );
} }
...@@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}; };
// Clean-up function (fires after converters) // Clean-up function (fires after converters)
jqXHR.always(function() { jqXHR.always( function() {
// If previous value didn't exist - remove it // If previous value didn't exist - remove it
if ( overwritten === undefined ) { if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName ); jQuery( window ).removeProp( callbackName );
...@@ -75,6 +76,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -75,6 +76,7 @@ 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;
...@@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { ...@@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
} }
responseContainer = overwritten = undefined; responseContainer = overwritten = undefined;
}); } );
// Delegate to script // Delegate to script
return "script"; return "script";
} }
}); } );
}); } );
define([ define( [
"../core", "../core",
"../core/parseHTML", "../core/parseHTML",
"../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 );
} }
...@@ -34,7 +44,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -34,7 +44,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If we have elements to modify, make the request // If we have elements to modify, make the request
if ( self.length > 0 ) { if ( self.length > 0 ) {
jQuery.ajax({ jQuery.ajax( {
url: url, url: url,
// If "type" variable is undefined, then "GET" method will be used. // If "type" variable is undefined, then "GET" method will be used.
...@@ -43,7 +53,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -43,7 +53,7 @@ jQuery.fn.load = function( url, params, callback ) {
type: type || "GET", type: type || "GET",
dataType: "html", dataType: "html",
data: params data: params
}).done(function( responseText ) { } ).done( function( responseText ) {
// Save response for use in complete callback // Save response for use in complete callback
response = arguments; response = arguments;
...@@ -52,7 +62,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -52,7 +62,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If a selector was specified, locate the right elements in a dummy div // If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors // Exclude scripts to avoid IE 'Permission Denied' errors
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result // Otherwise use the full result
responseText ); responseText );
...@@ -60,14 +70,14 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -60,14 +70,14 @@ jQuery.fn.load = function( url, params, callback ) {
// If the request succeeds, this function gets "data", "status", "jqXHR" // If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above. // but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error" // If it fails, this function gets "jqXHR", "status", "error"
}).always( callback && function( jqXHR, status ) { } ).always( callback && function( jqXHR, status ) {
self.each( function() { self.each( function() {
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] ); callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
}); } );
}); } );
} }
return this; return this;
}; };
}); } );
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// Support: Android 2.3 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
// Workaround failure to string-cast null input
jQuery.parseJSON = function( data ) { jQuery.parseJSON = function( data ) {
return JSON.parse( 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;
}); } );
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// 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;
...@@ -24,4 +28,4 @@ jQuery.parseXML = function( data ) { ...@@ -24,4 +28,4 @@ jQuery.parseXML = function( data ) {
return jQuery.parseXML; return jQuery.parseXML;
}); } );
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../ajax" "../ajax"
], function( jQuery, document ) { ], function( jQuery, document ) {
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );
// Install script dataType // Install script dataType
jQuery.ajaxSetup({ jQuery.ajaxSetup( {
accepts: { accepts: {
script: "text/javascript, application/javascript, " + script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript" "application/ecmascript, application/x-ecmascript"
}, },
contents: { contents: {
script: /(?:java|ecma)script/ script: /\b(?:java|ecma)script\b/
}, },
converters: { converters: {
"text script": function( text ) { "text script": function( text ) {
...@@ -19,49 +26,77 @@ jQuery.ajaxSetup({ ...@@ -19,49 +26,77 @@ jQuery.ajaxSetup({
return text; return text;
} }
} }
}); } );
// 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;
} }
}); } );
// Bind script tag hack transport // Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) { 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(function() { define( function() {
return window.location; return window.location;
}); } );
define([ define( [
"../../core" "../../core"
], function( jQuery ) { ], function( jQuery ) {
return jQuery.now(); return jQuery.now();
}); } );
define(function() { define( function() {
return (/\?/); return ( /\?/ );
}); } );
define([ define( [
"../core", "../core",
"../var/document",
"../var/support", "../var/support",
"../ajax" "../ajax"
], function( jQuery, support ) { ], function( jQuery, document, support ) {
jQuery.ajaxSettings.xhr = function() { // Create the request object
try { // (This is still attached to ajaxSettings for backward compatibility)
return new window.XMLHttpRequest(); jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
} catch ( e ) {}
}; // Support: IE6-IE8
function() {
var xhrSuccessStatus = {
// file protocol always yields status code 0, assume 200 // XHR cannot access local files, always use ActiveX for that case
0: 200, if ( this.isLocal ) {
// Support: IE9 return createActiveXHR();
// #1450: sometimes IE returns 1223 when it should be 204 }
1223: 204
}, // 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(); xhrSupported = jQuery.ajaxSettings.xhr();
// Support: IE<10
// Open requests must be manually aborted on unload (#5280)
// See https://support.microsoft.com/kb/2856746 for more info
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 ); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported; xhrSupported = support.ajax = !!xhrSupported;
jQuery.ajaxTransport(function( options ) { // Create transport if the browser can provide an xhr
var callback; if ( xhrSupported ) {
// Cross domain only allowed if supported through XMLHttpRequest jQuery.ajaxTransport( function( options ) {
if ( support.cors || xhrSupported && !options.crossDomain ) {
return { // Cross domain only allowed if supported through XMLHttpRequest
send: function( headers, complete ) { if ( !options.crossDomain || support.cors ) {
var i,
xhr = options.xhr(); var callback;
xhr.open( return {
options.type, send: function( headers, complete ) {
options.url, var i,
options.async, xhr = options.xhr(),
options.username, id = ++xhrId;
options.password
); // Open the socket
xhr.open(
// Apply custom fields if provided options.type,
if ( options.xhrFields ) { options.url,
for ( i in options.xhrFields ) { options.async,
xhr[ i ] = options.xhrFields[ i ]; options.username,
options.password
);
// 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 ) ) {
// Callback // Clean up
callback = function( type ) { delete xhrCallbacks[ id ];
return function() { callback = undefined;
if ( callback ) { xhr.onreadystatechange = jQuery.noop;
callback = xhr.onload = xhr.onerror = null;
// Abort manually if needed
if ( type === "abort" ) { if ( isAbort ) {
xhr.abort(); if ( xhr.readyState !== 4 ) {
} else if ( type === "error" ) { xhr.abort();
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: IE9 // Support: IE<10
// Accessing binary-data responseText throws an exception // Accessing binary-data responseText throws an exception
// (#11426) // (#11426)
typeof xhr.responseText === "string" ? { if ( typeof xhr.responseText === "string" ) {
text: xhr.responseText responses.text = xhr.responseText;
} : undefined, }
xhr.getAllResponseHeaders()
); // Firefox throws an exception when accessing
// 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 ) {
complete( status, statusText, responses, xhr.getAllResponseHeaders() );
}
}; };
};
// Listen to events // Do send the request
xhr.onload = callback(); // `xhr.send` may raise an exception, but it will be
xhr.onerror = callback("error"); // 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 ) {
// Create the abort callback // (IE6 & IE7) if it's in cache and has been
callback = callback("abort"); // retrieved directly we need to fire the callback
window.setTimeout( callback );
} else {
try { // Register the callback, but delay it in case `xhr.send` throws
// Do send the request (this may raise an exception) // Add to the list of active xhr callbacks
xhr.send( options.hasContent && options.data || null ); xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
} catch ( e ) { }
// #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
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"../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,
getSetAttribute = support.getSetAttribute,
getSetInput = support.input;
jQuery.fn.extend({ jQuery.fn.extend( {
attr: function( name, value ) { attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 ); return access( this, jQuery.attr, name, value, arguments.length > 1 );
}, },
removeAttr: function( name ) { removeAttr: function( name ) {
return this.each(function() { return this.each( function() {
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); } );
} }
}); } );
jQuery.extend({ jQuery.extend( {
attr: function( elem, name, value ) { attr: function( elem, name, value ) {
var ret, hooks, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
...@@ -41,7 +45,7 @@ jQuery.extend({ ...@@ -41,7 +45,7 @@ jQuery.extend({
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
name = name.toLowerCase(); 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 ) {
...@@ -74,6 +78,9 @@ jQuery.extend({ ...@@ -74,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 ) {
...@@ -91,50 +98,184 @@ jQuery.extend({ ...@@ -91,50 +98,184 @@ jQuery.extend({
attrNames = value && value.match( rnotwhite ); attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) { if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[i++] ) ) { while ( ( name = attrNames[ i++ ] ) ) {
propName = jQuery.propFix[ name ] || name; propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870) // Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) { if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false // Set corresponding property to false
elem[ propName ] = 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( name ); elem.removeAttribute( getSetAttribute ? name : propName );
} }
} }
} }
}); } );
// Hooks for boolean attributes // Hooks for boolean attributes
boolHook = { boolHook = {
set: function( elem, value, name ) { set: function( elem, value, name ) {
if ( value === false ) { if ( value === false ) {
// 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;
} }
}; };
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;
// Avoid an infinite loop by temporarily removing this function from the getter if ( !isXML ) {
handle = attrHandle[ name ];
attrHandle[ name ] = ret; // Avoid an infinite loop by temporarily removing this function from the getter
ret = getter( elem, name, isXML ) != null ? handle = attrHandle[ name ];
name.toLowerCase() : attrHandle[ name ] = ret;
null; ret = getter( elem, name, isXML ) != null ?
attrHandle[ name ] = handle; name.toLowerCase() :
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 );
}
}
};
}
// 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 + "" );
} }
return ret;
}; };
}); }
}); } );
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( {
addClass: function( value ) { addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
proceed = typeof value === "string" && value, i = 0;
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) { if ( typeof value === "string" && value ) {
// The disjunction here is for better compressibility (see removeClass) classes = value.match( rnotwhite ) || [];
classes = ( value || "" ).match( rnotwhite ) || [];
for ( ; i < len; i++ ) { while ( ( elem = this[ i++ ] ) ) {
elem = this[ i ];
curValue = getClass( elem ); curValue = getClass( elem );
cur = elem.nodeType === 1 && cur = elem.nodeType === 1 &&
( " " + curValue + " " ).replace( rclass, " " ); ( " " + curValue + " " ).replace( rclass, " " );
if ( cur ) { if ( cur ) {
j = 0; j = 0;
while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " "; cur += clazz + " ";
} }
...@@ -45,7 +40,7 @@ jQuery.fn.extend({ ...@@ -45,7 +40,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 );
} }
} }
} }
...@@ -56,20 +51,22 @@ jQuery.fn.extend({ ...@@ -56,20 +51,22 @@ jQuery.fn.extend({
removeClass: function( value ) { removeClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
proceed = arguments.length === 0 || typeof value === "string" && value, i = 0;
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) {
classes = ( value || "" ).match( rnotwhite ) || [];
for ( ; i < len; i++ ) { if ( !arguments.length ) {
elem = this[ i ]; return this.attr( "class", "" );
}
if ( typeof value === "string" && value ) {
classes = value.match( rnotwhite ) || [];
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem ); curValue = getClass( elem );
// This expression is here for better compressibility (see addClass) // This expression is here for better compressibility (see addClass)
...@@ -78,7 +75,8 @@ jQuery.fn.extend({ ...@@ -78,7 +75,8 @@ jQuery.fn.extend({
if ( cur ) { if ( cur ) {
j = 0; j = 0;
while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances // Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) > -1 ) { while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " ); cur = cur.replace( " " + clazz + " ", " " );
...@@ -86,9 +84,9 @@ jQuery.fn.extend({ ...@@ -86,9 +84,9 @@ jQuery.fn.extend({
} }
// Only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = value ? jQuery.trim( cur ) : ""; finalValue = jQuery.trim( cur );
if ( curValue !== finalValue ) { if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue ); jQuery.attr( elem, "class", finalValue );
} }
} }
} }
...@@ -105,15 +103,15 @@ jQuery.fn.extend({ ...@@ -105,15 +103,15 @@ jQuery.fn.extend({
} }
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( i ) { return this.each( function( i ) {
jQuery( this ).toggleClass( jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ), value.call( this, i, getClass( this ), stateVal ),
stateVal stateVal
); );
}); } );
} }
return this.each(function() { return this.each( function() {
var className, i, self, classNames; var className, i, self, classNames;
if ( type === "string" ) { if ( type === "string" ) {
...@@ -139,31 +137,30 @@ jQuery.fn.extend({ ...@@ -139,31 +137,30 @@ jQuery.fn.extend({
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__" ) || "" );
);
}
} }
}); } );
}, },
hasClass: function( selector ) { hasClass: function( selector ) {
var className = " " + selector + " ", var className, elem,
i = 0, i = 0;
l = this.length;
for ( ; i < l; i++ ) { className = " " + selector + " ";
if ( this[i].nodeType === 1 && while ( ( elem = this[ i++ ] ) ) {
( " " + getClass( this[i] ) + " " ).replace( rclass, " " ) if ( elem.nodeType === 1 &&
( " " + getClass( elem ) + " " ).replace( rclass, " " )
.indexOf( className ) > -1 .indexOf( className ) > -1
) { ) {
return true; return true;
...@@ -172,6 +169,6 @@ jQuery.fn.extend({ ...@@ -172,6 +169,6 @@ jQuery.fn.extend({
return false; return false;
} }
}); } );
}); } );
define([ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support", "./support",
"../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;
jQuery.fn.extend({ jQuery.fn.extend( {
prop: function( name, value ) { prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 ); return access( this, jQuery.prop, name, value, arguments.length > 1 );
}, },
removeProp: function( name ) { removeProp: function( name ) {
return this.each(function() { name = jQuery.propFix[ name ] || name;
delete this[ jQuery.propFix[ name ] || name ]; return this.each( function() {
});
// try/catch handles cases where IE balks (such as removing a property on window)
try {
this[ name ] = undefined;
delete this[ name ];
} catch ( e ) {}
} );
} }
}); } );
jQuery.extend({ jQuery.extend( {
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var ret, hooks, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
...@@ -55,10 +62,19 @@ jQuery.extend({ ...@@ -55,10 +62,19 @@ jQuery.extend({
propHooks: { propHooks: {
tabIndex: { tabIndex: {
get: function( elem ) { get: function( elem ) {
return elem.hasAttribute( "tabindex" ) ||
rfocusable.test( elem.nodeName ) || elem.href ? // elem.tabIndex doesn't always return the
elem.tabIndex : // correct value when it hasn't been explicitly set
-1; // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
// Use proper attribute retrieval(#12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
return tabindex ?
parseInt( tabindex, 10 ) :
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) && elem.href ?
0 :
-1;
} }
} }
}, },
...@@ -67,21 +83,44 @@ jQuery.extend({ ...@@ -67,21 +83,44 @@ jQuery.extend({
"for": "htmlFor", "for": "htmlFor",
"class": "className" "class": "className"
} }
}); } );
// 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;
} }
}; };
} }
jQuery.each([ jQuery.each( [
"tabIndex", "tabIndex",
"readOnly", "readOnly",
"maxLength", "maxLength",
...@@ -94,6 +133,11 @@ jQuery.each([ ...@@ -94,6 +133,11 @@ jQuery.each([
"contentEditable" "contentEditable"
], function() { ], function() {
jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
}); } );
// IE6/7 call enctype encoding
if ( !support.enctype ) {
jQuery.propFix.enctype = "encoding";
}
}); } );
define([ define( [
"../var/document", "../var/document",
"../var/support" "../var/support"
], 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: Android<=2.3 // Tests for enctype support on a form (#6743)
// Options inside disabled selects are incorrectly marked as disabled 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; select.disabled = true;
support.optDisabled = !opt.disabled; support.optDisabled = !opt.disabled;
// Support: IE<=11+ // Support: IE8 only
// An input loses its value after becoming a radio // 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";
})(); } )();
return support; return support;
}); } );
define([ define( [
"../core", "../core",
"./support", "./support",
"../core/init" "../core/init"
...@@ -6,26 +6,32 @@ define([ ...@@ -6,26 +6,32 @@ define([
var rreturn = /\r/g; var rreturn = /\r/g;
jQuery.fn.extend({ jQuery.fn.extend( {
val: function( value ) { val: function( value ) {
var hooks, ret, isFunction, var hooks, ret, isFunction,
elem = this[0]; elem = this[ 0 ];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] || hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ]; jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { if (
hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret; return ret;
} }
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// Handle most common string cases
ret.replace(rreturn, "") : // handle most common string cases
// Handle cases where value is null/undef or number ret.replace( rreturn, "" ) :
// handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
...@@ -34,7 +40,7 @@ jQuery.fn.extend({ ...@@ -34,7 +40,7 @@ jQuery.fn.extend({
isFunction = jQuery.isFunction( value ); isFunction = jQuery.isFunction( value );
return this.each(function( i ) { return this.each( function( i ) {
var val; var val;
if ( this.nodeType !== 1 ) { if ( this.nodeType !== 1 ) {
...@@ -50,33 +56,35 @@ jQuery.fn.extend({ ...@@ -50,33 +56,35 @@ 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 + "";
}); } );
} }
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting // If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val; this.value = val;
} }
}); } );
} }
}); } );
jQuery.extend({ jQuery.extend( {
valHooks: { valHooks: {
option: { option: {
get: function( elem ) { get: function( elem ) {
// Support: IE<11 var val = jQuery.find.attr( elem, "value" );
// option.value not trimmed (#14858) return val != null ?
return jQuery.trim( elem.value ); val :
// Support: IE10-11+
// option.text throws exceptions (#14686, #14858)
jQuery.trim( jQuery.text( elem ) );
} }
}, },
select: { select: {
...@@ -95,11 +103,13 @@ jQuery.extend({ ...@@ -95,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
( support.optDisabled ? ( support.optDisabled ?
!option.disabled : option.getAttribute( "disabled" ) === null ) && !option.disabled :
option.getAttribute( "disabled" ) === null ) &&
( !option.parentNode.disabled || ( !option.parentNode.disabled ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
...@@ -127,9 +137,24 @@ jQuery.extend({ ...@@ -127,9 +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;
} }
} }
...@@ -137,26 +162,27 @@ jQuery.extend({ ...@@ -137,26 +162,27 @@ jQuery.extend({
if ( !optionSet ) { if ( !optionSet ) {
elem.selectedIndex = -1; elem.selectedIndex = -1;
} }
return values;
return options;
} }
} }
} }
}); } );
// Radios and checkboxes getter/setter // Radios and checkboxes getter/setter
jQuery.each([ "radio", "checkbox" ], function() { jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = { jQuery.valHooks[ this ] = {
set: function( elem, value ) { set: function( elem, value ) {
if ( jQuery.isArray( value ) ) { if ( jQuery.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) > -1 ); return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
} }
} }
}; };
if ( !support.checkOn ) { if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) { jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute("value") === null ? "on" : elem.value; return elem.getAttribute( "value" ) === null ? "on" : elem.value;
}; };
} }
}); } );
}); } );
define([ define( [
"./core", "./core",
"./var/rnotwhite" "./var/rnotwhite"
], function( jQuery, rnotwhite ) { ], function( jQuery, rnotwhite ) {
...@@ -8,7 +8,7 @@ function createOptions( options ) { ...@@ -8,7 +8,7 @@ function createOptions( options ) {
var object = {}; var object = {};
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
object[ flag ] = true; object[ flag ] = true;
}); } );
return object; return object;
} }
...@@ -44,18 +44,25 @@ jQuery.Callbacks = function( options ) { ...@@ -44,18 +44,25 @@ jQuery.Callbacks = function( options ) {
var // Flag to know if list is currently firing var // Flag to know if list is currently firing
firing, firing,
// Last fire value for non-forgettable lists // Last fire value for non-forgettable lists
memory, memory,
// Flag to know if list was already fired // Flag to know if list was already fired
fired, fired,
// Flag to prevent firing // Flag to prevent firing
locked, locked,
// Actual callback list // Actual callback list
list = [], list = [],
// Queue of execution data for repeatable lists // Queue of execution data for repeatable lists
queue = [], queue = [],
// Index of currently firing callback (modified by add/remove as needed) // Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1, firingIndex = -1,
// Fire callbacks // Fire callbacks
fire = function() { fire = function() {
...@@ -114,18 +121,19 @@ jQuery.Callbacks = function( options ) { ...@@ -114,18 +121,19 @@ jQuery.Callbacks = function( options ) {
queue.push( memory ); queue.push( memory );
} }
(function add( args ) { ( function add( args ) {
jQuery.each( args, function( _, arg ) { jQuery.each( args, function( _, arg ) {
if ( jQuery.isFunction( arg ) ) { if ( jQuery.isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) { if ( !options.unique || !self.has( arg ) ) {
list.push( arg ); list.push( arg );
} }
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
// Inspect recursively // Inspect recursively
add( arg ); add( arg );
} }
}); } );
})( arguments ); } )( arguments );
if ( memory && !firing ) { if ( memory && !firing ) {
fire(); fire();
...@@ -146,7 +154,7 @@ jQuery.Callbacks = function( options ) { ...@@ -146,7 +154,7 @@ jQuery.Callbacks = function( options ) {
firingIndex--; firingIndex--;
} }
} }
}); } );
return this; return this;
}, },
...@@ -182,9 +190,9 @@ jQuery.Callbacks = function( options ) { ...@@ -182,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;
}, },
...@@ -221,4 +229,4 @@ jQuery.Callbacks = function( options ) { ...@@ -221,4 +229,4 @@ jQuery.Callbacks = function( options ) {
}; };
return jQuery; return jQuery;
}); } );
define([ define( [
"./var/arr", "./var/deletedIds",
"./var/document", "./var/document",
"./var/slice", "./var/slice",
"./var/concat", "./var/concat",
...@@ -9,25 +9,27 @@ define([ ...@@ -9,25 +9,27 @@ define([
"./var/toString", "./var/toString",
"./var/hasOwn", "./var/hasOwn",
"./var/support" "./var/support"
], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { ], function( deletedIds, document, slice, concat, push, indexOf,
class2type, toString, hasOwn, support ) {
var var
version = "@VERSION", version = "@VERSION",
// Define a local copy of jQuery // Define a local copy of jQuery
jQuery = function( selector, context ) { jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced' // The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included) // Need init if jQuery is called (just allow error to be thrown if not included)
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 ) {
...@@ -35,11 +37,15 @@ var ...@@ -35,11 +37,15 @@ var
}; };
jQuery.fn = jQuery.prototype = { jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used // The current version of jQuery being used
jquery: version, jquery: version,
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,
...@@ -68,6 +74,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -68,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;
...@@ -79,9 +86,9 @@ jQuery.fn = jQuery.prototype = { ...@@ -79,9 +86,9 @@ jQuery.fn = jQuery.prototype = {
}, },
map: function( callback ) { map: function( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) { return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem ); return callback.call( elem, i, elem );
})); } ) );
}, },
slice: function() { slice: function() {
...@@ -99,23 +106,23 @@ jQuery.fn = jQuery.prototype = { ...@@ -99,23 +106,23 @@ jQuery.fn = jQuery.prototype = {
eq: function( i ) { eq: function( i ) {
var len = this.length, var len = this.length,
j = +i + ( i < 0 ? len : 0 ); j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
}, },
end: function() { end: function() {
return this.prevObject || this.constructor(null); return this.prevObject || this.constructor();
}, },
// 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,
deep = false; deep = false;
...@@ -124,25 +131,27 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -124,25 +131,27 @@ 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++;
} }
// Handle case when target is a string or something (possible in deep copy) // Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
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--;
} }
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values // Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) { if ( ( options = arguments[ i ] ) != null ) {
// Extend the base object // Extend the base object
for ( name in options ) { for ( name in options ) {
src = target[ name ]; src = target[ name ];
...@@ -154,15 +163,15 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -154,15 +163,15 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
// Recurse if we're merging plain objects or arrays // Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) || if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
(copyIsArray = jQuery.isArray(copy)) ) ) { ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
if ( copyIsArray ) { if ( copyIsArray ) {
copyIsArray = false; copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : []; clone = src && jQuery.isArray( src ) ? src : [];
} else { } else {
clone = src && jQuery.isPlainObject(src) ? src : {}; clone = src && jQuery.isPlainObject( src ) ? src : {};
} }
// Never move original objects, clone them // Never move original objects, clone them
...@@ -180,7 +189,8 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -180,7 +189,8 @@ jQuery.extend = jQuery.fn.extend = function() {
return target; return target;
}; };
jQuery.extend({ jQuery.extend( {
// Unique for each copy of jQuery on the page // Unique for each copy of jQuery on the page
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
...@@ -193,71 +203,103 @@ jQuery.extend({ ...@@ -193,71 +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 ) {
// parseFloat NaNs numeric-cast false positives (null|true|false|"") // parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...") // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN // subtraction forces infinities to NaN
// adding 1 corrects loss of precision from parseFloat (#15100) // adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; var realStringObj = obj && obj.toString();
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
}, },
isPlainObject: function( obj ) { isEmptyObject: function( obj ) {
// Not plain objects: var name;
// - Any object or value whose internal [[Class]] property is not "[object Object]" for ( name in obj ) {
// - DOM nodes
// - window
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false; return false;
} }
return true;
},
if ( obj.constructor && isPlainObject: function( obj ) {
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { var key;
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false; return false;
} }
// If the function hasn't returned already, we're confident that try {
// |obj| is a plain object, created by {} or constructed with new Object
return true;
},
isEmptyObject: function( obj ) { // Not own constructor property must be Object
var name; if ( obj.constructor &&
for ( name in obj ) { !hasOwn.call( obj, "constructor" ) &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false; return false;
} }
return true;
// Support: IE<9
// Handle iteration over inherited properties before own properties.
if ( !support.ownFirst ) {
for ( key in obj ) {
return hasOwn.call( obj, key );
}
}
// 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
var script = document.createElement( "script" ); globalEval: function( data ) {
if ( data && jQuery.trim( data ) ) {
script.text = code;
document.head.appendChild( script ).parentNode.removeChild( script ); // 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 );
...@@ -268,11 +310,10 @@ jQuery.extend({ ...@@ -268,11 +310,10 @@ jQuery.extend({
}, },
each: function( obj, callback ) { each: function( obj, callback ) {
var i = 0, var length, i = 0;
length = obj.length,
isArray = isArraylike( obj );
if ( isArray ) { if ( isArrayLike( obj ) ) {
length = obj.length;
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break; break;
...@@ -289,7 +330,7 @@ jQuery.extend({ ...@@ -289,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 ?
"" : "" :
...@@ -301,7 +342,7 @@ jQuery.extend({ ...@@ -301,7 +342,7 @@ jQuery.extend({
var ret = results || []; var ret = results || [];
if ( arr != null ) { if ( arr != null ) {
if ( isArraylike( Object(arr) ) ) { if ( isArrayLike( Object( arr ) ) ) {
jQuery.merge( ret, jQuery.merge( ret,
typeof arr === "string" ? typeof arr === "string" ?
[ arr ] : arr [ arr ] : arr
...@@ -315,18 +356,43 @@ jQuery.extend({ ...@@ -315,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;
...@@ -355,14 +421,13 @@ jQuery.extend({ ...@@ -355,14 +421,13 @@ jQuery.extend({
// arg is for internal usage only // arg is for internal usage only
map: function( elems, callback, arg ) { map: function( elems, callback, arg ) {
var value, var length, value,
i = 0, i = 0,
length = elems.length,
isArray = isArraylike( elems ),
ret = []; ret = [];
// Go through the array, translating each of the items to their new values // Go through the array, translating each of the items to their new values
if ( isArray ) { if ( isArrayLike( elems ) ) {
length = elems.length;
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg ); value = callback( elems[ i ], i, arg );
...@@ -392,7 +457,7 @@ jQuery.extend({ ...@@ -392,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 ];
...@@ -418,12 +483,14 @@ jQuery.extend({ ...@@ -418,12 +483,14 @@ 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.
support: support support: support
}); } );
// JSHint would error on this code due to the Symbol not being defined in ES5. // JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global // Defining this global in .jshintrc would create a danger of using the global
...@@ -431,23 +498,23 @@ jQuery.extend({ ...@@ -431,23 +498,23 @@ 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 */
// Populate the class2type map // Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
function(i, name) { function( i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase(); class2type[ "[object " + name + "]" ] = name.toLowerCase();
}); } );
function isArraylike( obj ) { function isArrayLike( obj ) {
// Support: iOS 8.2 (not reproducible in simulator) // Support: iOS 8.2 (not reproducible in simulator)
// `in` check used to prevent JIT error (gh-2145) // `in` check used to prevent JIT error (gh-2145)
// hasOwn isn't used here due to false negatives // hasOwn isn't used here due to false negatives
// regarding Nodelist length in IE // regarding Nodelist length in IE
var length = "length" in obj && obj.length, var length = !!obj && "length" in obj && obj.length,
type = jQuery.type( obj ); type = jQuery.type( obj );
if ( type === "function" || jQuery.isWindow( obj ) ) { if ( type === "function" || jQuery.isWindow( obj ) ) {
...@@ -459,4 +526,4 @@ function isArraylike( obj ) { ...@@ -459,4 +526,4 @@ function isArraylike( obj ) {
} }
return jQuery; return jQuery;
}); } );
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// Multifunctional method to get and set values of a collection // Multifunctional method to get and set values of a collection
// 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 = jQuery.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
if ( jQuery.type( key ) === "object" ) { if ( jQuery.type( key ) === "object" ) {
chainable = true; chainable = true;
for ( i in key ) { for ( i in key ) {
access( elems, fn, i, key[i], true, emptyGet, raw ); access( elems, fn, i, key[ i ], true, emptyGet, raw );
} }
// Sets one value // Sets one value
...@@ -25,6 +25,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe ...@@ -25,6 +25,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
} }
if ( bulk ) { if ( bulk ) {
// Bulk operations run against the entire set // Bulk operations run against the entire set
if ( raw ) { if ( raw ) {
fn.call( elems, value ); fn.call( elems, value );
...@@ -40,8 +41,12 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe ...@@ -40,8 +41,12 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
} }
if ( fn ) { if ( fn ) {
for ( ; i < len; i++ ) { for ( ; i < length; i++ ) {
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); fn(
elems[ i ],
key,
raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
} }
} }
} }
...@@ -52,9 +57,9 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe ...@@ -52,9 +57,9 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
// 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;
}); } );
// Initialize a jQuery object // Initialize a jQuery object
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"./var/rsingleTag", "./var/rsingleTag",
...@@ -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;
...@@ -29,8 +28,8 @@ var rootjQuery, ...@@ -29,8 +28,8 @@ var 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
...@@ -41,23 +40,24 @@ var rootjQuery, ...@@ -41,23 +40,24 @@ var rootjQuery,
} }
// Match html or make sure no context is specified for #id // Match html or make sure no context is specified for #id
if ( match && (match[1] || !context) ) { if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array) // HANDLE: $(html) -> $(array)
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 ],
context && context.nodeType ? context.ownerDocument || context : document, context && context.nodeType ? context.ownerDocument || context : document,
true true
) ); ) );
// HANDLE: $(html, props) // HANDLE: $(html, props)
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) { for ( match in context ) {
// Properties of context are called as methods if possible // Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) { if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] ); this[ match ]( context[ match ] );
...@@ -73,13 +73,25 @@ var rootjQuery, ...@@ -73,13 +73,25 @@ var rootjQuery,
// HANDLE: $(#id) // HANDLE: $(#id)
} else { } else {
elem = document.getElementById( match[2] ); elem = document.getElementById( match[ 2 ] );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[ 2 ] ) {
return rootjQuery.find( selector );
}
if ( elem ) { // Otherwise, we inject the element directly into the jQuery object
// Inject the element directly into the jQuery object
this[0] = elem;
this.length = 1; this.length = 1;
this[ 0 ] = elem;
} }
this.context = document;
this.selector = selector;
return this; return this;
} }
...@@ -95,19 +107,25 @@ var rootjQuery, ...@@ -95,19 +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 );
}; };
...@@ -119,4 +137,4 @@ rootjQuery = jQuery( document ); ...@@ -119,4 +137,4 @@ rootjQuery = jQuery( document );
return init; return init;
}); } );
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"./var/rsingleTag", "./var/rsingleTag",
...@@ -13,13 +13,14 @@ define([ ...@@ -13,13 +13,14 @@ define([
// defaults to document // defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) { jQuery.parseHTML = function( data, context, keepScripts ) {
if ( 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;
} }
// document.implementation stops scripts or inline event handlers from // document.implementation stops scripts or inline event handlers from
// being executed immediately // being executed immediately
context = context || ( support.createHTMLDocument ? context = context || ( support.createHTMLDocument ?
...@@ -31,7 +32,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) { ...@@ -31,7 +32,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
// Single tag // Single tag
if ( parsed ) { if ( parsed ) {
return [ context.createElement( parsed[1] ) ]; return [ context.createElement( parsed[ 1 ] ) ];
} }
parsed = buildFragment( [ data ], context, scripts ); parsed = buildFragment( [ data ], context, scripts );
...@@ -45,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) { ...@@ -45,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
return jQuery.parseHTML; return jQuery.parseHTML;
}); } );
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../core/init",
"../deferred" "../deferred"
], function( jQuery, document ) { ], function( jQuery, document ) {
...@@ -8,13 +9,15 @@ define([ ...@@ -8,13 +9,15 @@ define([
var readyList; var readyList;
jQuery.fn.ready = function( fn ) { jQuery.fn.ready = function( fn ) {
// Add the callback // Add the callback
jQuery.ready.promise().done( fn ); jQuery.ready.promise().done( fn );
return this; return this;
}; };
jQuery.extend({ jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs. // Is the DOM ready to be used? Set to true once it occurs.
isReady: false, isReady: false,
...@@ -49,16 +52,42 @@ jQuery.extend({ ...@@ -49,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 ) {
...@@ -68,20 +97,62 @@ jQuery.ready.promise = function( obj ) { ...@@ -68,20 +97,62 @@ 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.
// We once tried to use readyState "interactive" here, // we once tried to use readyState "interactive" here,
// but it caused issues like the one // but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 // discovered by ChrisS here:
// http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) { if ( document.readyState === "complete" ) {
// 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 );
...@@ -90,4 +161,4 @@ jQuery.ready.promise = function( obj ) { ...@@ -90,4 +161,4 @@ jQuery.ready.promise = function( obj ) {
// Kick off the DOM ready check even if the user does not // Kick off the DOM ready check even if the user does not
jQuery.ready.promise(); jQuery.ready.promise();
}); } );
define([ define( [
"../var/document", "../var/document",
"../var/support" "../var/support"
], function( document, support ) { ], function( document, support ) {
support.createHTMLDocument = (function() { // Support: Safari 8+
var body = document.implementation.createHTMLDocument( "" ).body; // In Safari 8 documents created via document.implementation.createHTMLDocument
body.innerHTML = "<form></form><form></form>"; // collapse sibling forms: the second one becomes a child of the first one.
return body.childNodes.length === 2; // Because of that, this security measure has to be disabled in Safari 8.
})(); // https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = ( function() {
if ( !document.implementation.createHTMLDocument ) {
return false;
}
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 (/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/); return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
}); } );
define([ define( [
"./core", "./core",
"./var/pnum", "./var/pnum",
"./core/access", "./core/access",
...@@ -8,24 +8,30 @@ define([ ...@@ -8,24 +8,30 @@ 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",
"./css/showHide",
"./core/init", "./core/init",
"./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, showHide ) { isHidden, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support ) {
var var
// Swappable if display is none or starts with table
// except "table", "table-cell", or "table-caption" // BuildExclude
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display getStyles = curCSS.getStyles,
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" ), rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
...@@ -35,19 +41,22 @@ var ...@@ -35,19 +41,22 @@ var
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-- ) {
...@@ -58,9 +67,67 @@ function vendorPropName( name ) { ...@@ -58,9 +67,67 @@ function vendorPropName( name ) {
} }
} }
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 ) {
// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if ( !values[ index ] && display === "none" ) {
elem.style.display = "";
}
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if ( elem.style.display === "" && isHidden( elem ) ) {
values[ index ] =
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 ) { function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value ); 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[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
value; value;
...@@ -68,34 +135,39 @@ function setPositiveNumber( elem, value, subtract ) { ...@@ -68,34 +135,39 @@ function setPositiveNumber( elem, value, subtract ) {
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ? var i = extra === ( isBorderBox ? "border" : "content" ) ?
// If we already have the right measurement, avoid augmentation // If we already have the right measurement, avoid augmentation
4 : 4 :
// Otherwise initialize for horizontal or vertical properties // Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0, name === "width" ? 1 : 0,
val = 0; val = 0;
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 );
} }
if ( isBorderBox ) { if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content // border-box includes padding, so remove it if we want content
if ( extra === "content" ) { if ( extra === "content" ) {
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 );
} }
...@@ -108,29 +180,30 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -108,29 +180,30 @@ 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 ) {
// Fall back to computed then uncomputed css if necessary // Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
...@@ -138,11 +211,11 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -138,11 +211,11 @@ function getWidthOrHeight( elem, name, extra ) {
} }
// Computed unit is not pixels. Stop here and return. // Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) { if ( rnumnonpx.test( val ) ) {
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 ] );
...@@ -151,7 +224,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -151,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,
...@@ -163,7 +236,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -163,7 +236,7 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px"; ) + "px";
} }
jQuery.extend({ jQuery.extend( {
// Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
// behavior of getting and setting a style property // behavior of getting and setting a style property
...@@ -182,6 +255,7 @@ jQuery.extend({ ...@@ -182,6 +255,7 @@ jQuery.extend({
// Don't automatically add "px" to these possibly-unitless properties // Don't automatically add "px" to these possibly-unitless properties
cssNumber: { cssNumber: {
"animationIterationCount": true,
"columnCount": true, "columnCount": true,
"fillOpacity": true, "fillOpacity": true,
"flexGrow": true, "flexGrow": true,
...@@ -199,7 +273,9 @@ jQuery.extend({ ...@@ -199,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
...@@ -218,7 +294,8 @@ jQuery.extend({ ...@@ -218,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
...@@ -226,13 +303,14 @@ jQuery.extend({ ...@@ -226,13 +303,14 @@ jQuery.extend({
type = typeof value; type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345) // Convert "+=" or "-=" to relative numbers (#7345)
if ( type === "string" && (ret = rcssNum.exec( value )) && ret[ 1 ] ) { if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = adjustCSS( elem, name, ret ); value = adjustCSS( elem, name, ret );
// Fixes bug #9237 // Fixes bug #9237
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;
} }
...@@ -242,23 +320,29 @@ jQuery.extend({ ...@@ -242,23 +320,29 @@ 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";
} }
// If a hook was provided, use that value, otherwise just set the specified value // If a hook was provided, use that value, otherwise just set the specified value
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 {
// If a hook was provided get the non-computed value from there // If a hook was provided get the non-computed value from there
if ( hooks && "get" in hooks && if ( hooks && "get" in hooks &&
(ret = hooks.get( elem, false, extra )) !== undefined ) { ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret; return ret;
} }
...@@ -269,14 +353,15 @@ jQuery.extend({ ...@@ -269,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
...@@ -289,38 +374,32 @@ jQuery.extend({ ...@@ -289,38 +374,32 @@ 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 || jQuery.isNumeric( num ) ? num || 0 : val; return extra === true || isFinite( num ) ? num || 0 : val;
} }
return val; return val;
} }
}); } );
jQuery.each([ "height", "width" ], function( i, name ) { jQuery.each( [ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ 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" ) ) &&
// Support: Safari 8+ elem.offsetWidth === 0 ?
// 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 );
}) : } ) :
getWidthOrHeight( elem, name, extra ); getWidthOrHeight( elem, name, extra );
} }
}, },
...@@ -332,15 +411,64 @@ jQuery.each([ "height", "width" ], function( i, name ) { ...@@ -332,15 +411,64 @@ jQuery.each([ "height", "width" ], function( i, name ) {
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 ) : 0
); );
} }
}; };
}); } );
if ( !support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {
// IE uses filters for opacity
return ropacity.test( ( computed && elem.currentStyle ?
elem.currentStyle.filter :
elem.style.filter ) || "" ) ?
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
computed ? "1" : "";
},
set: function( elem, value ) {
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;
}
}
// otherwise, set new filter values
style.filter = ralpha.test( filter ) ?
filter.replace( ralpha, opacity ) :
filter + " " + opacity;
}
};
}
// Support: Android 2.3
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
...@@ -350,8 +478,30 @@ jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, ...@@ -350,8 +478,30 @@ jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
} }
); );
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
function( elem, computed ) {
if ( computed ) {
return (
parseFloat( curCSS( elem, "marginLeft" ) ) ||
// Support: IE<=11+
// Running getBoundingClientRect on a disconnected node in IE throws an error
// 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";
}
}
);
// These hooks are used by animate to expand properties // These hooks are used by animate to expand properties
jQuery.each({ jQuery.each( {
margin: "", margin: "",
padding: "", padding: "",
border: "Width" border: "Width"
...@@ -361,8 +511,8 @@ jQuery.each({ ...@@ -361,8 +511,8 @@ 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++ ) {
expanded[ prefix + cssExpand[ i ] + suffix ] = expanded[ prefix + cssExpand[ i ] + suffix ] =
...@@ -376,9 +526,9 @@ jQuery.each({ ...@@ -376,9 +526,9 @@ jQuery.each({
if ( !rmargin.test( prefix ) ) { if ( !rmargin.test( prefix ) ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
css: function( name, value ) { css: function( name, value ) {
return access( this, function( elem, name, value ) { return access( this, function( elem, name, value ) {
var styles, len, var styles, len,
...@@ -412,15 +562,15 @@ jQuery.fn.extend({ ...@@ -412,15 +562,15 @@ jQuery.fn.extend({
return state ? this.show() : this.hide(); return state ? this.show() : this.hide();
} }
return this.each(function() { return this.each( function() {
if ( isHidden( this ) ) { if ( isHidden( this ) ) {
jQuery( this ).show(); jQuery( this ).show();
} else { } else {
jQuery( this ).hide(); jQuery( this ).hide();
} }
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );
define(function() { define( function() {
function addGetHookIf( conditionFn, hookFn ) { function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed. // Define the hook, we'll check on the first run if it's really needed.
return { return {
get: function() { get: function() {
if ( conditionFn() ) { if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due // Hook not needed (or it's not possible to use it due
// to missing dependency), remove it. // to missing dependency), remove it.
delete this.get; delete this.get;
...@@ -12,11 +14,11 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -12,11 +14,11 @@ function addGetHookIf( conditionFn, hookFn ) {
} }
// Hook needed; redefine it so that the support test is not executed again. // Hook needed; redefine it so that the support test is not executed again.
return (this.get = hookFn).apply( this, arguments ); return ( this.get = hookFn ).apply( this, arguments );
} }
}; };
} }
return addGetHookIf; return addGetHookIf;
}); } );
define([ define( [
"../core", "../core",
"../var/rcssNum" "../var/rcssNum"
], function( jQuery, rcssNum ) { ], function( jQuery, rcssNum ) {
...@@ -12,11 +12,13 @@ function adjustCSS( elem, prop, valueParts, tween ) { ...@@ -12,11 +12,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
function() { return jQuery.css( elem, prop, "" ); }, function() { return jQuery.css( elem, prop, "" ); },
initial = currentValue(), initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches // Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) ); rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Trust units reported by jQuery.css // Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ]; unit = unit || initialInUnit[ 3 ];
...@@ -27,6 +29,7 @@ function adjustCSS( elem, prop, valueParts, tween ) { ...@@ -27,6 +29,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
initialInUnit = +initial || 1; initialInUnit = +initial || 1;
do { do {
// If previous iteration zeroed out, double until we get *something*. // If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below // Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5"; scale = scale || ".5";
...@@ -38,12 +41,13 @@ function adjustCSS( elem, prop, valueParts, tween ) { ...@@ -38,12 +41,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
// Update scale, tolerating zero or NaN from tween.cur() // Update scale, tolerating zero or NaN from tween.cur()
// Break the loop if scale is unchanged or perfect, or if we've just had enough. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
} while ( } while (
scale !== (scale = currentValue() / initial) && scale !== 1 && --maxIterations scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
); );
} }
if ( valueParts ) { if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0; initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified // Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ? adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
...@@ -58,4 +62,4 @@ function adjustCSS( elem, prop, valueParts, tween ) { ...@@ -58,4 +62,4 @@ function adjustCSS( elem, prop, valueParts, tween ) {
} }
return adjustCSS; return adjustCSS;
}); } );
define([ define( [
"exports",
"../core", "../core",
"../var/documentElement",
"./var/rnumnonpx", "./var/rnumnonpx",
"./var/rmargin", "./var/rmargin",
"./var/getStyles",
"./support", "./support",
"../selector" // 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.opener ) {
ret = jQuery.style( elem, name ); view = window;
} }
// A tribute to the "awesome hack by Dean Edwards" return view.getComputedStyle( elem );
// Android Browser returns percentage for some values, };
// but width seems to be reliably pixels.
// This is against the CSSOM draft spec: curCSS = function( elem, name, computed ) {
// http://dev.w3.org/csswg/cssom/#resolved-values var width, minWidth, maxWidth, ret,
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { 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;
if ( computed ) {
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
ret = jQuery.style( elem, name );
}
// A tribute to the "awesome hack by Dean Edwards"
// Chrome < 17 and Safari 5.0 uses "computed value"
// instead of "used value" for margin-right
// 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;
} );
define( [
"../core",
"../var/document",
"../manipulation" // appendTo
], function( jQuery, document ) {
var iframe,
elemdisplay = {
// Support: Firefox
// We have to pre-define these values for FF (#10227)
HTML: "block",
BODY: "block"
};
/**
* Retrieve the actual display of a element
* @param {String} name nodeName of the element
* @param {Object} doc Document object
*/
// Called only from within defaultDisplay
function actualDisplay( name, doc ) {
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
display = jQuery.css( elem[ 0 ], "display" );
// We don't have any data stored on the element,
// so use "detach" method as fast way to get rid of the element
elem.detach();
return display;
}
/**
* Try to determine the default display value of an element
* @param {String} nodeName
*/
function defaultDisplay( nodeName ) {
var doc = document,
display = elemdisplay[ nodeName ];
if ( !display ) {
display = actualDisplay( nodeName, doc );
// If the simple way fails, read from inside an iframe
if ( display === "none" || !display ) {
// Use the already-created iframe if possible
iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
.appendTo( doc.documentElement );
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
// Support: IE
doc.write();
doc.close();
display = actualDisplay( nodeName, doc );
iframe.detach();
}
// Store the correct default display
elemdisplay[ nodeName ] = display;
}
return display;
}
return defaultDisplay;
} );
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() {
"../data/var/dataPriv"
], function( dataPriv ) {
function showHide( elements, show ) { function showHide( elements, show ) {
var display, elem, var display, elem,
values = [], values = [],
...@@ -18,15 +15,16 @@ function showHide( elements, show ) { ...@@ -18,15 +15,16 @@ function showHide( elements, show ) {
display = elem.style.display; display = elem.style.display;
if ( show ) { if ( show ) {
if ( display === "none" ) { if ( display === "none" ) {
// Restore a pre-hide() value if we have one // Restore a pre-hide() value if we have one
values[ index ] = dataPriv.get( elem, "display" ) || ""; values[ index ] = jQuery._data( elem, "display" ) || "";
} }
} else { } else {
if ( display !== "none" ) { if ( display !== "none" ) {
values[ index ] = "none"; values[ index ] = "none";
// Remember the value we're replacing // Remember the value we're replacing
dataPriv.set( elem, "display", display ); jQuery._data( elem, "display", display );
} }
} }
} }
...@@ -44,4 +42,4 @@ function showHide( elements, show ) { ...@@ -44,4 +42,4 @@ function showHide( elements, show ) {
return showHide; return showHide;
}); } );
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../var/documentElement", "../var/documentElement",
"../var/support" "../var/support"
], function( jQuery, document, documentElement, support ) { ], function( jQuery, document, documentElement, support ) {
(function() { ( function() {
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
...@@ -15,91 +16,168 @@ define([ ...@@ -15,91 +16,168 @@ 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 === "";
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;box-sizing:border-box;" +
"display:block;position:absolute;" +
"margin:0;margin-top:1%;margin-right:50%;" +
"border:1px;padding:1px;" +
"top:1%;width:50%;height:4px";
div.innerHTML = "";
documentElement.appendChild( container );
var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%";
boxSizingReliableVal = divStyle.height === "4px";
pixelMarginRightVal = divStyle.marginRight === "4px";
documentElement.removeChild( container );
}
jQuery.extend( support, { jQuery.extend( support, {
pixelPosition: function() { reliableHiddenOffsets: function() {
// This test is executed only once but we still do memoizing if ( pixelPositionVal == null ) {
// since we can use the boxSizingReliable pre-computing. computeStyleTests();
// No need to check if the test was already performed, though. }
computeStyleTests(); return reliableHiddenOffsetsVal;
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() { reliableMarginRight: function() {
// Support: Android 2.3 // Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly if ( pixelPositionVal == null ) {
// gets computed margin-right based on width of container. (#3333) computeStyleTests();
}
return reliableMarginRightVal;
},
reliableMarginLeft: function() {
// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
if ( pixelPositionVal == null ) {
computeStyleTests();
}
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 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// This support function is only executed once so no memoizing is needed. contents = div.appendChild( document.createElement( "div" ) );
var ret,
marginDiv = div.appendChild( document.createElement( "div" ) );
// Reset CSS: box-sizing; display; margin; border; padding // Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText = contents.style.cssText = div.style.cssText =
// Support: Android 2.3 // Support: Android 2.3
// Vendor-prefix box-sizing // Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" + "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
"display:block;margin:0;border:0;padding:0"; "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0"; contents.style.marginRight = contents.style.width = "0";
div.style.width = "1px"; div.style.width = "1px";
documentElement.appendChild( container );
ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight ); reliableMarginRightVal =
!parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
documentElement.removeChild( container ); div.removeChild( contents );
div.removeChild( marginDiv ); }
return ret; // 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(function() { define( function() {
return [ "Top", "Right", "Bottom", "Left" ]; return [ "Top", "Right", "Bottom", "Left" ];
}); } );
define([ define( [
"../../core", "../../core",
"../../selector" "../../selector"
// css is assumed // css is assumed
], function( jQuery ) { ], function( jQuery ) {
return function( elem, el ) { return function( elem, el ) {
// isHidden might be called from jQuery#filter function; // isHidden might be called from jQuery#filter function;
// in that case, element will be second argument // in that case, element will be second argument
elem = el || elem; elem = el || elem;
return jQuery.css( elem, "display" ) === "none" || return jQuery.css( elem, "display" ) === "none" ||
!jQuery.contains( elem.ownerDocument, elem ); !jQuery.contains( elem.ownerDocument, elem );
}; };
}); } );
define(function() { define( function() {
return (/^margin/); return ( /^margin/ );
}); } );
define([ define( [
"../../var/pnum" "../../var/pnum"
], function( pnum ) { ], function( pnum ) {
return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
}); } );
define(function() { define( function() {
// A method for quickly swapping in/out CSS properties to get correct calculations. // A method for quickly swapping in/out CSS properties to get correct calculations.
return function( elem, options, callback, args ) { return function( elem, options, callback, args ) {
...@@ -21,4 +21,4 @@ return function( elem, options, callback, args ) { ...@@ -21,4 +21,4 @@ return function( elem, options, callback, args ) {
return ret; return ret;
}; };
}); } );
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" ) {
...@@ -32,6 +23,7 @@ function dataAttr( elem, key, data ) { ...@@ -32,6 +23,7 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true : data = data === "true" ? true :
data === "false" ? false : data === "false" ? false :
data === "null" ? null : data === "null" ? null :
// Only convert to a number if it doesn't change the string // Only convert to a number if it doesn't change the string
+data + "" === data ? +data : +data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) : rbrace.test( data ) ? jQuery.parseJSON( data ) :
...@@ -39,50 +31,267 @@ function dataAttr( elem, key, data ) { ...@@ -39,50 +31,267 @@ 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;
} }
jQuery.extend({ // 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( {
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 );
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
data: function( key, value ) { data: function( key, value ) {
var i, name, data, var i, name, data,
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-- ) {
...@@ -91,12 +300,12 @@ jQuery.fn.extend({ ...@@ -91,12 +300,12 @@ jQuery.fn.extend({
if ( attrs[ i ] ) { if ( attrs[ i ] ) {
name = attrs[ i ].name; name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) { if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.slice(5) ); name = jQuery.camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] ); dataAttr( elem, name, data[ name ] );
} }
} }
} }
dataPriv.set( elem, "hasDataAttrs", true ); jQuery._data( elem, "parsedAttrs", true );
} }
} }
...@@ -105,54 +314,29 @@ jQuery.fn.extend({ ...@@ -105,54 +314,29 @@ 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
// 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... // Sets one value
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 );
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );
define( [
"../var/document",
"../var/support"
], function( document, support ) {
( function() {
var div = document.createElement( "div" );
// Support: IE<9
support.deleteExpando = true;
try {
delete div.test;
} catch ( e ) {
support.deleteExpando = false;
}
// Null elements to avoid leaks in IE.
div = null;
} )();
return support;
} );
define( [
"../../core"
], function( jQuery ) {
/**
* Determines whether an object can have data
*/
return function( elem ) {
var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
nodeType = +elem.nodeType || 1;
// Do not set data on non-element DOM nodes because it will not be cleared (#8335).
return nodeType !== 1 && nodeType !== 9 ?
false :
// Nodes accept data unless otherwise specified; rejection can be conditional
!noData || noData !== true && elem.getAttribute( "classid" ) === noData;
};
} );
define([ define( [
"./core", "./core",
"./var/slice", "./var/slice",
"./callbacks" "./callbacks"
], function( jQuery, slice ) { ], function( jQuery, slice ) {
function Identity( v ) { jQuery.extend( {
return v;
}
function Thrower( ex ) {
throw ex;
}
jQuery.extend({
Deferred: function( func ) { Deferred: function( func ) {
var tuples = [ var tuples = [
// action, add listener, callbacks,
// ... .then handlers, argument index, [final state] // action, add listener, listener list, final state
[ "notify", "progress", jQuery.Callbacks("memory"), [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
jQuery.Callbacks("memory"), 2 ], [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
[ "resolve", "done", jQuery.Callbacks("once memory"), [ "notify", "progress", jQuery.Callbacks( "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 = {
...@@ -33,22 +23,14 @@ jQuery.extend({ ...@@ -33,22 +23,14 @@ 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 ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress) var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify }) // deferred[ done | fail | progress ] for forwarding actions to newDefer
// deferred.done(function() { bind to newDefer or newDefer.resolve }) deferred[ tuple[ 1 ] ]( function() {
// deferred.fail(function() { bind to newDefer or newDefer.reject })
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 ) ) {
returned.promise() returned.promise()
...@@ -61,162 +43,12 @@ jQuery.extend({ ...@@ -61,162 +43,12 @@ jQuery.extend({
fn ? [ returned ] : arguments fn ? [ returned ] : arguments
); );
} }
}); } );
}); } );
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 substitue 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 ) {
// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitue 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 {
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
promise: function( obj ) { promise: function( obj ) {
...@@ -225,52 +57,35 @@ jQuery.extend({ ...@@ -225,52 +57,35 @@ 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[ tuple[ 1 ] ] = list.add;
// promise.fail = 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 deferred[ tuple[ 0 ] ] = function() {
// rejected_handlers.fire deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
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] + "With" ]( this === deferred ? promise : this, arguments );
return this; return this;
}; };
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
// deferred.notifyWith = list.fireWith } );
// deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith
deferred[ tuple[0] + "With" ] = list.fireWith;
});
// Make the deferred a promise // Make the deferred a promise
promise.promise( deferred ); promise.promise( deferred );
...@@ -286,8 +101,7 @@ jQuery.extend({ ...@@ -286,8 +101,7 @@ jQuery.extend({
// Deferred helper // Deferred helper
when: function( subordinate /* , ..., subordinateN */ ) { when: function( subordinate /* , ..., subordinateN */ ) {
var method, var i = 0,
i = 0,
resolveValues = slice.call( arguments ), resolveValues = slice.call( arguments ),
length = resolveValues.length, length = resolveValues.length,
...@@ -297,7 +111,7 @@ jQuery.extend({ ...@@ -297,7 +111,7 @@ jQuery.extend({
// the master Deferred. // the master Deferred.
// If resolveValues consist of only a single Deferred, just use that. // If resolveValues consist of only a single Deferred, just use that.
master = remaining === 1 ? subordinate : jQuery.Deferred(), deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
// Update function for both resolve and progress values // Update function for both resolve and progress values
updateFunc = function( i, contexts, values ) { updateFunc = function( i, contexts, values ) {
...@@ -305,50 +119,41 @@ jQuery.extend({ ...@@ -305,50 +119,41 @@ jQuery.extend({
contexts[ i ] = this; contexts[ i ] = this;
values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( values === progressValues ) { if ( values === progressValues ) {
master.notifyWith( contexts, values ); deferred.notifyWith( contexts, values );
} else if ( !( --remaining ) ) { } else if ( !( --remaining ) ) {
master.resolveWith( contexts, values ); deferred.resolveWith( contexts, values );
} }
}; };
}, },
progressValues, progressContexts, resolveContexts; progressValues, progressContexts, resolveContexts;
// Add listeners to Deferred subordinates; treat others as resolved // add listeners to Deferred subordinates; treat others as resolved
if ( length > 1 ) { if ( length > 1 ) {
progressValues = new Array( length ); progressValues = new Array( length );
progressContexts = 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 ] && if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
jQuery.isFunction( (method = resolveValues[ i ].promise) ) ) { resolveValues[ i ].promise()
method.call( resolveValues[ i ] )
.progress( updateFunc( i, progressContexts, progressValues ) ) .progress( updateFunc( i, progressContexts, progressValues ) )
.done( updateFunc( i, resolveContexts, resolveValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( master.reject ); .fail( deferred.reject );
} else if ( resolveValues[ i ] &&
jQuery.isFunction( (method = resolveValues[ i ].then) ) ) {
method.call(
resolveValues[ i ],
updateFunc( i, resolveContexts, resolveValues ),
master.reject,
updateFunc( i, progressContexts, progressValues )
);
} else { } else {
--remaining; --remaining;
} }
} }
} }
// If we're not waiting on anything, resolve the master // if we're not waiting on anything, resolve the master
if ( !remaining ) { if ( !remaining ) {
master.resolveWith( resolveContexts, resolveValues ); deferred.resolveWith( resolveContexts, resolveValues );
} }
return master.promise(); return deferred.promise();
} }
}); } );
return jQuery; return jQuery;
}); } );
define(function() { define( [
}); "./core",
"./traversing"
], function( jQuery ) {
jQuery.fn.extend( {
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
}
} );
// The number of elements contained in the matched element set
jQuery.fn.size = function() {
return this.length;
};
jQuery.fn.andSelf = jQuery.fn.addBack;
} );
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./css" "./css"
...@@ -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" );
...@@ -18,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -18,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
var doc; var doc;
if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
// isn't a whole lot we can do. See pull request at this URL for discussion: // isn't a whole lot we can do. See pull request at this URL for discussion:
// https://github.com/jquery/jquery/pull/764 // https://github.com/jquery/jquery/pull/764
...@@ -30,6 +31,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -30,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 ],
...@@ -38,6 +41,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -38,6 +41,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
} }
return value === undefined ? return value === undefined ?
// Get width or height on the element, requesting but not forcing parseFloat // Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) : jQuery.css( elem, type, extra ) :
...@@ -45,8 +49,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -45,8 +49,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable, null ); }, type, chainable ? margin : undefined, chainable, null );
}; };
}); } );
}); } );
return jQuery; return jQuery;
}); } );
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() {
fxNow = undefined; fxNow = undefined;
}); } );
return ( fxNow = jQuery.now() ); return ( fxNow = jQuery.now() );
} }
// 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 ];
...@@ -67,9 +58,9 @@ function createTween( value, prop, animation ) { ...@@ -67,9 +58,9 @@ function createTween( value, prop, animation ) {
index = 0, index = 0,
length = collection.length; length = collection.length;
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 ) {
...@@ -99,138 +89,125 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -99,138 +89,125 @@ function defaultPrefilter( elem, props, opts ) {
} }
hooks.unqueued++; hooks.unqueued++;
anim.always(function() { anim.always( function() {
// Ensure the complete handler is called before this completes
anim.always(function() { // doing this makes sure that the complete handler will be called
// before this completes
anim.always( function() {
hooks.unqueued--; hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire(); hooks.empty.fire();
} }
}); } );
}); } );
} }
// Detect show/hide animations // height/width overflow pass
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE does not
// change the overflow attribute when overflowX and
// overflowY are set to the same value
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated
display = jQuery.css( elem, "display" );
// Test default display if display is currently "none"
checkDisplay = display === "none" ?
jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
style.display = "inline-block";
} else {
style.zoom = 1;
}
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
if ( !support.shrinkWrapBlocks() ) {
anim.always( function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
} );
}
}
// show/hide pass
for ( prop in props ) { for ( prop in props ) {
value = props[ prop ]; value = props[ prop ];
if ( rfxtypes.test( value ) ) { if ( rfxtypes.exec( value ) ) {
delete props[ prop ]; delete props[ prop ];
toggle = toggle || value === "toggle"; toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) { if ( value === ( hidden ? "hide" : "show" ) ) {
// Pretend to be hidden if this is a "show" and // If there is dataShow left over from a stopped hide or show
// there is still data from a stopped show/hide // and we are going to proceed with show, we should pretend to be hidden
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true; hidden = true;
// Ignore all other no-op show/hide data
} else { } else {
continue; continue;
} }
} }
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
}
// Bail out if this is a no-op like .hide().hide() // Any non-fx value stops us from restoring the original display value
propTween = !jQuery.isEmptyObject( props ); } else {
if ( !propTween && jQuery.isEmptyObject( orig ) ) { display = undefined;
return; }
} }
// Restrict "overflow" and "display" styles during box animations if ( !jQuery.isEmptyObject( orig ) ) {
if ( isBox && elem.nodeType === 1 ) { if ( dataShow ) {
// Support: IE 9 - 11 if ( "hidden" in dataShow ) {
// Record all 3 overflow attributes because IE does not infer the shorthand hidden = dataShow.hidden;
// from identically-valued overflowX and overflowY }
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; } else {
dataShow = jQuery._data( elem, "fxshow", {} );
}
// Identify a display type, preferring old show/hide data over the CSS cascade // store state if its toggle - enables .stop().toggle() to "reverse"
restoreDisplay = dataShow && dataShow.display; if ( toggle ) {
if ( restoreDisplay == null ) { dataShow.hidden = !hidden;
restoreDisplay = dataPriv.get( elem, "display" );
} }
display = jQuery.css( elem, "display" ); if ( hidden ) {
if ( display === "none" ) { jQuery( elem ).show();
display = restoreDisplay || swap( elem, { "display": "" }, function() { } else {
return jQuery.css( elem, "display" ); anim.done( function() {
jQuery( elem ).hide();
} ); } );
} }
anim.done( function() {
// Animate inline elements as inline-block var prop;
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { jQuery._removeData( elem, "fxshow" );
if ( jQuery.css( elem, "float" ) === "none" ) { for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
// Restore the original display value at the end of pure show/hide animations
if ( !propTween ) {
anim.done(function() {
style.display = restoreDisplay;
});
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
}
}
style.display = "inline-block";
} }
} } );
} for ( prop in orig ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( opts.overflow ) {
style.overflow = "hidden"; if ( !( prop in dataShow ) ) {
anim.always(function() { dataShow[ prop ] = tween.start;
style.overflow = opts.overflow[ 0 ]; if ( hidden ) {
style.overflowX = opts.overflow[ 1 ]; tween.end = tween.start;
style.overflowY = opts.overflow[ 2 ]; tween.start = prop === "width" || prop === "height" ? 1 : 0;
});
}
// Implement show/hide animations
propTween = false;
for ( prop in orig ) {
// General show/hide setup for this element animation
if ( !propTween ) {
if ( dataShow ) {
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
} }
} else {
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
}
// Store hidden/visible for toggle so `.stop().toggle()` "reverses"
if ( toggle ) {
dataShow.hidden = !hidden;
}
// Show elements before animating them
if ( hidden ) {
showHide( [ elem ], true );
} }
/* jshint -W083 */
anim.done(function() {
// 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 ] );
}
});
} }
// Per-property setup // If this is a noop like .hide().hide(), restore an overwritten display value
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
if ( !( prop in dataShow ) ) { style.display = display;
dataShow[ prop ] = propTween.start;
if ( hidden ) {
propTween.end = propTween.start;
propTween.start = prop === "width" || prop === "height" ? 1 : 0;
}
}
} }
} }
...@@ -257,8 +234,8 @@ function propFilter( props, specialEasing ) { ...@@ -257,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 ];
...@@ -277,15 +254,17 @@ function Animation( elem, properties, options ) { ...@@ -277,15 +254,17 @@ function Animation( elem, properties, options ) {
index = 0, index = 0,
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() {
if ( stopped ) { if ( stopped ) {
return false; return false;
} }
var currentTime = fxNow || createFxNow(), var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 // Support: Android 2.3
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
...@@ -297,7 +276,7 @@ function Animation( elem, properties, options ) { ...@@ -297,7 +276,7 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
} }
deferred.notifyWith( elem, [ animation, percent, remaining ]); deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) { if ( percent < 1 && length ) {
return remaining; return remaining;
...@@ -306,7 +285,7 @@ function Animation( elem, properties, options ) { ...@@ -306,7 +285,7 @@ function Animation( elem, properties, options ) {
return false; return false;
} }
}, },
animation = deferred.promise({ animation = deferred.promise( {
elem: elem, elem: elem,
props: jQuery.extend( {}, properties ), props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, { opts: jQuery.extend( true, {
...@@ -326,7 +305,8 @@ function Animation( elem, properties, options ) { ...@@ -326,7 +305,8 @@ 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 ) {
...@@ -337,15 +317,17 @@ function Animation( elem, properties, options ) { ...@@ -337,15 +317,17 @@ 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.resolveWith( elem, [ animation, gotoEnd ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else { } else {
deferred.rejectWith( elem, [ animation, gotoEnd ] ); deferred.rejectWith( elem, [ animation, gotoEnd ] );
} }
return this; return this;
} }
}), } ),
props = animation.props; props = animation.props;
propFilter( props, animation.opts.specialEasing ); propFilter( props, animation.opts.specialEasing );
...@@ -372,7 +354,7 @@ function Animation( elem, properties, options ) { ...@@ -372,7 +354,7 @@ function Animation( elem, properties, options ) {
elem: elem, elem: elem,
anim: animation, anim: animation,
queue: animation.opts.queue queue: animation.opts.queue
}) } )
); );
// attach callbacks from options // attach callbacks from options
...@@ -420,7 +402,7 @@ jQuery.Animation = jQuery.extend( Animation, { ...@@ -420,7 +402,7 @@ jQuery.Animation = jQuery.extend( Animation, {
Animation.prefilters.push( callback ); Animation.prefilters.push( callback );
} }
} }
}); } );
jQuery.speed = function( speed, easing, fn ) { jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
...@@ -430,17 +412,11 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -430,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";
} }
...@@ -461,24 +437,25 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -461,24 +437,25 @@ jQuery.speed = function( speed, easing, fn ) {
return opt; return opt;
}; };
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 ) {
var empty = jQuery.isEmptyObject( prop ), var empty = jQuery.isEmptyObject( prop ),
optall = jQuery.speed( speed, easing, callback ), optall = jQuery.speed( speed, easing, callback ),
doAnimation = function() { doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost // Operate on a copy of prop so per-property easing won't be lost
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 );
} }
}; };
...@@ -504,11 +481,11 @@ jQuery.fn.extend({ ...@@ -504,11 +481,11 @@ jQuery.fn.extend({
this.queue( type || "fx", [] ); this.queue( type || "fx", [] );
} }
return this.each(function() { return this.each( function() {
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 ) {
...@@ -524,7 +501,7 @@ jQuery.fn.extend({ ...@@ -524,7 +501,7 @@ jQuery.fn.extend({
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && if ( timers[ index ].elem === this &&
(type == null || timers[ index ].queue === type) ) { ( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd ); timers[ index ].anim.stop( gotoEnd );
dequeue = false; dequeue = false;
...@@ -532,37 +509,37 @@ jQuery.fn.extend({ ...@@ -532,37 +509,37 @@ 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 );
} }
}); } );
}, },
finish: function( type ) { finish: function( type ) {
if ( type !== false ) { if ( type !== false ) {
type = type || "fx"; type = type || "fx";
} }
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 );
...@@ -570,33 +547,33 @@ jQuery.fn.extend({ ...@@ -570,33 +547,33 @@ 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;
}); } );
} }
}); } );
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ]; var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
return speed == null || typeof speed === "boolean" ? return speed == null || typeof speed === "boolean" ?
cssFn.apply( this, arguments ) : cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback ); this.animate( genFx( name, true ), speed, easing, callback );
}; };
}); } );
// Generate shortcuts for custom animations // Generate shortcuts for custom animations
jQuery.each({ jQuery.each( {
slideDown: genFx("show"), slideDown: genFx( "show" ),
slideUp: genFx("hide"), slideUp: genFx( "hide" ),
slideToggle: genFx("toggle"), slideToggle: genFx( "toggle" ),
fadeIn: { opacity: "show" }, fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" }, fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" } fadeToggle: { opacity: "toggle" }
...@@ -604,18 +581,19 @@ jQuery.each({ ...@@ -604,18 +581,19 @@ jQuery.each({
jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
return this.animate( props, speed, easing, callback ); return this.animate( props, speed, easing, callback );
}; };
}); } );
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();
for ( ; i < timers.length; i++ ) { for ( ; i < timers.length; i++ ) {
timer = timers[ i ]; timer = timers[ i ];
// Checks the timer has not already been removed // Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) { if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 ); timers.splice( i--, 1 );
...@@ -638,30 +616,25 @@ jQuery.fx.timer = function( timer ) { ...@@ -638,30 +616,25 @@ 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;
}; };
jQuery.fx.speeds = { jQuery.fx.speeds = {
slow: 600, slow: 600,
fast: 200, fast: 200,
// Default speed // Default speed
_default: 400 _default: 400
}; };
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"../css" "../css"
], function( jQuery ) { ], function( jQuery ) {
...@@ -66,18 +66,19 @@ Tween.propHooks = { ...@@ -66,18 +66,19 @@ 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.
return !result || result === "auto" ? 0 : result; return !result || result === "auto" ? 0 : result;
}, },
set: function( tween ) { set: function( tween ) {
// Use step hook for back compat.
// Use cssHook if its there. // use step hook for back compat - use cssHook if its there - use .style if its
// Use .style if available and use plain properties where available. // 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 &&
...@@ -91,8 +92,9 @@ Tween.propHooks = { ...@@ -91,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 ) {
...@@ -116,4 +118,4 @@ jQuery.fx = Tween.prototype.init; ...@@ -116,4 +118,4 @@ jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point // Back Compat <1.8 extension point
jQuery.fx.step = {}; jQuery.fx.step = {};
}); } );
define([ define( [
"../core", "../core",
"../selector", "../selector",
"../effects" "../effects"
], function( jQuery ) { ], function( jQuery ) {
jQuery.expr.filters.animated = function( elem ) { jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function( fn ) { return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem; return elem === fn.elem;
}).length; } ).length;
}; };
}); } );
define( [
"../var/support",
"../var/document"
], function( support, document ) {
( function() {
var shrinkWrapBlocksVal;
support.shrinkWrapBlocks = function() {
if ( shrinkWrapBlocksVal != null ) {
return shrinkWrapBlocksVal;
}
// Will be changed later if needed.
shrinkWrapBlocksVal = false;
// Minified: var b,c,d
var div, body, container;
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body || !body.style ) {
// Test fired too early or in an unsupported environment, exit.
return;
}
// Setup
div = document.createElement( "div" );
container = document.createElement( "div" );
container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
body.appendChild( container ).appendChild( div );
// Support: IE6
// Check if elements with layout shrink-wrap their children
if ( typeof div.style.zoom !== "undefined" ) {
// Reset CSS: box-sizing; display; margin; border
div.style.cssText =
// Support: Firefox<29, 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:1px;width:1px;zoom:1";
div.appendChild( document.createElement( "div" ) ).style.width = "5px";
shrinkWrapBlocksVal = div.offsetWidth !== 3;
}
body.removeChild( container );
return shrinkWrapBlocksVal;
};
} )();
return support;
} );
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
"./var/hasOwn", "./var/hasOwn",
"./var/slice", "./var/slice",
"./event/support", "./event/support",
"./data/var/dataPriv", "./data/var/acceptData",
"./core/init", "./core/init",
"./data/accepts", "./data",
"./selector" "./selector"
], function( jQuery, document, rnotwhite, hasOwn, slice, support, 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)$/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
...@@ -39,8 +39,10 @@ function on( elem, types, selector, data, fn, one ) { ...@@ -39,8 +39,10 @@ function on( elem, types, selector, data, fn, one ) {
// Types can be a map of types/handlers // Types can be a map of types/handlers
if ( typeof types === "object" ) { if ( typeof types === "object" ) {
// ( types-Object, selector, data ) // ( types-Object, selector, data )
if ( typeof selector !== "string" ) { if ( typeof selector !== "string" ) {
// ( types-Object, data ) // ( types-Object, data )
data = data || selector; data = data || selector;
selector = undefined; selector = undefined;
...@@ -52,15 +54,18 @@ function on( elem, types, selector, data, fn, one ) { ...@@ -52,15 +54,18 @@ function on( elem, types, selector, data, fn, one ) {
} }
if ( data == null && fn == null ) { if ( data == null && fn == null ) {
// ( types, fn ) // ( types, fn )
fn = selector; fn = selector;
data = selector = undefined; data = selector = undefined;
} else if ( fn == null ) { } else if ( fn == null ) {
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
// ( types, selector, fn ) // ( types, selector, fn )
fn = data; fn = data;
data = undefined; data = undefined;
} else { } else {
// ( types, data, fn ) // ( types, data, fn )
fn = data; fn = data;
data = selector; data = selector;
...@@ -69,21 +74,25 @@ function on( elem, types, selector, data, fn, one ) { ...@@ -69,21 +74,25 @@ 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 ) {
origFn = fn; origFn = fn;
fn = function( event ) { fn = function( event ) {
// Can use an empty set, since event contains the info // Can use an empty set, since event contains the info
jQuery().off( event ); jQuery().off( event );
return origFn.apply( this, arguments ); return origFn.apply( this, arguments );
}; };
// Use same guid so caller can remove using origFn // Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
} }
return elem.each( function() { return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector ); jQuery.event.add( this, types, fn, data, selector );
}); } );
} }
/* /*
...@@ -95,11 +104,10 @@ jQuery.event = { ...@@ -95,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 ) {
...@@ -119,25 +127,32 @@ jQuery.event = { ...@@ -119,25 +127,32 @@ jQuery.event = {
} }
// Init the element's event structure and main handler, if this is the first // Init the element's event structure and main handler, if this is the first
if ( !(events = elemData.events) ) { if ( !( events = elemData.events ) ) {
events = elemData.events = {}; events = elemData.events = {};
} }
if ( !(eventHandle = elemData.handle) ) { if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) { eventHandle = elemData.handle = function( e ) {
// 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
types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length; t = types.length;
while ( t-- ) { while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[1]; type = origType = tmp[ 1 ];
namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// There *must* be a type, no attaching namespace-only handlers // There *must* be a type, no attaching namespace-only handlers
if ( !type ) { if ( !type ) {
...@@ -154,7 +169,7 @@ jQuery.event = { ...@@ -154,7 +169,7 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers // handleObj is passed to all event handlers
handleObj = jQuery.extend({ handleObj = jQuery.extend( {
type: type, type: type,
origType: origType, origType: origType,
data: data, data: data,
...@@ -162,20 +177,24 @@ jQuery.event = { ...@@ -162,20 +177,24 @@ jQuery.event = {
guid: handler.guid, guid: handler.guid,
selector: selector, selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ), needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".") namespace: namespaces.join( "." )
}, handleObjIn ); }, handleObjIn );
// Init the event handler queue if we're the first // Init the event handler queue if we're the first
if ( !(handlers = events[ type ]) ) { if ( !( handlers = events[ type ] ) ) {
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 );
} }
} }
} }
...@@ -199,17 +218,19 @@ jQuery.event = { ...@@ -199,17 +218,19 @@ 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,
origCount, t, events,
special, handlers, type,
namespaces, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
var j, origCount, tmp, if ( !elemData || !( events = elemData.events ) ) {
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
if ( !elemData || !(events = elemData.events) ) {
return; return;
} }
...@@ -217,9 +238,9 @@ jQuery.event = { ...@@ -217,9 +238,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length; t = types.length;
while ( t-- ) { while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[1]; type = origType = tmp[ 1 ];
namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element // Unbind all events (on this namespace, if provided) for the element
if ( !type ) { if ( !type ) {
...@@ -232,7 +253,8 @@ jQuery.event = { ...@@ -232,7 +253,8 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type; type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || []; handlers = events[ type ] || [];
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
// Remove matching events // Remove matching events
origCount = j = handlers.length; origCount = j = handlers.length;
...@@ -268,18 +290,22 @@ jQuery.event = { ...@@ -268,18 +290,22 @@ 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 ) { trigger: function( event, data, elem, onlyHandlers ) {
var handle, ontype, cur,
var i, cur, tmp, bubbleType, ontype, handle, special, bubbleType, special, tmp, i,
eventPath = [ elem || document ], eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event, type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = tmp = elem = elem || document; cur = tmp = elem = elem || document;
...@@ -293,13 +319,14 @@ jQuery.event = { ...@@ -293,13 +319,14 @@ jQuery.event = {
return; return;
} }
if ( type.indexOf(".") > -1 ) { if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle() // Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split("."); namespaces = type.split( "." );
type = namespaces.shift(); type = namespaces.shift();
namespaces.sort(); namespaces.sort();
} }
ontype = type.indexOf(":") < 0 && "on" + type; ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string // Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ? event = event[ jQuery.expando ] ?
...@@ -308,9 +335,9 @@ jQuery.event = { ...@@ -308,9 +335,9 @@ jQuery.event = {
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3; event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join("."); event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ? event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null; null;
// Clean up the event in case it is being reused // Clean up the event in case it is being reused
...@@ -344,29 +371,30 @@ jQuery.event = { ...@@ -344,29 +371,30 @@ jQuery.event = {
} }
// Only add window if we got to document (e.g., not plain obj or detached DOM) // Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === (elem.ownerDocument || document) ) { if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window ); eventPath.push( tmp.defaultView || tmp.parentWindow || window );
} }
} }
// Fire handlers on the event path // Fire handlers on the event path
i = 0; i = 0;
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
event.type = i > 1 ? event.type = i > 1 ?
bubbleType : bubbleType :
special.bindType || type; special.bindType || type;
// jQuery handler // jQuery handler
handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
dataPriv.get( cur, "handle" ); jQuery._data( cur, "handle" );
if ( handle ) { if ( handle ) {
handle.apply( cur, data ); handle.apply( cur, data );
} }
// Native handler // Native handler
handle = ontype && cur[ ontype ]; handle = ontype && cur[ ontype ];
if ( handle && handle.apply && jQuery.acceptData( cur ) ) { if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data ); event.result = handle.apply( cur, data );
if ( event.result === false ) { if ( event.result === false ) {
event.preventDefault(); event.preventDefault();
...@@ -378,12 +406,16 @@ jQuery.event = { ...@@ -378,12 +406,16 @@ jQuery.event = {
// If nobody prevented the default action, do it now // If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) { if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && if (
jQuery.acceptData( elem ) ) { ( !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. // 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) // Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method // Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ]; tmp = elem[ ontype ];
...@@ -394,7 +426,13 @@ jQuery.event = { ...@@ -394,7 +426,13 @@ jQuery.event = {
// Prevent re-triggering of the same event, since we already bubbled it above // Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type; jQuery.event.triggered = type;
elem[ 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; jQuery.event.triggered = undefined;
if ( tmp ) { if ( tmp ) {
...@@ -415,11 +453,11 @@ jQuery.event = { ...@@ -415,11 +453,11 @@ 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
args[0] = event; args[ 0 ] = event;
event.delegateTarget = this; event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired // Call the preDispatch hook for the mapped type, and let it bail if desired
...@@ -432,11 +470,11 @@ jQuery.event = { ...@@ -432,11 +470,11 @@ jQuery.event = {
// Run delegates first; they may want to stop propagation beneath us // Run delegates first; they may want to stop propagation beneath us
i = 0; i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem; event.currentTarget = matched.elem;
j = 0; j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) { !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or 2) have namespace(s) // Triggered event must either 1) have no namespace, or 2) have namespace(s)
...@@ -446,11 +484,11 @@ jQuery.event = { ...@@ -446,11 +484,11 @@ jQuery.event = {
event.handleObj = handleObj; event.handleObj = handleObj;
event.data = handleObj.data; event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args ); handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) { if ( ret !== undefined ) {
if ( (event.result = ret) === false ) { if ( ( event.result = ret ) === false ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
...@@ -477,14 +515,18 @@ jQuery.event = { ...@@ -477,14 +515,18 @@ jQuery.event = {
// Find delegate handlers // Find delegate handlers
// Black-hole SVG <use> instance trees (#13180) // Black-hole SVG <use> instance trees (#13180)
// //
// Support: Firefox // Support: Firefox<=42+
// Avoid non-left-click bubbling in Firefox (#3861) // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { if ( delegateCount && cur.nodeType &&
( 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 process clicks on disabled elements (#6911, #8165, #11382, #11764) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
if ( cur.disabled !== true || event.type !== "click" ) { if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
matches = []; matches = [];
for ( i = 0; i < delegateCount; i++ ) { for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ]; handleObj = handlers[ i ];
...@@ -502,7 +544,7 @@ jQuery.event = { ...@@ -502,7 +544,7 @@ jQuery.event = {
} }
} }
if ( matches.length ) { if ( matches.length ) {
handlerQueue.push({ elem: cur, handlers: matches }); handlerQueue.push( { elem: cur, handlers: matches } );
} }
} }
} }
...@@ -510,20 +552,66 @@ jQuery.event = { ...@@ -510,20 +552,66 @@ jQuery.event = {
// Add the remaining (directly-bound) handlers // Add the remaining (directly-bound) handlers
if ( delegateCount < handlers.length ) { if ( delegateCount < handlers.length ) {
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
} }
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( " " ),
fixHooks: {}, fixHooks: {},
keyHooks: { keyHooks: {
props: "char charCode key keyCode".split(" "), props: "char charCode key keyCode".split( " " ),
filter: function( event, original ) { filter: function( event, original ) {
// Add which for key events // Add which for key events
...@@ -536,11 +624,12 @@ jQuery.event = { ...@@ -536,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 ) {
...@@ -556,6 +645,13 @@ jQuery.event = { ...@@ -556,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 ) {
...@@ -566,53 +662,26 @@ jQuery.event = { ...@@ -566,53 +662,26 @@ 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.0+
// 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: {
// Prevent triggered image.load events from bubbling to window.load // Prevent triggered image.load events from bubbling to window.load
noBubble: true noBubble: true
}, },
focus: { focus: {
// 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"
...@@ -627,9 +696,10 @@ jQuery.event = { ...@@ -627,9 +696,10 @@ jQuery.event = {
delegateType: "focusout" delegateType: "focusout"
}, },
click: { click: {
// 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;
} }
...@@ -661,18 +731,15 @@ jQuery.event = { ...@@ -661,18 +731,15 @@ jQuery.event = {
{ {
type: type, type: type,
isSimulated: true isSimulated: true
// Previously, `originalEvent: {}` was set here, so stopPropagation call // Previously, `originalEvent: {}` was set here, so stopPropagation call
// would not be triggered on donor event, since in our own // would not be triggered on donor event, since in our own
// jQuery.event.stopPropagation function we had a check for existence of // jQuery.event.stopPropagation function we had a check for existence of
// originalEvent.stopPropagation method, so, consequently it would be a noop. // originalEvent.stopPropagation method, so, consequently it would be a noop.
// //
// But now, this "simulate" function is used only for events // Guard for simulated events was moved to jQuery.event.stopPropagation function
// for which stopPropagation() is noop, so there is no need for that anymore. // since `originalEvent` should point to the original event for the
// // constancy with other events and for more focused logic
// For the compat branch though, guard for "click" and "submit"
// events is still used, but was moved to jQuery.event.stopPropagation function
// because `originalEvent` should point to the original event for the constancy
// with other events and for more focused logic
} }
); );
...@@ -684,17 +751,34 @@ jQuery.event = { ...@@ -684,17 +751,34 @@ jQuery.event = {
} }
}; };
jQuery.removeEvent = function( elem, type, handle ) { jQuery.removeEvent = document.removeEventListener ?
function( elem, type, handle ) {
// This "if" is needed for plain objects // This "if" is needed for plain objects
if ( elem.removeEventListener ) { if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle ); 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
if ( !(this instanceof jQuery.Event) ) { if ( !( this instanceof jQuery.Event ) ) {
return new jQuery.Event( src, props ); return new jQuery.Event( src, props );
} }
...@@ -707,7 +791,8 @@ jQuery.Event = function( src, props ) { ...@@ -707,7 +791,8 @@ jQuery.Event = function( src, props ) {
// by a handler lower down the tree; reflect the correct value. // by a handler lower down the tree; reflect the correct value.
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;
...@@ -741,9 +826,18 @@ jQuery.Event.prototype = { ...@@ -741,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() {
...@@ -751,16 +845,25 @@ jQuery.Event.prototype = { ...@@ -751,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();
} }
...@@ -772,14 +875,11 @@ jQuery.Event.prototype = { ...@@ -772,14 +875,11 @@ jQuery.Event.prototype = {
// so that event delegation works in jQuery. // so that event delegation works in jQuery.
// Do the same for pointerenter/pointerleave and pointerover/pointerout // Do the same for pointerenter/pointerleave and pointerover/pointerout
// //
// Support: Safari<7.0 // Support: Safari 7 only
// Safari doesn't support mouseenter/mouseleave at all. // Safari sends mouseenter too often; see:
// // https://code.google.com/p/chromium/issues/detail?id=470258
// Support: Chrome 34+ // for the description of the bug (it existed in older Chrome versions as well).
// Mouseenter doesn't perform while left mouse button is pressed jQuery.each( {
// (and initiated outside the observed element)
// https://code.google.com/p/chromium/issues/detail?id=333868
jQuery.each({
mouseenter: "mouseover", mouseenter: "mouseover",
mouseleave: "mouseout", mouseleave: "mouseout",
pointerenter: "pointerover", pointerenter: "pointerover",
...@@ -795,9 +895,9 @@ jQuery.each({ ...@@ -795,9 +895,9 @@ jQuery.each({
related = event.relatedTarget, related = event.relatedTarget,
handleObj = event.handleObj; handleObj = event.handleObj;
// For mousenter/leave call the handler if related is outside the target. // For mouseenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window // NB: No relatedTarget if the mouse left/entered the browser window
if ( !related || (related !== target && !jQuery.contains( target, related )) ) { if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
event.type = handleObj.origType; event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments ); ret = handleObj.handler.apply( this, arguments );
event.type = fix; event.type = fix;
...@@ -805,7 +905,131 @@ jQuery.each({ ...@@ -805,7 +905,131 @@ jQuery.each({
return ret; return ret;
} }
}; };
}); } );
// 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 // Support: Firefox
// Firefox doesn't have focus(in | out) events // Firefox doesn't have focus(in | out) events
...@@ -816,7 +1040,7 @@ jQuery.each({ ...@@ -816,7 +1040,7 @@ jQuery.each({
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order // 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 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) { if ( !support.focusin ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout // Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) { var handler = function( event ) {
...@@ -826,30 +1050,29 @@ if ( !support.focusin ) { ...@@ -826,30 +1050,29 @@ if ( !support.focusin ) {
jQuery.event.special[ fix ] = { jQuery.event.special[ fix ] = {
setup: function() { setup: function() {
var doc = this.ownerDocument || this, var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix ); attaches = jQuery._data( doc, fix );
if ( !attaches ) { if ( !attaches ) {
doc.addEventListener( orig, handler, true ); doc.addEventListener( orig, handler, true );
} }
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
}, },
teardown: function() { teardown: function() {
var doc = this.ownerDocument || this, var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix ) - 1; attaches = jQuery._data( doc, fix ) - 1;
if ( !attaches ) { if ( !attaches ) {
doc.removeEventListener( orig, handler, true ); doc.removeEventListener( orig, handler, true );
dataPriv.remove( doc, fix ); jQuery._removeData( doc, fix );
} else { } else {
dataPriv.access( doc, fix, attaches ); jQuery._data( doc, fix, attaches );
} }
} }
}; };
}); } );
} }
jQuery.fn.extend({ jQuery.fn.extend( {
on: function( types, selector, data, fn ) { on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn ); return on( this, types, selector, data, fn );
...@@ -860,6 +1083,7 @@ jQuery.fn.extend({ ...@@ -860,6 +1083,7 @@ jQuery.fn.extend({
off: function( types, selector, fn ) { off: function( types, selector, fn ) {
var handleObj, type; var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) { if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event // ( event ) dispatched jQuery.Event
handleObj = types.handleObj; handleObj = types.handleObj;
jQuery( types.delegateTarget ).off( jQuery( types.delegateTarget ).off(
...@@ -872,6 +1096,7 @@ jQuery.fn.extend({ ...@@ -872,6 +1096,7 @@ jQuery.fn.extend({
return this; return this;
} }
if ( typeof types === "object" ) { if ( typeof types === "object" ) {
// ( types-object [, selector] ) // ( types-object [, selector] )
for ( type in types ) { for ( type in types ) {
this.off( type, selector, types[ type ] ); this.off( type, selector, types[ type ] );
...@@ -879,6 +1104,7 @@ jQuery.fn.extend({ ...@@ -879,6 +1104,7 @@ jQuery.fn.extend({
return this; return this;
} }
if ( selector === false || typeof selector === "function" ) { if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] ) // ( types [, fn] )
fn = selector; fn = selector;
selector = undefined; selector = undefined;
...@@ -886,23 +1112,23 @@ jQuery.fn.extend({ ...@@ -886,23 +1112,23 @@ jQuery.fn.extend({
if ( fn === false ) { if ( fn === false ) {
fn = returnFalse; fn = returnFalse;
} }
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 ) { trigger: function( type, data ) {
return this.each(function() { return this.each( function() {
jQuery.event.trigger( type, data, this ); jQuery.event.trigger( type, data, this );
}); } );
}, },
triggerHandler: function( type, data ) { triggerHandler: function( type, data ) {
var elem = this[0]; var elem = this[ 0 ];
if ( elem ) { if ( elem ) {
return jQuery.event.trigger( type, data, elem, true ); return jQuery.event.trigger( type, data, elem, true );
} }
} }
}); } );
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"../event" "../event"
], function( jQuery ) { ], function( jQuery ) {
// Attach a bunch of functions for handling common AJAX events // Attach a bunch of functions for handling common AJAX events
jQuery.each([ jQuery.each( [
"ajaxStart", "ajaxStart",
"ajaxStop", "ajaxStop",
"ajaxComplete", "ajaxComplete",
...@@ -15,6 +15,6 @@ jQuery.each([ ...@@ -15,6 +15,6 @@ jQuery.each([
jQuery.fn[ type ] = function( fn ) { jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn ); return this.on( type, fn );
}; };
}); } );
}); } );
define([ define( [
"../core", "../core",
"../event" "../event"
], 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
...@@ -14,29 +14,12 @@ jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " + ...@@ -14,29 +14,12 @@ jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " +
this.on( name, null, data, fn ) : this.on( name, null, data, fn ) :
this.trigger( name ); this.trigger( name );
}; };
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
hover: function( fnOver, fnOut ) { hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
} }
}); } );
}); } );
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;
}); } );
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
...@@ -18,7 +18,7 @@ define([ ...@@ -18,7 +18,7 @@ define([
if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() { define( "jquery", [], function() {
return jQuery; return jQuery;
}); } );
} }
}); } );
var var
// Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
_jQuery = window.jQuery, _jQuery = window.jQuery,
...@@ -17,8 +18,8 @@ jQuery.noConflict = function( deep ) { ...@@ -17,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;
......
define([ define( [
"./core", "./core",
"./selector", "./selector",
"./traversing", "./traversing",
"./callbacks", "./callbacks",
"./deferred", "./deferred",
"./core/ready", "./core/ready",
"./support",
"./data", "./data",
"./queue", "./queue",
"./queue/delay", "./queue/delay",
...@@ -31,6 +32,6 @@ define([ ...@@ -31,6 +32,6 @@ define([
"./exports/amd" "./exports/amd"
], function( jQuery ) { ], function( jQuery ) {
return (window.jQuery = window.$ = jQuery); return ( window.jQuery = window.$ = jQuery );
}); } );
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/acceptData",
"./data/var/dataPriv",
"./data/var/dataUser",
"./core/init", "./core/init",
"./data/accepts",
"./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 ) { buildFragment, support, acceptData ) {
var var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
rnoInnerhtml = /<(?:script|style|link)/i,
// Support: IE 10-11, Edge 10240+
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
rnoInnerhtml = /<script|<style|<link/i,
// 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; elem.getElementsByTagName( "tbody" )[ 0 ] ||
} elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
elem;
return 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;
// Fails to persist the checked state of a cloned checkbox or radio button. // IE6-7 get confused and end up setting the value of a cloned
if ( nodeName === "input" && rcheckableType.test( src.type ) ) { // checkbox/radio button to an empty string instead of "on"
dest.checked = src.checked; if ( dest.value !== src.value ) {
dest.value = src.value;
}
// IE6-8 fails to return the selected option to the default selected
// state when cloning options
} 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;
} }
...@@ -113,7 +170,8 @@ function domManip( collection, args, callback, ignored ) { ...@@ -113,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,
...@@ -124,13 +182,13 @@ function domManip( collection, args, callback, ignored ) { ...@@ -124,13 +182,13 @@ function domManip( collection, args, callback, ignored ) {
if ( isFunction || if ( isFunction ||
( l > 1 && typeof value === "string" && ( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) { !support.checkClone && rchecked.test( value ) ) ) {
return collection.each(function( index ) { return collection.each( function( index ) {
var self = collection.eq( index ); var self = collection.eq( index );
if ( isFunction ) { if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() ); args[ 0 ] = value.call( this, index, self.html() );
} }
domManip( self, args, callback, ignored ); domManip( self, args, callback, ignored );
}); } );
} }
if ( l ) { if ( l ) {
...@@ -157,6 +215,7 @@ function domManip( collection, args, callback, ignored ) { ...@@ -157,6 +215,7 @@ function domManip( collection, args, callback, ignored ) {
// Keep references to cloned scripts for later restoration // Keep references to cloned scripts for later restoration
if ( hasScripts ) { if ( hasScripts ) {
// Support: Android<4.1, PhantomJS<2 // Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit // push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) ); jQuery.merge( scripts, getAll( node, "script" ) );
...@@ -176,20 +235,27 @@ function domManip( collection, args, callback, ignored ) { ...@@ -176,20 +235,27 @@ 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 ) {
// Optional AJAX dependency, but won't run scripts if not present // Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) { if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src ); jQuery._evalUrl( node.src );
} }
} else { } else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); jQuery.globalEval(
( node.text || node.textContent || node.innerHTML || "" )
.replace( rcleanScript, "" )
);
} }
} }
} }
} }
// Fix #11809: Avoid leaking memory
fragment = first = null;
} }
} }
...@@ -198,10 +264,11 @@ function domManip( collection, args, callback, ignored ) { ...@@ -198,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 ) );
} }
...@@ -217,26 +284,40 @@ function remove( elem, selector, keepData ) { ...@@ -217,26 +284,40 @@ function remove( elem, selector, keepData ) {
return elem; return elem;
} }
jQuery.extend({ jQuery.extend( {
htmlPrefilter: function( html ) { htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" ); return html.replace( rxhtmlTag, "<$1></$2>" );
}, },
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: http://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 ] );
}
} }
} }
...@@ -246,8 +327,8 @@ jQuery.extend({ ...@@ -246,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 );
...@@ -260,35 +341,71 @@ jQuery.extend({ ...@@ -260,35 +341,71 @@ 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 ];
if ( data ) {
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
}
// Remove cache only if it was not already removed by jQuery.event.remove
if ( cache[ id ] ) {
for ( ; (elem = elems[ i ]) !== undefined; i++ ) { delete cache[ id ];
if ( jQuery.acceptData( elem ) && (data = elem[ dataPriv.expando ])) {
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead // 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 );
// Webkit & Blink performance suffers when deleting properties
// from DOM nodes, so set to undefined instead
// https://code.google.com/p/chromium/issues/detail?id=378607
} else { } else {
jQuery.removeEvent( elem, type, data.handle ); elem[ internalKey ] = undefined;
} }
deletedIds.push( id );
} }
} }
delete elem[ dataPriv.expando ];
} }
} }
} }
}); } );
jQuery.fn.extend( {
// Keep domManip exposed until 3.0 (gh-2225)
domManip: domManip,
jQuery.fn.extend({
detach: function( selector ) { detach: function( selector ) {
return remove( this, selector, true ); return remove( this, selector, true );
}, },
...@@ -301,11 +418,9 @@ jQuery.fn.extend({ ...@@ -301,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 );
}, },
...@@ -315,7 +430,7 @@ jQuery.fn.extend({ ...@@ -315,7 +430,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.appendChild( elem ); target.appendChild( elem );
} }
}); } );
}, },
prepend: function() { prepend: function() {
...@@ -324,7 +439,7 @@ jQuery.fn.extend({ ...@@ -324,7 +439,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild ); target.insertBefore( elem, target.firstChild );
} }
}); } );
}, },
before: function() { before: function() {
...@@ -332,7 +447,7 @@ jQuery.fn.extend({ ...@@ -332,7 +447,7 @@ jQuery.fn.extend({
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
} }
}); } );
}, },
after: function() { after: function() {
...@@ -340,21 +455,29 @@ jQuery.fn.extend({ ...@@ -340,21 +455,29 @@ jQuery.fn.extend({
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
} }
}); } );
}, },
empty: function() { empty: function() {
var elem, var elem,
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;
} }
} }
...@@ -365,9 +488,9 @@ jQuery.fn.extend({ ...@@ -365,9 +488,9 @@ jQuery.fn.extend({
dataAndEvents = dataAndEvents == null ? false : dataAndEvents; dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map(function() { return this.map( function() {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
}); } );
}, },
html: function( value ) { html: function( value ) {
...@@ -376,21 +499,25 @@ jQuery.fn.extend({ ...@@ -376,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;
...@@ -426,9 +553,9 @@ jQuery.fn.extend({ ...@@ -426,9 +553,9 @@ jQuery.fn.extend({
// Force callback invocation // Force callback invocation
}, ignored ); }, ignored );
} }
}); } );
jQuery.each({ jQuery.each( {
appendTo: "append", appendTo: "append",
prependTo: "prepend", prependTo: "prepend",
insertBefore: "before", insertBefore: "before",
...@@ -437,23 +564,22 @@ jQuery.each({ ...@@ -437,23 +564,22 @@ 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() );
} }
return this.pushStack( ret ); return this.pushStack( ret );
}; };
}); } );
return jQuery; return jQuery;
}); } );
define([ define( [
"../ajax" "../ajax"
], function( jQuery ) { ], function( jQuery ) {
jQuery._evalUrl = function( url ) { jQuery._evalUrl = function( url ) {
return jQuery.ajax({ return jQuery.ajax( {
url: url, url: url,
// Make this explicit, since user can override this through ajaxSetup (#11264) // Make this explicit, since user can override this through ajaxSetup (#11264)
...@@ -13,9 +13,9 @@ jQuery._evalUrl = function( url ) { ...@@ -13,9 +13,9 @@ jQuery._evalUrl = function( url ) {
async: false, async: false,
global: false, global: false,
"throws": true "throws": true
}); } );
}; };
return jQuery._evalUrl; return jQuery._evalUrl;
}); } );
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,8 +39,6 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -23,8 +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
...@@ -33,11 +47,12 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -33,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
...@@ -46,21 +61,59 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -46,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 ) {
// Remember the top-level container // String was a <table>, *may* have spurious <tbody>
tmp = fragment.firstChild; elem = tag === "table" && !rtbody.test( elem ) ?
tmp.firstChild :
// Ensure the created nodes are orphaned (#12392) // String was a bare <thead> or <tfoot>
wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
tmp :
0;
j = elem && elem.childNodes.length;
while ( j-- ) {
if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
!tbody.childNodes.length ) {
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++ ] ) ) {
...@@ -70,13 +123,14 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -70,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 ) {
...@@ -94,8 +148,10 @@ function buildFragment( elems, context, scripts, selection, ignored ) { ...@@ -94,8 +148,10 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
} }
} }
return fragment; tmp = null;
return safe;
} }
return buildFragment; return buildFragment;
}); } );
define( [
"./var/nodeNames"
], function( nodeNames ) {
function createSafeFragment( document ) {
var list = nodeNames.split( "|" ),
safeFrag = document.createDocumentFragment();
if ( safeFrag.createElement ) {
while ( list.length ) {
safeFrag.createElement(
list.pop()
);
}
}
return safeFrag;
}
return createSafeFragment;
} );
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
function getAll( context, tag ) { function getAll( context, tag ) {
// Support: IE9-11+ var elems, elem,
// Use typeof to avoid zero-argument method invocation on host objects (#15151) i = 0,
var ret = typeof context.getElementsByTagName !== "undefined" ? found = 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" )
); );
} }
} }
return setGlobalEval; return setGlobalEval;
}); } );
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() {
return "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
"details|dialog|figcaption|figure|footer|header|hgroup|main|" +
"mark|meter|nav|output|picture|progress|section|summary|template|time|video";
} );
define(function() { define( function() {
return (/^(?:checkbox|radio)$/i); return ( /^(?:checkbox|radio)$/i );
}); } );
define( function() {
return ( /^\s+/ );
} );
define(function() { define( function() {
return ( /^$|\/(?:java|ecma)script/i ); return ( /^$|\/(?:java|ecma)script/i );
}); } );
define(function() { define( function() {
return ( /<([\w:-]+)/ ); 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>" ],
// Support: IE8
param: [ 1, "<object>", "</object>" ],
thead: [ 1, "<table>", "</table>" ], thead: [ 1, "<table>", "</table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
// Some of the following wrappers are not fully defined, because // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// their parent elements (except for "table" element) could be omitted // unless wrapped in a div with non-breaking characters in front of it.
// since browser parsers are smart enough to auto-insert them _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
// Support: Android 2.3
// Android browser doesn't auto-insert colgroup
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
// Auto-insert "tbody" element
tr: [ 2, "<table>", "</table>" ],
// Auto-insert "tbody" and "tr" elements
td: [ 3, "<table>", "</table>" ],
_default: [ 0, "", "" ]
}; };
// 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;
wrapMap.th = wrapMap.td; wrapMap.th = wrapMap.td;
return wrapMap; return wrapMap;
}); } );
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./var/document", "./var/document",
...@@ -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,54 +71,48 @@ jQuery.offset = { ...@@ -65,54 +71,48 @@ 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 );
} }
} }
}; };
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 :
this.each(function( i ) { this.each( function( i ) {
jQuery.offset.setOffset( this, options, i ); jQuery.offset.setOffset( this, options, i );
}); } );
} }
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() {
...@@ -121,16 +121,17 @@ jQuery.fn.extend({ ...@@ -121,16 +121,17 @@ 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
offset = elem.getBoundingClientRect();
// we assume that getBoundingClientRect is available when computed position is fixed
offset = elem.getBoundingClientRect();
} else { } else {
// Get *real* offsetParent // Get *real* offsetParent
offsetParent = this.offsetParent(); offsetParent = this.offsetParent();
...@@ -149,51 +150,45 @@ jQuery.fn.extend({ ...@@ -149,51 +150,45 @@ jQuery.fn.extend({
} }
// 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;
}); } );
} }
}); } );
// 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 {
...@@ -201,27 +196,27 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( ...@@ -201,27 +196,27 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
} }
}, method, val, arguments.length, null ); }, method, val, arguments.length, null );
}; };
}); } );
// Support: Safari<7+, Chrome<37+ // 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;
} }
} }
); );
}); } );
return jQuery; return jQuery;
}); } );
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 ) {
var queue; var queue;
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,18 +59,20 @@ jQuery.extend({ ...@@ -60,18 +59,20 @@ 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 );
}); } )
} );
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
queue: function( type, data ) { queue: function( type, data ) {
var setter = 2; var setter = 2;
...@@ -82,30 +83,31 @@ jQuery.fn.extend({ ...@@ -82,30 +83,31 @@ jQuery.fn.extend({
} }
if ( arguments.length < setter ) { if ( arguments.length < setter ) {
return jQuery.queue( this[0], type ); return jQuery.queue( this[ 0 ], type );
} }
return data === undefined ? return data === undefined ?
this : this :
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" ) {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
} }
}); } );
}, },
dequeue: function( type ) { dequeue: function( type ) {
return this.each(function() { return this.each( function() {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
}); } );
}, },
clearQueue: function( type ) { clearQueue: function( type ) {
return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
}, },
// Get a promise resolved when queues of a certain type // Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default) // are emptied (fx is the type by default)
promise: function( type, obj ) { promise: function( type, obj ) {
...@@ -127,7 +129,7 @@ jQuery.fn.extend({ ...@@ -127,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 );
...@@ -136,7 +138,7 @@ jQuery.fn.extend({ ...@@ -136,7 +138,7 @@ jQuery.fn.extend({
resolve(); resolve();
return defer.promise( obj ); return defer.promise( obj );
} }
}); } );
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"../queue", "../queue",
"../effects" // Delay is optional because of this dependency "../effects" // Delay is optional because of this dependency
...@@ -15,8 +15,8 @@ jQuery.fn.delay = function( time, type ) { ...@@ -15,8 +15,8 @@ jQuery.fn.delay = function( time, type ) {
hooks.stop = function() { hooks.stop = function() {
window.clearTimeout( timeout ); window.clearTimeout( timeout );
}; };
}); } );
}; };
return jQuery.fn.delay; return jQuery.fn.delay;
}); } );
define([ define( [
"./core", "./core",
"sizzle" "sizzle"
], function( jQuery, Sizzle ) { ], function( jQuery, Sizzle ) {
jQuery.find = Sizzle; jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors; jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos; jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText; jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML; jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains; jQuery.contains = Sizzle.contains;
}); } );
define([ "./selector-sizzle" ], function() {}); define( [ "./selector-sizzle" ], function() {} );
define([ define( [
"./core", "./core",
"./manipulation/var/rcheckableType", "./manipulation/var/rcheckableType",
"./core/init", "./core/init",
...@@ -16,30 +16,35 @@ function buildParams( prefix, obj, traditional, add ) { ...@@ -16,30 +16,35 @@ function buildParams( prefix, obj, traditional, add ) {
var name; var name;
if ( jQuery.isArray( obj ) ) { if ( jQuery.isArray( obj ) ) {
// Serialize array item. // Serialize array item.
jQuery.each( obj, function( i, v ) { jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) { if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar. // Treat each array item as a scalar.
add( prefix, v ); add( prefix, v );
} else { } else {
// Item is non-scalar (array or object), encode its numeric index. // Item is non-scalar (array or object), encode its numeric index.
buildParams( buildParams(
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
v, v,
traditional, traditional,
add add
); );
} }
}); } );
} else if ( !traditional && jQuery.type( obj ) === "object" ) { } else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item. // Serialize object item.
for ( name in obj ) { for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
} }
} else { } else {
// Serialize scalar item. // Serialize scalar item.
add( prefix, obj ); add( prefix, obj );
} }
...@@ -51,6 +56,7 @@ jQuery.param = function( a, traditional ) { ...@@ -51,6 +56,7 @@ jQuery.param = function( a, traditional ) {
var prefix, var prefix,
s = [], s = [],
add = function( key, value ) { add = function( key, value ) {
// If value is a function, invoke it and return its value // If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
...@@ -63,12 +69,14 @@ jQuery.param = function( a, traditional ) { ...@@ -63,12 +69,14 @@ jQuery.param = function( a, traditional ) {
// If an array was passed in, assume that it is an array of form elements. // If an array was passed in, assume that it is an array of form elements.
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements // Serialize the form elements
jQuery.each( a, function() { jQuery.each( a, function() {
add( this.name, this.value ); add( this.name, this.value );
}); } );
} else { } else {
// If traditional, encode the "old" way (the way 1.3.2 or older // If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively. // did it), otherwise encode params recursively.
for ( prefix in a ) { for ( prefix in a ) {
...@@ -80,25 +88,26 @@ jQuery.param = function( a, traditional ) { ...@@ -80,25 +88,26 @@ jQuery.param = function( a, traditional ) {
return s.join( "&" ).replace( r20, "+" ); return s.join( "&" ).replace( r20, "+" );
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
serialize: function() { serialize: function() {
return jQuery.param( this.serializeArray() ); return jQuery.param( this.serializeArray() );
}, },
serializeArray: function() { serializeArray: function() {
return this.map(function() { return this.map( function() {
// Can add propHook for "elements" to filter or add form elements // Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" ); var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this; return elements ? jQuery.makeArray( elements ) : this;
}) } )
.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 ) );
}) } )
.map(function( i, elem ) { .map( function( i, elem ) {
var val = jQuery( this ).val(); var val = jQuery( this ).val();
return val == null ? return val == null ?
...@@ -106,11 +115,11 @@ jQuery.fn.extend({ ...@@ -106,11 +115,11 @@ jQuery.fn.extend({
jQuery.isArray( val ) ? jQuery.isArray( val ) ?
jQuery.map( val, function( val ) { jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}) : } ) :
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}).get(); } ).get();
} }
}); } );
return jQuery; return jQuery;
}); } );
define( [
"./core",
"./var/support",
"./var/document",
"./core/init", // Needed for hasOwn support test
// This is listed as a dependency for build order, but it's still optional in builds
"./core/ready"
], function( jQuery, support, document ) {
// Support: IE<9
// Iteration over object's inherited properties before its own
var i;
for ( i in jQuery( support ) ) {
break;
}
support.ownFirst = i === "0";
// Note: most support tests are defined in their respective modules.
// false until the test is run
support.inlineBlockNeedsLayout = false;
// Execute ASAP in case we need to set body.style.zoom
jQuery( function() {
// Minified: var a,b,c,d
var val, div, body, container;
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body || !body.style ) {
// Return for frameset docs that don't have a body
return;
}
// Setup
div = document.createElement( "div" );
container = document.createElement( "div" );
container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
body.appendChild( container ).appendChild( div );
if ( typeof div.style.zoom !== "undefined" ) {
// Support: IE<8
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
if ( val ) {
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE from shrinking the body in IE 7 mode #12869
// Support: IE<8
body.style.zoom = 1;
}
}
body.removeChild( container );
} );
return support;
} );
define([ define( [
"./core", "./core",
"./var/indexOf", "./traversing/var/dir",
"./traversing/var/siblings",
"./traversing/var/rneedsContext", "./traversing/var/rneedsContext",
"./core/init", "./core/init",
"./traversing/findFilter", "./traversing/findFilter",
"./selector" "./selector"
], function( jQuery, indexOf, 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,
...@@ -16,48 +18,19 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/, ...@@ -16,48 +18,19 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
prev: true prev: true
}; };
jQuery.extend({ jQuery.fn.extend( {
dir: function( elem, dir, until ) {
var matched = [],
truncate = until !== undefined;
while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) {
break;
}
matched.push( elem );
}
}
return matched;
},
sibling: function( n, elem ) {
var matched = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
matched.push( n );
}
}
return matched;
}
});
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;
} }
} }
}); } );
}, },
closest: function( selectors, context ) { closest: function( selectors, context ) {
...@@ -70,14 +43,15 @@ jQuery.fn.extend({ ...@@ -70,14 +43,15 @@ jQuery.fn.extend({
0; 0;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments // Always skip document fragments
if ( cur.nodeType < 11 && (pos ? if ( cur.nodeType < 11 && ( pos ?
pos.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;
...@@ -88,7 +62,8 @@ jQuery.fn.extend({ ...@@ -88,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
...@@ -96,17 +71,16 @@ jQuery.fn.extend({ ...@@ -96,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 ) {
...@@ -119,26 +93,29 @@ jQuery.fn.extend({ ...@@ -119,26 +93,29 @@ jQuery.fn.extend({
addBack: function( selector ) { addBack: function( selector ) {
return this.add( selector == null ? return this.add( selector == null ?
this.prevObject : this.prevObject.filter(selector) this.prevObject : this.prevObject.filter( selector )
); );
} }
}); } );
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;
} }
jQuery.each({ jQuery.each( {
parent: function( elem ) { parent: function( elem ) {
var parent = elem.parentNode; var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null; return parent && parent.nodeType !== 11 ? parent : null;
}, },
parents: function( elem ) { parents: function( elem ) {
return jQuery.dir( elem, "parentNode" ); return dir( elem, "parentNode" );
}, },
parentsUntil: function( elem, i, until ) { parentsUntil: function( elem, i, until ) {
return jQuery.dir( elem, "parentNode", until ); return dir( elem, "parentNode", until );
}, },
next: function( elem ) { next: function( elem ) {
return sibling( elem, "nextSibling" ); return sibling( elem, "nextSibling" );
...@@ -147,53 +124,56 @@ jQuery.each({ ...@@ -147,53 +124,56 @@ jQuery.each({
return sibling( elem, "previousSibling" ); return sibling( elem, "previousSibling" );
}, },
nextAll: function( elem ) { nextAll: function( elem ) {
return jQuery.dir( elem, "nextSibling" ); return dir( elem, "nextSibling" );
}, },
prevAll: function( elem ) { prevAll: function( elem ) {
return jQuery.dir( elem, "previousSibling" ); return dir( elem, "previousSibling" );
}, },
nextUntil: function( elem, i, until ) { nextUntil: function( elem, i, until ) {
return jQuery.dir( elem, "nextSibling", until ); return dir( elem, "nextSibling", until );
}, },
prevUntil: function( elem, i, until ) { prevUntil: function( elem, i, until ) {
return jQuery.dir( elem, "previousSibling", until ); return dir( elem, "previousSibling", until );
}, },
siblings: function( elem ) { siblings: function( elem ) {
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); return siblings( ( elem.parentNode || {} ).firstChild, elem );
}, },
children: function( elem ) { children: function( elem ) {
return jQuery.sibling( 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 );
}; };
}); } );
return jQuery; return jQuery;
}); } );
define([ define( [
"../core", "../core",
"../var/indexOf", "../var/indexOf",
"./var/rneedsContext", "./var/rneedsContext",
...@@ -13,14 +13,14 @@ function winnow( elements, qualifier, not ) { ...@@ -13,14 +13,14 @@ function winnow( elements, qualifier, not ) {
return jQuery.grep( elements, function( elem, i ) { return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */ /* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not; return !!qualifier.call( elem, i, elem ) !== not;
}); } );
} }
if ( qualifier.nodeType ) { if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not; return ( elem === qualifier ) !== not;
}); } );
} }
...@@ -33,8 +33,8 @@ function winnow( elements, qualifier, not ) { ...@@ -33,8 +33,8 @@ function winnow( elements, qualifier, not ) {
} }
return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not; return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
}); } );
} }
jQuery.filter = function( expr, elems, not ) { jQuery.filter = function( expr, elems, not ) {
...@@ -48,37 +48,40 @@ jQuery.filter = function( expr, elems, not ) { ...@@ -48,37 +48,40 @@ jQuery.filter = function( expr, elems, not ) {
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1; return elem.nodeType === 1;
})); } ) );
}; };
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() {
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) { if ( jQuery.contains( self[ i ], this ) ) {
return true; return true;
} }
} }
}) ); } ) );
} }
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
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 ) );
}, },
not: function( selector ) { not: function( selector ) {
return this.pushStack( winnow(this, selector || [], true) ); return this.pushStack( winnow( this, selector || [], true ) );
}, },
is: function( selector ) { is: function( selector ) {
return !!winnow( return !!winnow(
...@@ -92,6 +95,6 @@ jQuery.fn.extend({ ...@@ -92,6 +95,6 @@ jQuery.fn.extend({
false false
).length; ).length;
} }
}); } );
}); } );
define( [
"../../core"
], function( jQuery ) {
return function( elem, dir, until ) {
var matched = [],
truncate = until !== undefined;
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) {
break;
}
matched.push( elem );
}
}
return matched;
};
} );
define([ define( [
"../../core", "../../core",
"../../selector" "../../selector"
], function( jQuery ) { ], function( jQuery ) {
return jQuery.expr.match.needsContext; return jQuery.expr.match.needsContext;
}); } );
define( function() {
return function( n, elem ) {
var matched = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
matched.push( n );
}
}
return matched;
};
} );
define(function() { define( function() {
// [[Class]] -> type pairs // [[Class]] -> type pairs
return {}; return {};
}); } );
define([ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.concat; return deletedIds.concat;
}); } );
define( function() {
return [];
} );
define(function() { define( function() {
return window.document; return window.document;
}); } );
define([ define( [
"./document" "./document"
], function( document ) { ], function( document ) {
return document.documentElement; return document.documentElement;
}); } );
define([ define( [
"./class2type" "./class2type"
], function( class2type ) { ], function( class2type ) {
return class2type.hasOwnProperty; return class2type.hasOwnProperty;
}); } );
define([ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.indexOf; return deletedIds.indexOf;
}); } );
define(function() { define( function() {
return (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; return ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
}); } );
define([ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.push; return deletedIds.push;
}); } );
define([ define( [
"../var/pnum" "../var/pnum"
], function( pnum ) { ], function( pnum ) {
return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
}); } );
define(function() { define( function() {
return (/\S+/g); return ( /\S+/g );
}); } );
define([ define( [
"./arr" "./deletedIds"
], function( arr ) { ], function( deletedIds ) {
return arr.slice; return deletedIds.slice;
}); } );
define(function() { define( function() {
// All support tests are defined in their respective modules. // All support tests are defined in their respective modules.
return {}; return {};
}); } );
define([ define( [
"./class2type" "./class2type"
], function( class2type ) { ], function( class2type ) {
return class2type.toString; return class2type.toString;
}); } );
define([ define( [
"./core", "./core",
"./core/init", "./core/init",
"./manipulation", // clone "./manipulation", // clone
"./traversing" // parent, contents "./traversing" // parent, contents
], function( jQuery ) { ], function( jQuery ) {
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 ] );
} }
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;
}).append( this ); } ).append( this );
} }
return this; return this;
...@@ -37,12 +38,12 @@ jQuery.fn.extend({ ...@@ -37,12 +38,12 @@ jQuery.fn.extend({
wrapInner: function( html ) { wrapInner: function( html ) {
if ( jQuery.isFunction( html ) ) { if ( jQuery.isFunction( html ) ) {
return this.each(function( i ) { return this.each( function( i ) {
jQuery( this ).wrapInner( html.call(this, i) ); jQuery( this ).wrapInner( html.call( this, i ) );
}); } );
} }
return this.each(function() { return this.each( function() {
var self = jQuery( this ), var self = jQuery( this ),
contents = self.contents(); contents = self.contents();
...@@ -52,24 +53,25 @@ jQuery.fn.extend({ ...@@ -52,24 +53,25 @@ jQuery.fn.extend({
} else { } else {
self.append( html ); self.append( html );
} }
}); } );
}, },
wrap: function( html ) { wrap: function( html ) {
var isFunction = jQuery.isFunction( html ); var isFunction = jQuery.isFunction( html );
return this.each(function( i ) { return this.each( function( i ) {
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
}); } );
}, },
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();
} }
}); } );
return jQuery; return jQuery;
}); } );
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