updated js

This commit is contained in:
Paul Schneider
2025-06-13 15:38:03 +01:00
parent c4dc16dde4
commit f322e3f485
143 changed files with 21762 additions and 9183 deletions

View File

@ -1,38 +1,25 @@
{ {
"name": "jquery", "name": "jquery",
"version": "2.1.4",
"main": "dist/jquery.js", "main": "dist/jquery.js",
"license": "MIT", "license": "MIT",
"ignore": [ "ignore": [
"**/.*",
"build",
"dist/cdn",
"speed",
"test",
"*.md",
"AUTHORS.txt",
"Gruntfile.js",
"package.json" "package.json"
], ],
"devDependencies": {
"sizzle": "2.1.1-jquery.2.1.2",
"requirejs": "2.1.10",
"qunit": "1.14.0",
"sinon": "1.8.1"
},
"keywords": [ "keywords": [
"jquery", "jquery",
"javascript", "javascript",
"browser",
"library" "library"
], ],
"homepage": "https://github.com/jquery/jquery-dist", "homepage": "https://github.com/jquery/jquery-dist",
"_release": "2.1.4", "version": "3.7.1",
"_release": "3.7.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "2.1.4", "tag": "3.7.1",
"commit": "7751e69b615c6eca6f783a81e292a55725af6b85" "commit": "fde1f76e2799dd877c176abde0ec836553246991"
}, },
"_source": "https://github.com/jquery/jquery-dist.git", "_source": "https://github.com/jquery/jquery-dist.git",
"_target": "2.1.4", "_target": ">=1.8",
"_originalSource": "jquery" "_originalSource": "jquery"
} }

View File

@ -0,0 +1,371 @@
John Resig <jeresig@gmail.com>
Gilles van den Hoven <gilles0181@gmail.com>
Michael Geary <mike@geary.com>
Stefan Petre <stefan.petre@gmail.com>
Yehuda Katz <wycats@gmail.com>
Corey Jewett <cj@syntheticplayground.com>
Klaus Hartl <klaus.hartl@gmail.com>
Franck Marcia <franck.marcia@gmail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com>
Paul Bakaus <paul.bakaus@gmail.com>
Brandon Aaron <brandon.aaron@gmail.com>
Mike Alsup <malsup@gmail.com>
Dave Methvin <dave.methvin@gmail.com>
Ed Engelhardt <edengelhardt@gmail.com>
Sean Catchpole <littlecooldude@gmail.com>
Paul Mclanahan <pmclanahan@gmail.com>
David Serduke <davidserduke@gmail.com>
Richard D. Worth <rdworth@gmail.com>
Scott González <scott.gonzalez@gmail.com>
Ariel Flesler <aflesler@gmail.com>
Cheah Chu Yeow <chuyeow@gmail.com>
Andrew Chalkley <andrew@chalkley.org>
Fabio Buffoni <fabio.buffoni@bitmaster.it>
Stefan Bauckmeier  <stefan@bauckmeier.de>
Jon Evans <jon@springyweb.com>
TJ Holowaychuk <tj@vision-media.ca>
Riccardo De Agostini <rdeago@gmail.com>
Michael Bensoussan <mickey@seesmic.com>
Louis-Rémi Babé <lrbabe@gmail.com>
Robert Katić <robert.katic@gmail.com>
Damian Janowski <damian.janowski@gmail.com>
Anton Kovalyov <anton@kovalyov.net>
Dušan B. Jovanovic <dbjdbj@gmail.com>
Earle Castledine <mrspeaker@gmail.com>
Rich Dougherty <rich@rd.gen.nz>
Kim Dalsgaard <kim@kimdalsgaard.com>
Andrea Giammarchi <andrea.giammarchi@gmail.com>
Fabian Jakobs <fabian.jakobs@web.de>
Mark Gibson <jollytoad@gmail.com>
Karl Swedberg <kswedberg@gmail.com>
Justin Meyer <justinbmeyer@gmail.com>
Ben Alman <cowboy@rj3.net>
James Padolsey <cla@padolsey.net>
David Petersen <public@petersendidit.com>
Batiste Bieler <batiste.bieler@gmail.com>
Jake Archibald <jake.archibald@bbc.co.uk>
Alexander Farkas <info@corrupt-system.de>
Filipe Fortes <filipe@fortes.com>
Rick Waldron <waldron.rick@gmail.com>
Neeraj Singh <neerajdotname@gmail.com>
Paul Irish <paul.irish@gmail.com>
Iraê Carvalho <irae@irae.pro.br>
Matt Curry <matt@pseudocoder.com>
Michael Monteleone <michael@michaelmonteleone.net>
Noah Sloan <noah.sloan@gmail.com>
Tom Viner <github@viner.tv>
J. Ryan Stinnett <jryans@gmail.com>
Douglas Neiner <doug@dougneiner.com>
Adam J. Sontag <ajpiano@ajpiano.com>
Heungsub Lee <h@subl.ee>
Dave Reed <dareed@microsoft.com>
Carl Fürstenberg <azatoth@gmail.com>
Jacob Wright <jacwright@gmail.com>
Ralph Whitbeck <ralph.whitbeck@gmail.com>
unknown <Igen005@.upcorp.ad.uprr.com>
temp01 <temp01irc@gmail.com>
Colin Snover <github.com@zetafleet.com>
Jared Grippe <jared@deadlyicon.com>
Ryan W Tenney <ryan@10e.us>
Alex Sexton <AlexSexton@gmail.com>
Pinhook <contact@pinhooklabs.com>
Ron Otten <r.j.g.otten@gmail.com>
Jephte Clain <Jephte.Clain@univ-reunion.fr>
Anton Matzneller <obhvsbypqghgc@gmail.com>
Dan Heberden <danheberden@gmail.com>
Henri Wiechers <hwiechers@gmail.com>
Russell Holbrook <russell.holbrook@patch.com>
Julian Aubourg <aubourg.julian@gmail.com>
Gianni Alessandro Chiappetta <gianni@runlevel6.org>
Scott Jehl <scottjehl@gmail.com>
James Burke <jrburke@gmail.com>
Jonas Pfenniger <jonas@pfenniger.name>
Xavi Ramirez <xavi.rmz@gmail.com>
Sylvester Keil <sylvester@keil.or.at>
Brandon Sterne <bsterne@mozilla.com>
Mathias Bynens <mathias@qiwi.be>
Lee Carpenter <elcarpie@gmail.com>
Timmy Willison <4timmywil@gmail.com>
Corey Frang <gnarf37@gmail.com>
Digitalxero <digitalxero>
David Murdoch <david@davidmurdoch.com>
Josh Varner <josh.varner@gmail.com>
Charles McNulty <cmcnulty@kznf.com>
Jordan Boesch <jboesch26@gmail.com>
Jess Thrysoee <jess@thrysoee.dk>
Michael Murray <m@murz.net>
Alexis Abril <me@alexisabril.com>
Rob Morgan <robbym@gmail.com>
John Firebaugh <john_firebaugh@bigfix.com>
Sam Bisbee <sam@sbisbee.com>
Gilmore Davidson <gilmoreorless@gmail.com>
Brian Brennan <me@brianlovesthings.com>
Xavier Montillet <xavierm02.net@gmail.com>
Daniel Pihlstrom <sciolist.se@gmail.com>
Sahab Yazdani <sahab.yazdani+github@gmail.com>
avaly <github-com@agachi.name>
Scott Hughes <hi@scott-hughes.me>
Mike Sherov <mike.sherov@gmail.com>
Greg Hazel <ghazel@gmail.com>
Schalk Neethling <schalk@ossreleasefeed.com>
Denis Knauf <Denis.Knauf@gmail.com>
Timo Tijhof <krinklemail@gmail.com>
Steen Nielsen <swinedk@gmail.com>
Anton Ryzhov <anton@ryzhov.me>
Shi Chuan <shichuanr@gmail.com>
Matt Mueller <mattmuelle@gmail.com>
Berker Peksag <berker.peksag@gmail.com>
Toby Brain <tobyb@freshview.com>
Justin <drakefjustin@gmail.com>
Daniel Herman <daniel.c.herman@gmail.com>
Oleg Gaidarenko <markelog@gmail.com>
Rock Hymas <rock@fogcreek.com>
Richard Gibson <richard.gibson@gmail.com>
Rafaël Blais Masson <rafbmasson@gmail.com>
cmc3cn <59194618@qq.com>
Joe Presbrey <presbrey@gmail.com>
Sindre Sorhus <sindresorhus@gmail.com>
Arne de Bree <arne@bukkie.nl>
Vladislav Zarakovsky <vlad.zar@gmail.com>
Andrew E Monat <amonat@gmail.com>
Oskari <admin@o-programs.com>
Joao Henrique de Andrade Bruni <joaohbruni@yahoo.com.br>
tsinha <tsinha@Anthonys-MacBook-Pro.local>
Dominik D. Geyer <dominik.geyer@gmail.com>
Matt Farmer <matt@frmr.me>
Trey Hunner <treyhunner@gmail.com>
Jason Moon <jmoon@socialcast.com>
Jeffery To <jeffery.to@gmail.com>
Kris Borchers <kris.borchers@gmail.com>
Vladimir Zhuravlev <private.face@gmail.com>
Jacob Thornton <jacobthornton@gmail.com>
Chad Killingsworth <chadkillingsworth@missouristate.edu>
Vitya Muhachev <vic99999@yandex.ru>
Nowres Rafid <nowres.rafed@gmail.com>
David Benjamin <davidben@mit.edu>
Alan Plum <github@ap.apsq.de>
Uri Gilad <antishok@gmail.com>
Chris Faulkner <thefaulkner@gmail.com>
Marcel Greter <marcel.greter@ocbnet.ch>
Elijah Manor <elijah.manor@gmail.com>
Daniel Chatfield <chatfielddaniel@gmail.com>
Daniel Gálvez <dgalvez@editablething.com>
Nikita Govorov <nikita.govorov@gmail.com>
Wesley Walser <waw325@gmail.com>
Mike Pennisi <mike@mikepennisi.com>
Matthias Jäggli <matthias.jaeggli@gmail.com>
Devin Cooper <cooper.semantics@gmail.com>
Markus Staab <markus.staab@redaxo.de>
Dave Riddle <david@joyvuu.com>
Callum Macrae <callum@lynxphp.com>
Jonathan Sampson <jjdsampson@gmail.com>
Benjamin Truyman <bentruyman@gmail.com>
Jay Merrifield <fracmak@gmail.com>
James Huston <james@jameshuston.net>
Sai Lung Wong <sai.wong@huffingtonpost.com>
Erick Ruiz de Chávez <erickrdch@gmail.com>
David Bonner <dbonner@cogolabs.com>
Allen J Schmidt Jr <cobrasoft@gmail.com>
Akintayo Akinwunmi <aakinwunmi@judge.com>
MORGAN <morgan@morgangraphics.com>
Ismail Khair <ismail.khair@gmail.com>
Carl Danley <carldanley@gmail.com>
Mike Petrovich <michael.c.petrovich@gmail.com>
Greg Lavallee <greglavallee@wapolabs.com>
Tom H Fuertes <TomFuertes@gmail.com>
Roland Eckl <eckl.roland@googlemail.com>
Yiming He <yiminghe@gmail.com>
David Fox <dfoxinator@gmail.com>
Bennett Sorbo <bsorbo@gmail.com>
Paul Ramos <paul.b.ramos@gmail.com>
Rod Vagg <rod@vagg.org>
Sebastian Burkhard <sebi.burkhard@gmail.com>
Zachary Adam Kaplan <razic@viralkitty.com>
Adam Coulombe <me@adam.co>
nanto_vi <nanto@moon.email.ne.jp>
nanto <nanto@moon.email.ne.jp>
Danil Somsikov <danilasomsikov@gmail.com>
Ryunosuke SATO <tricknotes.rs@gmail.com>
Diego Tres <diegotres@gmail.com>
Jean Boussier <jean.boussier@gmail.com>
Andrew Plummer <plummer.andrew@gmail.com>
Mark Raddatz <mraddatz@gmail.com>
Pascal Borreli <pascal@borreli.com>
Isaac Z. Schlueter <i@izs.me>
Karl Sieburg <ksieburg@yahoo.com>
Nguyen Phuc Lam <ruado1987@gmail.com>
Dmitry Gusev <dmitry.gusev@gmail.com>
Steven Benner <admin@stevenbenner.com>
Li Xudong <istonelee@gmail.com>
Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
Renato Oliveira dos Santos <ros3@cin.ufpe.br>
Frederic Junod <frederic.junod@camptocamp.com>
Tom H Fuertes <tomfuertes@gmail.com>
Mitch Foley <mitch@thefoley.net>
ros3cin <ros3@cin.ufpe.br>
Kyle Robinson Young <kyle@dontkry.com>
John Paul <john@johnkpaul.com>
Jason Bedard <jason+jquery@jbedard.ca>
Chris Talkington <chris@talkingtontech.com>
Eddie Monge <eddie@eddiemonge.com>
Terry Jones <terry@jon.es>
Jason Merino <jasonmerino@gmail.com>
Dan Burzo <danburzo@gmail.com>
Jeremy Dunck <jdunck@gmail.com>
Chris Price <price.c@gmail.com>
Guy Bedford <guybedford@gmail.com>
njhamann <njhamann@gmail.com>
Goare Mao <mygoare@gmail.com>
Amey Sakhadeo <me@ameyms.com>
Mike Sidorov <mikes.ekb@gmail.com>
Anthony Ryan <anthonyryan1@gmail.com>
Lihan Li <frankieteardrop@gmail.com>
George Kats <katsgeorgeek@gmail.com>
Dongseok Paeng <dongseok83.paeng@lge.com>
Ronny Springer <springer.ronny@gmail.com>
Ilya Kantor <iliakan@gmail.com>
Marian Sollmann <marian.sollmann@cargomedia.ch>
Chris Antaki <ChrisAntaki@gmail.com>
David Hong <d.hong@me.com>
Jakob Stoeck <jakob@pokermania.de>
Christopher Jones <chris@cjqed.com>
Forbes Lindesay <forbes@lindesay.co.uk>
S. Andrew Sheppard <andrew@wq.io>
Leonardo Balter <leonardo.balter@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
Daniel Husar <dano.husar@gmail.com>
Philip Jägenstedt <philip@foolip.org>
John Hoven <hovenj@gmail.com>
Roman Reiß <me@silverwind.io>
Benjy Cui <benjytrys@gmail.com>
Christian Kosmowski <ksmwsk@gmail.com>
David Corbacho <davidcorbacho@gmail.com>
Liang Peng <poppinlp@gmail.com>
TJ VanToll <tj.vantoll@gmail.com>
Aurelio De Rosa <aurelioderosa@gmail.com>
Senya Pugach <upisfree@outlook.com>
Dan Hart <danhart@notonthehighstreet.com>
Nazar Mokrynskyi <nazar@mokrynskyi.com>
Benjamin Tan <demoneaux@gmail.com>
Amit Merchant <bullredeyes@gmail.com>
Jason Bedard <jason+github@jbedard.ca>
Veaceslav Grimalschi <grimalschi@yandex.ru>
Richard McDaniel <rm0026@uah.edu>
Arthur Verschaeve <contact@arthurverschaeve.be>
Shivaji Varma <contact@shivajivarma.com>
Ben Toews <mastahyeti@gmail.com>
Bin Xin <rhyzix@gmail.com>
Neftaly Hernandez <neftaly.hernandez@gmail.com>
T.J. Crowder <tj.crowder@farsightsoftware.com>
Nicolas HENRY <icewil@gmail.com>
Frederic Hemberger <mail@frederic-hemberger.de>
Victor Homyakov <vkhomyackov@gmail.com>
Aditya Raghavan <araghavan3@gmail.com>
Anne-Gaelle Colom <coloma@westminster.ac.uk>
Leonardo Braga <leonardo.braga@gmail.com>
George Mauer <gmauer@gmail.com>
Stephen Edgar <stephen@netweb.com.au>
Thomas Tortorini <thomastortorini@gmail.com>
Jörn Wagner <joern.wagner@explicatis.com>
Jon Hester <jon.d.hester@gmail.com>
Colin Frick <colin@bash.li>
Winston Howes <winstonhowes@gmail.com>
Alexander O'Mara <me@alexomara.com>
Chris Rebert <github@rebertia.com>
Bastian Buchholz <buchholz.bastian@googlemail.com>
Mu Haibao <mhbseal@163.com>
Calvin Metcalf <calvin.metcalf@gmail.com>
Arthur Stolyar <nekr.fabula@gmail.com>
Gabriel Schulhof <gabriel.schulhof@intel.com>
Gilad Peleg <giladp007@gmail.com>
Julian Alexander Murillo <julian.alexander.murillo@gmail.com>
Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>
Martin Naumann <martin@geekonaut.de>
Yongwoo Jeon <yongwoo.jeon@navercorp.com>
John-David Dalton <john.david.dalton@gmail.com>
Marek Lewandowski <m.lewandowski@cksource.com>
Bruno Pérel <brunoperel@gmail.com>
Daniel Nill <daniellnill@gmail.com>
Reed Loden <reed@reedloden.com>
Sean Henderson <seanh.za@gmail.com>
Gary Ye <garysye@gmail.com>
Richard Kraaijenhagen <stdin+git@riichard.com>
Connor Atherton <c.liam.atherton@gmail.com>
Christian Grete <webmaster@christiangrete.com>
Tom von Clef <thomas.vonclef@gmail.com>
Liza Ramo <liza.h.ramo@gmail.com>
Joelle Fleurantin <joasqueeniebee@gmail.com>
Steve Mao <maochenyan@gmail.com>
Jon Dufresne <jon.dufresne@gmail.com>
Jae Sung Park <alberto.park@gmail.com>
Josh Soref <apache@soref.com>
Saptak Sengupta <saptak013@gmail.com>
Henry Wong <henryw4k@gmail.com>
Jun Sun <klsforever@gmail.com>
Martijn W. van der Lee <martijn@vanderlee.com>
Devin Wilson <dwilson6.github@gmail.com>
Damian Senn <jquery@topaxi.codes>
Zack Hall <zackhall@outlook.com>
Vitaliy Terziev <vitaliyterziev@gmail.com>
Todor Prikumov <tono_pr@abv.bg>
Bernhard M. Wiedemann <jquerybmw@lsmod.de>
Jha Naman <createnaman@gmail.com>
Alexander Lisianoi <all3fox@gmail.com>
William Robinet <william.robinet@conostix.com>
Joe Trumbull <trumbull.j@gmail.com>
Alexander K <xpyro@ya.ru>
Ralin Chimev <ralin.chimev@gmail.com>
Felipe Sateler <fsateler@gmail.com>
Christophe Tafani-Dereeper <christophetd@hotmail.fr>
Manoj Kumar <nithmanoj@gmail.com>
David Broder-Rodgers <broder93@gmail.com>
Alex Louden <alex@louden.com>
Alex Padilla <alexonezero@outlook.com>
karan-96 <karanbatra96@gmail.com>
南漂一卒 <shiy007@qq.com>
Erik Lax <erik@datahack.se>
Boom Lee <teabyii@gmail.com>
Andreas Solleder <asol@num42.de>
Pierre Spring <pierre@nelm.io>
Shashanka Nataraj <shashankan.10@gmail.com>
CDAGaming <cstack2011@yahoo.com>
Matan Kotler-Berkowitz <205matan@gmail.com>
Jordan Beland <jordan.beland@gmail.com>
Henry Zhu <hi@henryzoo.com>
Nilton Cesar <niltoncms@gmail.com>
basil.belokon <basil.belokon@gmail.com>
Andrey Meshkov <ay.meshkov@gmail.com>
tmybr11 <tomas.perone@gmail.com>
Luis Emilio Velasco Sanchez <emibloque@gmail.com>
Ed S <ejsanders@gmail.com>
Bert Zhang <enbo@users.noreply.github.com>
Sébastien Règne <regseb@users.noreply.github.com>
wartmanm <3869625+wartmanm@users.noreply.github.com>
Siddharth Dungarwal <sd5869@gmail.com>
abnud1 <ahmad13932013@hotmail.com>
Andrei Fangli <andrei_fangli@outlook.com>
Marja Hölttä <marja.holtta@gmail.com>
buddh4 <mail@jharrer.de>
Hoang <dangkyokhoang@gmail.com>
Wonseop Kim <wonseop.kim@samsung.com>
Pat O'Callaghan <patocallaghan@gmail.com>
JuanMa Ruiz <ruizjuanma@gmail.com>
Ahmed.S.ElAfifi <ahmed.s.elafifi@gmail.com>
Christian Oliff <christianoliff@pm.me>
Christian Wenz <christian@wenz.org>
Sean Robinson <sean.robinson@scottsdalecc.edu>
Jonathan <vanillajonathan@users.noreply.github.com>
Pierre Grimaud <grimaud.pierre@gmail.com>
Beatriz Rezener <beatrizrezener@users.noreply.github.com>
Natalia Sroka <37873210+natipo@users.noreply.github.com>
Wonhyoung Park <wh05.park@samsung.com>
Dallas Fraser <dallas.fraser.waterloo@gmail.com>
fecore1 <89127124+fecore1@users.noreply.github.com>
ygj6 <7699524+ygj6@users.noreply.github.com>
Simon Legner <Simon.Legner@gmail.com>
Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Anders Kaseorg <andersk@mit.edu>
Alex <aleksandrosansan@gmail.com>
Timo Tijhof <krinkle@fastmail.com>
Gabriela Gutierrez <gabigutierrez@google.com>
Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com>

View File

@ -1,5 +1,4 @@
Copyright 2014 jQuery Foundation and other contributors Copyright OpenJS Foundation and other contributors, https://openjsf.org/
http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -0,0 +1,60 @@
# jQuery
> jQuery is a fast, small, and feature-rich JavaScript library.
For information on how to get started and how to use jQuery, please see [jQuery's documentation](https://api.jquery.com/).
For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
If upgrading, please see the [blog post for 3.7.1](https://blog.jquery.com/2023/08/28/jquery-3-7-1-released-reliable-table-row-dimensions/). This includes notable differences from the previous version and a more readable changelog.
## Including jQuery
Below are some of the most common ways to include jQuery.
### Browser
#### Script tag
```html
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
```
#### Webpack / Browserify / Babel
There are several ways to use [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Babel](https://babeljs.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including jQuery will usually look like this:
```js
import $ from "jquery";
```
If you need to use jQuery in a file that's not an ECMAScript module, you can use the CommonJS syntax:
```js
var $ = require( "jquery" );
```
#### AMD (Asynchronous Module Definition)
AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](https://requirejs.org/docs/whyamd.html).
```js
define( [ "jquery" ], function( $ ) {
} );
```
### Node
To include jQuery in [Node](https://nodejs.org/), first install with npm.
```sh
npm install jquery
```
For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/jsdom/jsdom). This can be useful for testing purposes.
```js
const { JSDOM } = require( "jsdom" );
const { window } = new JSDOM( "" );
const $ = require( "jquery" )( window );
```

View File

@ -1,28 +1,14 @@
{ {
"name": "jquery", "name": "jquery",
"version": "2.1.4",
"main": "dist/jquery.js", "main": "dist/jquery.js",
"license": "MIT", "license": "MIT",
"ignore": [ "ignore": [
"**/.*",
"build",
"dist/cdn",
"speed",
"test",
"*.md",
"AUTHORS.txt",
"Gruntfile.js",
"package.json" "package.json"
], ],
"devDependencies": {
"sizzle": "2.1.1-jquery.2.1.2",
"requirejs": "2.1.10",
"qunit": "1.14.0",
"sinon": "1.8.1"
},
"keywords": [ "keywords": [
"jquery", "jquery",
"javascript", "javascript",
"browser",
"library" "library"
] ]
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,23 +1,31 @@
define([ define( [
"./core", "./core",
"./var/rnotwhite", "./var/document",
"./var/isFunction",
"./var/rnothtmlwhite",
"./ajax/var/location",
"./ajax/var/nonce", "./ajax/var/nonce",
"./ajax/var/rquery", "./ajax/var/rquery",
"./core/init", "./core/init",
"./ajax/parseJSON", "./core/parseXML",
"./ajax/parseXML", "./event/trigger",
"./deferred" "./deferred",
], function( jQuery, rnotwhite, nonce, rquery ) { "./serialize" // jQuery.param
], function( jQuery, document, isFunction, rnothtmlwhite, location, nonce, rquery ) {
"use strict";
var var
r20 = /%20/g,
rhash = /#.*$/, rhash = /#.*$/,
rts = /([?&])_=[^&]*/, rantiCache = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
// #7653, #8125, #8152: local protocol detection
// trac-7653, trac-8125, trac-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)
@ -37,14 +45,13 @@ var
*/ */
transports = {}, transports = {},
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression
allTypes = "*/".concat( "*" ), allTypes = "*/".concat( "*" ),
// Document location // Anchor tag for parsing the document origin
ajaxLocation = window.location.href, originAnchor = document.createElement( "a" );
// Segment location into parts originAnchor.href = location.href;
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 ) {
@ -59,19 +66,21 @@ function addToPrefiltersOrTransports( structure ) {
var dataType, var dataType,
i = 0, i = 0,
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
if ( 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[ 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 );
} }
} }
} }
@ -89,14 +98,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
inspected[ dataType ] = true; inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport ); options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport ); inspect( dataTypeOrTransport );
return false; return false;
} else if ( seekingTransport ) { } else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport ); return !( selected = dataTypeOrTransport );
} }
}); } );
return selected; return selected;
} }
@ -105,14 +116,14 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
// A special extend for ajax options // A special extend for ajax options
// that takes "flat" options (not to be deep extended) // that takes "flat" options (not to be deep extended)
// Fixes #9887 // Fixes trac-9887
function ajaxExtend( target, src ) { function ajaxExtend( target, src ) {
var key, deep, var key, deep,
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 ) {
@ -136,7 +147,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" );
} }
} }
@ -154,9 +165,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;
} }
@ -164,6 +176,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;
} }
@ -185,6 +198,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();
@ -214,7 +228,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;
@ -237,6 +251,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 ];
@ -256,13 +271,16 @@ 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 ) {
response = conv( response ); response = conv( response );
} else { } else {
try { try {
response = conv( response ); response = conv( response );
} catch ( e ) { } catch ( e ) {
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; return {
state: "parsererror",
error: conv ? e : "No conversion from " + prev + " to " + current
};
} }
} }
} }
@ -273,7 +291,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,
@ -283,13 +301,14 @@ jQuery.extend({
etag: {}, etag: {},
ajaxSettings: { ajaxSettings: {
url: ajaxLocation, url: location.href,
type: "GET", type: "GET",
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), isLocal: rlocalProtocol.test( location.protocol ),
global: true, global: true,
processData: true, processData: true,
async: true, async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8", contentType: "application/x-www-form-urlencoded; charset=UTF-8",
/* /*
timeout: 0, timeout: 0,
data: null, data: null,
@ -311,9 +330,9 @@ jQuery.extend({
}, },
contents: { contents: {
xml: /xml/, xml: /\bxml\b/,
html: /html/, html: /\bhtml/,
json: /json/ json: /\bjson\b/
}, },
responseFields: { responseFields: {
@ -333,7 +352,7 @@ jQuery.extend({
"text html": true, "text html": true,
// Evaluate text as a json expression // Evaluate text as a json expression
"text json": jQuery.parseJSON, "text json": JSON.parse,
// Parse text as xml // Parse text as xml
"text xml": jQuery.parseXML "text xml": jQuery.parseXML
@ -378,39 +397,58 @@ jQuery.extend({
options = options || {}; options = options || {};
var transport, var transport,
// URL without anti-cache param // URL without anti-cache param
cacheURL, cacheURL,
// Response headers // Response headers
responseHeadersString, responseHeadersString,
responseHeaders, responseHeaders,
// timeout handle // timeout handle
timeoutTimer, timeoutTimer,
// Cross-domain detection vars
parts, // Url cleanup var
urlAnchor,
// Request state (becomes false upon send and true upon completion)
completed,
// To know if global events are to be dispatched // To know if global events are to be dispatched
fireGlobals, fireGlobals,
// Loop variable // Loop variable
i, i,
// uncached part of the url
uncached,
// Create the final options object // Create the final options object
s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
// 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 && ( callbackContext.nodeType || callbackContext.jquery ) ? globalEventContext = s.context &&
( 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
state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
readyState: 0, readyState: 0,
@ -418,28 +456,30 @@ jQuery.extend({
// Builds headers hashtable if needed // Builds headers hashtable if needed
getResponseHeader: function( key ) { getResponseHeader: function( key ) {
var match; var match;
if ( state === 2 ) { if ( completed ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( (match = rheaders.exec( responseHeadersString )) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
.concat( match[ 2 ] );
} }
} }
match = responseHeaders[ key.toLowerCase() ]; match = responseHeaders[ key.toLowerCase() + " " ];
} }
return match == null ? null : match; return match == null ? null : match.join( ", " );
}, },
// Raw string // Raw string
getAllResponseHeaders: function() { getAllResponseHeaders: function() {
return state === 2 ? responseHeadersString : null; return completed ? responseHeadersString : null;
}, },
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
var lname = name.toLowerCase(); if ( completed == null ) {
if ( !state ) { name = requestHeadersNames[ name.toLowerCase() ] =
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; requestHeadersNames[ name.toLowerCase() ] || name;
requestHeaders[ name ] = value; requestHeaders[ name ] = value;
} }
return this; return this;
@ -447,7 +487,7 @@ jQuery.extend({
// Overrides response content-type header // Overrides response content-type header
overrideMimeType: function( type ) { overrideMimeType: function( type ) {
if ( !state ) { if ( completed == null ) {
s.mimeType = type; s.mimeType = type;
} }
return this; return this;
@ -457,14 +497,16 @@ jQuery.extend({
statusCode: function( map ) { statusCode: function( map ) {
var code; var code;
if ( map ) { if ( map ) {
if ( state < 2 ) { if ( completed ) {
for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
} else {
// Execute the appropriate callbacks // Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] ); jqXHR.always( map[ jqXHR.status ] );
} else {
// Lazy-add the new callbacks in a way that preserves old ones
for ( code in map ) {
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
} }
} }
return this; return this;
@ -482,31 +524,41 @@ jQuery.extend({
}; };
// Attach deferreds // Attach deferreds
deferred.promise( jqXHR ).complete = completeDeferred.add; deferred.promise( jqXHR );
jqXHR.success = jqXHR.done;
jqXHR.error = jqXHR.fail;
// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (prefilters might expect it) // Add protocol if not provided (prefilters might expect it)
// Handle falsy url in the settings object (#10093: consistency with old signature) // Handle falsy url in the settings object (trac-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 || ajaxLocation ) + "" ).replace( rhash, "" ) s.url = ( ( url || s.url || location.href ) + "" )
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); .replace( rprotocol, location.protocol + "//" );
// Alias method option to type as per ticket #12004 // Alias method option to type as per ticket trac-12004
s.type = options.method || options.type || s.method || s.type; s.type = options.method || options.type || s.method || s.type;
// Extract dataTypes list // Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
// A cross-domain request is in order when we have a protocol:host:port mismatch // A cross-domain request is in order when the origin doesn't match the current origin.
if ( s.crossDomain == null ) { if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() ); urlAnchor = document.createElement( "a" );
s.crossDomain = !!( parts &&
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || // Support: IE <=8 - 11, Edge 12 - 15
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== // IE throws exception on accessing the href property if url is malformed,
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) // e.g. http://example.com:80x/
); try {
urlAnchor.href = s.url;
// Support: IE <=8 - 11 only
// 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
@ -518,17 +570,17 @@ jQuery.extend({
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
// If request was aborted inside a prefilter, stop there // If request was aborted inside a prefilter, stop there
if ( state === 2 ) { if ( completed ) {
return jqXHR; return jqXHR;
} }
// We can fire global events as of now if asked to // We can fire global events as of now if asked to
// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)
fireGlobals = jQuery.event && s.global; fireGlobals = jQuery.event && s.global;
// 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
@ -539,28 +591,37 @@ jQuery.extend({
// Save the URL in case we're toying with the If-Modified-Since // Save the URL in case we're toying with the If-Modified-Since
// and/or If-None-Match header later on // and/or If-None-Match header later on
cacheURL = s.url; // Remove hash to simplify url manipulation
cacheURL = s.url.replace( rhash, "" );
// More options handling for requests with no content // More options handling for requests with no content
if ( !s.hasContent ) { if ( !s.hasContent ) {
// If data is available, append data to url // Remember the hash so we can put it back
if ( s.data ) { uncached = s.url.slice( cacheURL.length );
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
// #9682: remove data so that it's not used in an eventual retry // If data is available and should be processed, append data to url
if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
// trac-9682: remove data so that it's not used in an eventual retry
delete s.data; delete s.data;
} }
// Add anti-cache in url if needed // Add or update anti-cache param if needed
if ( s.cache === false ) { if ( s.cache === false ) {
s.url = rts.test( cacheURL ) ? cacheURL = cacheURL.replace( rantiCache, "$1" );
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
// If there is already a '_' parameter, set its value uncached;
cacheURL.replace( rts, "$1_=" + nonce++ ) :
// Otherwise add one to the end
cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
} }
// Put hash and anti-cache on the URL that will be requested (gh-1732)
s.url = cacheURL + uncached;
// Change '%20' to '+' if this is encoded form body content (gh-2658)
} else if ( s.data && s.processData &&
( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
s.data = s.data.replace( r20, "+" );
} }
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
@ -581,8 +642,9 @@ 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.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ] s.accepts[ "*" ]
); );
@ -592,7 +654,9 @@ jQuery.extend({
} }
// Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { if ( s.beforeSend &&
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
// Abort if not done already and return // Abort if not done already and return
return jqXHR.abort(); return jqXHR.abort();
} }
@ -601,9 +665,9 @@ jQuery.extend({
strAbort = "abort"; strAbort = "abort";
// Install callbacks on deferreds // Install callbacks on deferreds
for ( i in { success: 1, error: 1, complete: 1 } ) { completeDeferred.add( s.complete );
jqXHR[ i ]( s[ i ] ); jqXHR.done( s.success );
} jqXHR.fail( s.error );
// Get transport // Get transport
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
@ -618,24 +682,31 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
} }
// If request was aborted inside ajaxSend, stop there
if ( completed ) {
return jqXHR;
}
// Timeout // Timeout
if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
timeoutTimer = setTimeout(function() { timeoutTimer = window.setTimeout( function() {
jqXHR.abort("timeout"); jqXHR.abort( "timeout" );
}, s.timeout ); }, s.timeout );
} }
try { try {
state = 1; completed = false;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Propagate exception as error if not done
if ( state < 2 ) { // Rethrow post-completion exceptions
done( -1, e ); if ( completed ) {
// Simply rethrow otherwise
} else {
throw e; throw e;
} }
// Propagate others as results
done( -1, e );
} }
} }
@ -644,17 +715,16 @@ jQuery.extend({
var isSuccess, success, error, response, modified, var isSuccess, success, error, response, modified,
statusText = nativeStatusText; statusText = nativeStatusText;
// Called once // Ignore repeat invocations
if ( state === 2 ) { if ( completed ) {
return; return;
} }
// State is "done" now completed = true;
state = 2;
// Clear timeout if it exists // Clear timeout if it exists
if ( timeoutTimer ) { if ( timeoutTimer ) {
clearTimeout( timeoutTimer ); window.clearTimeout( timeoutTimer );
} }
// Dereference transport for early garbage collection // Dereference transport for early garbage collection
@ -675,6 +745,13 @@ jQuery.extend({
response = ajaxHandleResponses( s, jqXHR, responses ); response = ajaxHandleResponses( s, jqXHR, responses );
} }
// Use a noop converter for missing script but not if jsonp
if ( !isSuccess &&
jQuery.inArray( "script", s.dataTypes ) > -1 &&
jQuery.inArray( "json", s.dataTypes ) < 0 ) {
s.converters[ "text script" ] = function() {};
}
// Convert no matter what (that way responseXXX fields are always set) // Convert no matter what (that way responseXXX fields are always set)
response = ajaxConvert( s, response, jqXHR, isSuccess ); response = ajaxConvert( s, response, jqXHR, isSuccess );
@ -683,11 +760,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;
} }
@ -709,6 +786,7 @@ jQuery.extend({
isSuccess = !error; isSuccess = !error;
} }
} else { } else {
// Extract error from statusText and normalize for non-aborts // Extract error from statusText and normalize for non-aborts
error = statusText; error = statusText;
if ( status || !statusText ) { if ( status || !statusText ) {
@ -744,9 +822,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" );
} }
} }
} }
@ -761,26 +840,37 @@ 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 ( isFunction( data ) ) {
type = type || callback; type = type || callback;
callback = data; callback = data;
data = undefined; data = undefined;
} }
return jQuery.ajax({ // The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend( {
url: url, url: url,
type: method, type: method,
dataType: type, dataType: type,
data: data, data: data,
success: callback success: callback
}); }, jQuery.isPlainObject( url ) && url ) );
}; };
}); } );
jQuery.ajaxPrefilter( function( s ) {
var i;
for ( i in s.headers ) {
if ( i.toLowerCase() === "content-type" ) {
s.contentType = s.headers[ i ] || "";
}
}
} );
return jQuery; return jQuery;
}); } );

View File

@ -1,22 +1,25 @@
define([ define( [
"../core", "../core",
"../var/isFunction",
"./var/nonce", "./var/nonce",
"./var/rquery", "./var/rquery",
"../ajax" "../ajax"
], function( jQuery, nonce, rquery ) { ], function( jQuery, isFunction, nonce, rquery ) {
"use strict";
var oldCallbacks = [], 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.guid++ ) );
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 ) {
@ -24,14 +27,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer, var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" : "url" :
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" typeof s.data === "string" &&
( s.contentType || "" )
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
); );
// Handle iff the expected data type is "jsonp" or we have a parameter to set // Handle iff the expected data type is "jsonp" or we have a parameter to set
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
// Get callback name, remembering preexisting value associated with it // Get callback name, remembering preexisting value associated with it
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
s.jsonpCallback() : s.jsonpCallback() :
s.jsonpCallback; s.jsonpCallback;
@ -43,14 +49,14 @@ 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" );
} }
return responseContainer[ 0 ]; return responseContainer[ 0 ];
}; };
// force json dataType // Force json dataType
s.dataTypes[ 0 ] = "json"; s.dataTypes[ 0 ] = "json";
// Install callback // Install callback
@ -60,30 +66,38 @@ 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() {
// Restore preexisting value
window[ callbackName ] = overwritten; // If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
// Otherwise restore preexisting value
} else {
window[ callbackName ] = overwritten;
}
// Save back as free // Save back as free
if ( s[ callbackName ] ) { if ( s[ callbackName ] ) {
// make sure that re-using the options doesn't screw things around
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback; s.jsonpCallback = originalSettings.jsonpCallback;
// save the callback name for future use // Save the callback name for future use
oldCallbacks.push( callbackName ); oldCallbacks.push( callbackName );
} }
// Call if it was a function and we have a response // Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( overwritten ) ) { if ( responseContainer && isFunction( overwritten ) ) {
overwritten( responseContainer[ 0 ] ); overwritten( responseContainer[ 0 ] );
} }
responseContainer = overwritten = undefined; responseContainer = overwritten = undefined;
}); } );
// Delegate to script // Delegate to script
return "script"; return "script";
} }
}); } );
}); } );

View File

@ -1,36 +1,31 @@
define([ define( [
"../core", "../core",
"../core/stripAndCollapse",
"../var/isFunction",
"../core/parseHTML", "../core/parseHTML",
"../ajax", "../ajax",
"../traversing", "../traversing",
"../manipulation", "../manipulation",
"../selector", "../selector"
// Optional event/alias dependency ], function( jQuery, stripAndCollapse, isFunction ) {
"../event/alias"
], function( jQuery ) {
// Keep a copy of the old load method "use strict";
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 >= 0 ) { if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) ); selector = stripAndCollapse( url.slice( off ) );
url = url.slice( 0, off ); url = url.slice( 0, off );
} }
// If it's a function // If it's a function
if ( jQuery.isFunction( params ) ) { if ( isFunction( params ) ) {
// We assume that it's the callback // We assume that it's the callback
callback = params; callback = params;
@ -43,14 +38,16 @@ 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.
type: type, // Make value of this field explicit since
// user can override it through ajaxSetup method
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;
@ -59,17 +56,22 @@ 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 );
}).complete( callback && function( jqXHR, status ) { // If the request succeeds, this function gets "data", "status", "jqXHR"
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); // but they are ignored because response was set above.
}); // If it fails, this function gets "jqXHR", "status", "error"
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
} }
return this; return this;
}; };
}); } );

View File

@ -1,13 +0,0 @@
define([
"../core"
], function( jQuery ) {
// Support: Android 2.3
// Workaround failure to string-cast null input
jQuery.parseJSON = function( data ) {
return JSON.parse( data + "" );
};
return jQuery.parseJSON;
});

View File

@ -1,28 +0,0 @@
define([
"../core"
], function( jQuery ) {
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
var xml, tmp;
if ( !data || typeof data !== "string" ) {
return null;
}
// Support: IE9
try {
tmp = new DOMParser();
xml = tmp.parseFromString( data, "text/xml" );
} catch ( e ) {
xml = undefined;
}
if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data );
}
return xml;
};
return jQuery.parseXML;
});

View File

@ -1,15 +1,26 @@
define([ define( [
"../core", "../core",
"../var/document",
"../ajax" "../ajax"
], function( jQuery ) { ], function( jQuery, document ) {
"use strict";
// 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, application/ecmascript, application/x-ecmascript" script: "text/javascript, application/javascript, " +
"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 ) {
@ -17,7 +28,7 @@ jQuery.ajaxSetup({
return text; return text;
} }
} }
}); } );
// Handle cache's special case and crossDomain // Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) { jQuery.ajaxPrefilter( "script", function( s ) {
@ -27,29 +38,28 @@ jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.crossDomain ) { if ( s.crossDomain ) {
s.type = "GET"; s.type = "GET";
} }
}); } );
// 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
if ( s.crossDomain ) { // This transport only deals with cross domain or forced-by-attrs requests
if ( s.crossDomain || s.scriptAttrs ) {
var script, callback; var script, callback;
return { return {
send: function( _, complete ) { send: function( _, complete ) {
script = jQuery("<script>").prop({ script = jQuery( "<script>" )
async: true, .attr( s.scriptAttrs || {} )
charset: s.scriptCharset, .prop( { charset: s.scriptCharset, src: s.url } )
src: s.url .on( "load error", callback = function( evt ) {
}).on(
"load error",
callback = function( evt ) {
script.remove(); script.remove();
callback = null; callback = null;
if ( evt ) { if ( evt ) {
complete( evt.type === "error" ? 404 : 200, evt.type ); complete( evt.type === "error" ? 404 : 200, evt.type );
} }
} } );
);
// Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] ); document.head.appendChild( script[ 0 ] );
}, },
abort: function() { abort: function() {
@ -59,6 +69,6 @@ jQuery.ajaxTransport( "script", function( s ) {
} }
}; };
} }
}); } );
}); } );

View File

@ -0,0 +1,5 @@
define( function() {
"use strict";
return window.location;
} );

View File

@ -1,5 +1,5 @@
define([ define( function() {
"../../core" "use strict";
], function( jQuery ) {
return jQuery.now(); return { guid: Date.now() };
}); } );

View File

@ -1,3 +1,5 @@
define(function() { define( function() {
return (/\?/); "use strict";
});
return ( /\?/ );
} );

View File

@ -1,52 +1,48 @@
define([ define( [
"../core", "../core",
"../var/support", "../var/support",
"../ajax" "../ajax"
], function( jQuery, support ) { ], function( jQuery, support ) {
"use strict";
jQuery.ajaxSettings.xhr = function() { jQuery.ajaxSettings.xhr = function() {
try { try {
return new XMLHttpRequest(); return new window.XMLHttpRequest();
} catch( e ) {} } catch ( e ) {}
}; };
var xhrId = 0, var xhrSuccessStatus = {
xhrCallbacks = {},
xhrSuccessStatus = { // File protocol always yields status code 0, assume 200
// file protocol always yields status code 0, assume 200
0: 200, 0: 200,
// Support: IE9
// #1450: sometimes IE returns 1223 when it should be 204 // Support: IE <=9 only
// trac-1450: sometimes IE returns 1223 when it should be 204
1223: 204 1223: 204
}, },
xhrSupported = jQuery.ajaxSettings.xhr(); xhrSupported = jQuery.ajaxSettings.xhr();
// Support: IE9
// 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 ]();
}
});
}
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported; support.ajax = xhrSupported = !!xhrSupported;
jQuery.ajaxTransport(function( options ) { jQuery.ajaxTransport( function( options ) {
var callback; var callback, errorCallback;
// Cross domain only allowed if supported through XMLHttpRequest // Cross domain only allowed if supported through XMLHttpRequest
if ( support.cors || xhrSupported && !options.crossDomain ) { if ( support.cors || xhrSupported && !options.crossDomain ) {
return { return {
send: function( headers, complete ) { send: function( headers, complete ) {
var i, var i,
xhr = options.xhr(), xhr = options.xhr();
id = ++xhrId;
xhr.open( options.type, options.url, options.async, options.username, options.password ); xhr.open(
options.type,
options.url,
options.async,
options.username,
options.password
);
// Apply custom fields if provided // Apply custom fields if provided
if ( options.xhrFields ) { if ( options.xhrFields ) {
@ -65,8 +61,8 @@ jQuery.ajaxTransport(function( options ) {
// 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
@ -78,27 +74,39 @@ jQuery.ajaxTransport(function( options ) {
callback = function( type ) { callback = function( type ) {
return function() { return function() {
if ( callback ) { if ( callback ) {
delete xhrCallbacks[ id ]; callback = errorCallback = xhr.onload =
callback = xhr.onload = xhr.onerror = null; xhr.onerror = xhr.onabort = xhr.ontimeout =
xhr.onreadystatechange = null;
if ( type === "abort" ) { if ( type === "abort" ) {
xhr.abort(); xhr.abort();
} else if ( type === "error" ) { } else if ( type === "error" ) {
complete(
// file: protocol always yields status 0; see #8605, #14207 // Support: IE <=9 only
xhr.status, // On a manual native abort, IE9 throws
xhr.statusText // errors on any property access that is not readyState
); if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see trac-8605, trac-14207
xhr.status,
xhr.statusText
);
}
} else { } else {
complete( complete(
xhrSuccessStatus[ xhr.status ] || xhr.status, xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText, xhr.statusText,
// Support: IE9
// Accessing binary-data responseText throws an exception // Support: IE <=9 only
// (#11426) // IE9 has no XHR2 but throws on binary (trac-11426)
typeof xhr.responseText === "string" ? { // For XHR2 non-text, let the caller handle it (gh-2498)
text: xhr.responseText ( xhr.responseType || "text" ) !== "text" ||
} : undefined, typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders() xhr.getAllResponseHeaders()
); );
} }
@ -108,16 +116,42 @@ jQuery.ajaxTransport(function( options ) {
// Listen to events // Listen to events
xhr.onload = callback(); xhr.onload = callback();
xhr.onerror = callback("error"); errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
// Support: IE 9 only
// Use onreadystatechange to replace onabort
// to handle uncaught aborts
if ( xhr.onabort !== undefined ) {
xhr.onabort = errorCallback;
} else {
xhr.onreadystatechange = function() {
// Check readyState before timeout as it changes
if ( xhr.readyState === 4 ) {
// Allow onerror to be called first,
// but that will not handle a native abort
// Also, save errorCallback to a variable
// as xhr.onerror cannot be accessed
window.setTimeout( function() {
if ( callback ) {
errorCallback();
}
} );
}
};
}
// Create the abort callback // Create the abort callback
callback = xhrCallbacks[ id ] = callback("abort"); callback = callback( "abort" );
try { try {
// Do send the request (this may raise an exception) // Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null ); xhr.send( options.hasContent && options.data || null );
} catch ( e ) { } catch ( e ) {
// #14683: Only rethrow if this hasn't been notified as an error yet
// trac-14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) { if ( callback ) {
throw e; throw e;
} }
@ -131,6 +165,6 @@ jQuery.ajaxTransport(function( options ) {
} }
}; };
} }
}); } );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./attributes/attr", "./attributes/attr",
"./attributes/prop", "./attributes/prop",
@ -6,6 +6,8 @@ define([
"./attributes/val" "./attributes/val"
], function( jQuery ) { ], function( jQuery ) {
"use strict";
// Return jQuery for attributes-only inclusion // Return jQuery for attributes-only inclusion
return jQuery; return jQuery;
}); } );

View File

@ -1,101 +1,81 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite",
"../var/strundefined",
"../core/access", "../core/access",
"../core/nodeName",
"./support", "./support",
"../var/rnothtmlwhite",
"../selector" "../selector"
], function( jQuery, rnotwhite, strundefined, access, support ) { ], function( jQuery, access, nodeName, support, rnothtmlwhite ) {
var nodeHook, boolHook, "use strict";
var boolHook,
attrHandle = jQuery.expr.attrHandle; attrHandle = jQuery.expr.attrHandle;
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 hooks, ret, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // Don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
return; return;
} }
// Fallback to prop when attributes are not supported // Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === strundefined ) { if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value ); return jQuery.prop( elem, name, value );
} }
// All attributes are lowercase // Attribute hooks are determined by the lowercase version
// Grab necessary hook if one is defined // Grab necessary hook if one is defined
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
name = name.toLowerCase(); hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
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 ) {
if ( value === null ) { if ( value === null ) {
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
return;
}
} else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret; return ret;
} else {
elem.setAttribute( name, value + "" );
return value;
} }
} else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { elem.setAttribute( name, value + "" );
return value;
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret; return ret;
} else {
ret = jQuery.find.attr( elem, name );
// Non-existent attributes return null, we normalize to undefined
return ret == null ?
undefined :
ret;
} }
},
removeAttr: function( elem, value ) { ret = jQuery.find.attr( elem, name );
var name, propName,
i = 0,
attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) { // Non-existent attributes return null, we normalize to undefined
while ( (name = attrNames[i++]) ) { return ret == null ? undefined : ret;
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false
elem[ propName ] = false;
}
elem.removeAttribute( name );
}
}
}, },
attrHooks: { attrHooks: {
type: { type: {
set: function( elem, value ) { set: function( elem, value ) {
if ( !support.radioValue && value === "radio" && if ( !support.radioValue && value === "radio" &&
jQuery.nodeName( elem, "input" ) ) { nodeName( elem, "input" ) ) {
var val = elem.value; var val = elem.value;
elem.setAttribute( "type", value ); elem.setAttribute( "type", value );
if ( val ) { if ( val ) {
@ -105,13 +85,29 @@ jQuery.extend({
} }
} }
} }
},
removeAttr: function( elem, value ) {
var name,
i = 0,
// Attribute names can contain non-HTML whitespace characters
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
attrNames = value && value.match( rnothtmlwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) {
elem.removeAttribute( name );
}
}
} }
}); } );
// 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 { } else {
@ -120,22 +116,26 @@ boolHook = {
return name; return name;
} }
}; };
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
var getter = attrHandle[ name ] || jQuery.find.attr; var getter = attrHandle[ name ] || jQuery.find.attr;
attrHandle[ name ] = function( elem, name, isXML ) { attrHandle[ name ] = function( elem, name, isXML ) {
var ret, handle; var ret, handle,
lowercaseName = name.toLowerCase();
if ( !isXML ) { if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter // Avoid an infinite loop by temporarily removing this function from the getter
handle = attrHandle[ name ]; handle = attrHandle[ lowercaseName ];
attrHandle[ name ] = ret; attrHandle[ lowercaseName ] = ret;
ret = getter( elem, name, isXML ) != null ? ret = getter( elem, name, isXML ) != null ?
name.toLowerCase() : lowercaseName :
null; null;
attrHandle[ name ] = handle; attrHandle[ lowercaseName ] = handle;
} }
return ret; return ret;
}; };
}); } );
}); } );

View File

@ -1,122 +1,138 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite", "../core/stripAndCollapse",
"../var/strundefined", "../var/isFunction",
"../data/var/data_priv", "../var/rnothtmlwhite",
"../data/var/dataPriv",
"../core/init" "../core/init"
], function( jQuery, rnotwhite, strundefined, data_priv ) { ], function( jQuery, stripAndCollapse, isFunction, rnothtmlwhite, dataPriv ) {
var rclass = /[\t\r\n\f]/g; "use strict";
jQuery.fn.extend({ function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
function classesToArray( value ) {
if ( Array.isArray( value ) ) {
return value;
}
if ( typeof value === "string" ) {
return value.match( rnothtmlwhite ) || [];
}
return [];
}
jQuery.fn.extend( {
addClass: function( value ) { addClass: function( value ) {
var classes, elem, cur, clazz, j, finalValue, var classNames, cur, curValue, className, i, finalValue;
proceed = typeof value === "string" && value,
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, this.className ) ); jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) { classNames = classesToArray( value );
// The disjunction here is for better compressibility (see removeClass)
classes = ( value || "" ).match( rnotwhite ) || [];
for ( ; i < len; i++ ) { if ( classNames.length ) {
elem = this[ i ]; return this.each( function() {
cur = elem.nodeType === 1 && ( elem.className ? curValue = getClass( this );
( " " + elem.className + " " ).replace( rclass, " " ) : cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
" "
);
if ( cur ) { if ( cur ) {
j = 0; for ( i = 0; i < classNames.length; i++ ) {
while ( (clazz = classes[j++]) ) { className = classNames[ i ];
if ( cur.indexOf( " " + clazz + " " ) < 0 ) { if ( cur.indexOf( " " + className + " " ) < 0 ) {
cur += clazz + " "; cur += className + " ";
} }
} }
// only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = jQuery.trim( cur ); finalValue = stripAndCollapse( cur );
if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
elem.className = finalValue; this.setAttribute( "class", finalValue );
} }
} }
} } );
} }
return this; return this;
}, },
removeClass: function( value ) { removeClass: function( value ) {
var classes, elem, cur, clazz, j, finalValue, var classNames, cur, curValue, className, i, finalValue;
proceed = arguments.length === 0 || typeof value === "string" && value,
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, this.className ) ); 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", "" );
}
classNames = classesToArray( value );
if ( classNames.length ) {
return this.each( function() {
curValue = getClass( this );
// This expression is here for better compressibility (see addClass) // This expression is here for better compressibility (see addClass)
cur = elem.nodeType === 1 && ( elem.className ? cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
( " " + elem.className + " " ).replace( rclass, " " ) :
""
);
if ( cur ) { if ( cur ) {
j = 0; for ( i = 0; i < classNames.length; i++ ) {
while ( (clazz = classes[j++]) ) { className = classNames[ i ];
// Remove *all* instances // Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { while ( cur.indexOf( " " + className + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " ); cur = cur.replace( " " + className + " ", " " );
} }
} }
// Only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = value ? jQuery.trim( cur ) : ""; finalValue = stripAndCollapse( cur );
if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
elem.className = finalValue; this.setAttribute( "class", finalValue );
} }
} }
} } );
} }
return this; return this;
}, },
toggleClass: function( value, stateVal ) { toggleClass: function( value, stateVal ) {
var type = typeof value; var classNames, className, i, self,
type = typeof value,
isValidValue = type === "string" || Array.isArray( value );
if ( typeof stateVal === "boolean" && type === "string" ) { if ( isFunction( value ) ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
stateVal
);
} );
}
if ( typeof stateVal === "boolean" && isValidValue ) {
return stateVal ? this.addClass( value ) : this.removeClass( value ); return stateVal ? this.addClass( value ) : this.removeClass( value );
} }
if ( jQuery.isFunction( value ) ) { classNames = classesToArray( value );
return this.each(function( i ) {
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); return this.each( function() {
}); if ( isValidValue ) {
}
return this.each(function() {
if ( type === "string" ) {
// Toggle individual class names // Toggle individual class names
var className, self = jQuery( this );
i = 0,
self = jQuery( this ), for ( i = 0; i < classNames.length; i++ ) {
classNames = value.match( rnotwhite ) || []; className = classNames[ i ];
while ( (className = classNames[ i++ ]) ) {
// Check each className given, space separated list // Check each className given, space separated list
if ( self.hasClass( className ) ) { if ( self.hasClass( className ) ) {
self.removeClass( className ); self.removeClass( className );
@ -126,33 +142,43 @@ jQuery.fn.extend({
} }
// Toggle whole class name // Toggle whole class name
} else if ( type === strundefined || type === "boolean" ) { } else if ( value === undefined || type === "boolean" ) {
if ( this.className ) { className = getClass( this );
// store className if set if ( className ) {
data_priv.set( this, "__className__", this.className );
// Store className if set
dataPriv.set( 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.
this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; if ( this.setAttribute ) {
this.setAttribute( "class",
className || value === false ?
"" :
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 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { while ( ( elem = this[ i++ ] ) ) {
if ( elem.nodeType === 1 &&
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
return true; return true;
} }
} }
return false; return false;
} }
}); } );
}); } );

View File

@ -1,82 +1,130 @@
define([ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support" "./support",
"../selector"
], function( jQuery, access, support ) { ], function( jQuery, access, support ) {
var rfocusable = /^(?:input|select|textarea|button)$/i; "use strict";
jQuery.fn.extend({ var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
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() { return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ]; delete this[ jQuery.propFix[ name ] || name ];
}); } );
} }
}); } );
jQuery.extend({
propFix: {
"for": "htmlFor",
"class": "className"
},
jQuery.extend( {
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var ret, hooks, notxml, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes // Don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
return; return;
} }
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
if ( notxml ) {
// Fix name and attach hooks // Fix name and attach hooks
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ]; hooks = jQuery.propHooks[ name ];
} }
if ( value !== undefined ) { if ( value !== undefined ) {
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? if ( hooks && "set" in hooks &&
ret : ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
( elem[ name ] = value ); return ret;
}
} else { return ( elem[ name ] = value );
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
ret :
elem[ name ];
} }
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
return elem[ name ];
}, },
propHooks: { propHooks: {
tabIndex: { tabIndex: {
get: function( elem ) { get: function( elem ) {
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
elem.tabIndex : // Support: IE <=9 - 11 only
-1; // elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// Use proper attribute retrieval (trac-12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
if ( tabindex ) {
return parseInt( tabindex, 10 );
}
if (
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) &&
elem.href
) {
return 0;
}
return -1;
} }
} }
} },
});
propFix: {
"for": "htmlFor",
"class": "className"
}
} );
// Support: IE <=11 only
// Accessing the selectedIndex property
// forces the browser to respect setting selected
// on the option
// The getter ensures a default option is selected
// when in an optgroup
// eslint rule "no-unused-expressions" is disabled for this code
// since it considers such accessions noop
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
get: function( elem ) { get: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode; var parent = elem.parentNode;
if ( parent && parent.parentNode ) { if ( parent && parent.parentNode ) {
parent.parentNode.selectedIndex; parent.parentNode.selectedIndex;
} }
return null; return null;
},
set: function( elem ) {
/* eslint no-unused-expressions: "off" */
var parent = elem.parentNode;
if ( parent ) {
parent.selectedIndex;
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
}
} }
}; };
} }
jQuery.each([ jQuery.each( [
"tabIndex", "tabIndex",
"readOnly", "readOnly",
"maxLength", "maxLength",
@ -89,6 +137,6 @@ jQuery.each([
"contentEditable" "contentEditable"
], function() { ], function() {
jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
}); } );
}); } );

View File

@ -1,35 +1,33 @@
define([ define( [
"../var/document",
"../var/support" "../var/support"
], function( support ) { ], function( document, support ) {
(function() { "use strict";
( function() {
var input = document.createElement( "input" ), var input = document.createElement( "input" ),
select = document.createElement( "select" ), select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) ); opt = select.appendChild( document.createElement( "option" ) );
input.type = "checkbox"; input.type = "checkbox";
// Support: iOS<=5.1, Android<=4.2+ // Support: Android <=4.3 only
// Default value for a checkbox should be "on" // Default value for a checkbox should be "on"
support.checkOn = input.value !== ""; support.checkOn = input.value !== "";
// Support: IE<=11+ // Support: IE <=11 only
// Must access selectedIndex to make default options select // Must access selectedIndex to make default options select
support.optSelected = opt.selected; support.optSelected = opt.selected;
// Support: Android<=2.3 // Support: IE <=11 only
// Options inside disabled selects are incorrectly marked as disabled
select.disabled = true;
support.optDisabled = !opt.disabled;
// Support: IE<=11+
// An input loses its value after becoming a radio // An input loses its value after becoming a radio
input = document.createElement( "input" ); input = document.createElement( "input" );
input.value = "t"; input.value = "t";
input.type = "radio"; input.type = "radio";
support.radioValue = input.value === "t"; support.radioValue = input.value === "t";
})(); } )();
return support; return support;
}); } );

View File

@ -1,46 +1,58 @@
define([ define( [
"../core", "../core",
"../core/stripAndCollapse",
"./support", "./support",
"../core/nodeName",
"../var/isFunction",
"../core/init" "../core/init"
], function( jQuery, support ) { ], function( jQuery, stripAndCollapse, support, nodeName, isFunction ) {
"use strict";
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, valueIsFunction,
elem = this[0]; elem = this[ 0 ];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ elem.type ] ||
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" ? // Handle most common string cases
// Handle most common string cases if ( typeof ret === "string" ) {
ret.replace(rreturn, "") : return ret.replace( rreturn, "" );
// Handle cases where value is null/undef or number }
ret == null ? "" : ret;
// Handle cases where value is null/undef or number
return ret == null ? "" : ret;
} }
return; return;
} }
isFunction = jQuery.isFunction( value ); valueIsFunction = isFunction( value );
return this.each(function( i ) { return this.each( function( i ) {
var val; var val;
if ( this.nodeType !== 1 ) { if ( this.nodeType !== 1 ) {
return; return;
} }
if ( isFunction ) { if ( valueIsFunction ) {
val = value.call( this, i, jQuery( this ).val() ); val = value.call( this, i, jQuery( this ).val() );
} else { } else {
val = value; val = value;
@ -53,55 +65,66 @@ jQuery.fn.extend({
} else if ( typeof val === "number" ) { } else if ( typeof val === "number" ) {
val += ""; val += "";
} else if ( jQuery.isArray( val ) ) { } else if ( Array.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 ) {
var val = jQuery.find.attr( elem, "value" ); var val = jQuery.find.attr( elem, "value" );
return val != null ? return val != null ?
val : val :
// Support: IE10-11+
// option.text throws exceptions (#14686, #14858) // Support: IE <=10 - 11 only
jQuery.trim( jQuery.text( elem ) ); // option.text throws exceptions (trac-14686, trac-14858)
// Strip and collapse whitespace
// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
stripAndCollapse( jQuery.text( elem ) );
} }
}, },
select: { select: {
get: function( elem ) { get: function( elem ) {
var value, option, var value, option, i,
options = elem.options, options = elem.options,
index = elem.selectedIndex, index = elem.selectedIndex,
one = elem.type === "select-one" || index < 0, one = elem.type === "select-one",
values = one ? null : [], values = one ? null : [],
max = one ? index + 1 : options.length, max = one ? index + 1 : options.length;
i = index < 0 ?
max : if ( index < 0 ) {
one ? index : 0; i = max;
} else {
i = one ? index : 0;
}
// Loop through all the selected options // Loop through all the selected options
for ( ; i < max; i++ ) { for ( ; i < max; i++ ) {
option = options[ i ]; option = options[ i ];
// IE6-9 doesn't update selected after form reset (#2551) // Support: IE <=9 only
// IE8-9 doesn't update selected after form reset (trac-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 ? !option.disabled : option.getAttribute( "disabled" ) === null ) && !option.disabled &&
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { ( !option.parentNode.disabled ||
!nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option // Get the specific value for the option
value = jQuery( option ).val(); value = jQuery( option ).val();
@ -127,9 +150,16 @@ jQuery.extend({
while ( i-- ) { while ( i-- ) {
option = options[ i ]; option = options[ i ];
if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
/* eslint-disable no-cond-assign */
if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true; optionSet = true;
} }
/* eslint-enable no-cond-assign */
} }
// Force browsers to behave consistently when non-matching value is set // Force browsers to behave consistently when non-matching value is set
@ -140,22 +170,22 @@ jQuery.extend({
} }
} }
} }
}); } );
// 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 ( Array.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); 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;
}; };
} }
}); } );
}); } );

View File

@ -1,17 +1,18 @@
define([ define( [
"./core", "./core",
"./var/rnotwhite" "./core/toType",
], function( jQuery, rnotwhite ) { "./var/isFunction",
"./var/rnothtmlwhite"
], function( jQuery, toType, isFunction, rnothtmlwhite ) {
// String to Object options format cache "use strict";
var optionsCache = {};
// Convert String-formatted options into Object-formatted ones and store in cache // Convert String-formatted options into Object-formatted ones
function createOptions( options ) { function createOptions( options ) {
var object = optionsCache[ options ] = {}; var object = {};
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
object[ flag ] = true; object[ flag ] = true;
}); } );
return object; return object;
} }
@ -42,156 +43,186 @@ jQuery.Callbacks = function( options ) {
// Convert options from String-formatted to Object-formatted if needed // Convert options from String-formatted to Object-formatted if needed
// (we check in cache first) // (we check in cache first)
options = typeof options === "string" ? options = typeof options === "string" ?
( optionsCache[ options ] || createOptions( options ) ) : createOptions( options ) :
jQuery.extend( {}, options ); jQuery.extend( {}, options );
var // Last fire value (for non-forgettable lists) var // Flag to know if list is currently firing
firing,
// 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 know if list is currently firing
firing, // Flag to prevent firing
// First callback to fire (used internally by add and fireWith) locked,
firingStart,
// End of the loop when firing
firingLength,
// Index of currently firing callback (modified by remove if needed)
firingIndex,
// Actual callback list // Actual callback list
list = [], list = [],
// Stack of fire calls for repeatable lists
stack = !options.once && [], // Queue of execution data for repeatable lists
queue = [],
// Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1,
// Fire callbacks // Fire callbacks
fire = function( data ) { fire = function() {
memory = options.memory && data;
fired = true; // Enforce single-firing
firingIndex = firingStart || 0; locked = locked || options.once;
firingStart = 0;
firingLength = list.length; // Execute callbacks for all pending executions,
firing = true; // respecting firingIndex overrides and runtime changes
for ( ; list && firingIndex < firingLength; firingIndex++ ) { fired = firing = true;
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { for ( ; queue.length; firingIndex = -1 ) {
memory = false; // To prevent further calls using add memory = queue.shift();
break; while ( ++firingIndex < list.length ) {
// Run callback and check for early termination
if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
options.stopOnFalse ) {
// Jump to end and forget the data so .add doesn't re-fire
firingIndex = list.length;
memory = false;
}
} }
} }
// Forget the data if we're done with it
if ( !options.memory ) {
memory = false;
}
firing = false; firing = false;
if ( list ) {
if ( stack ) { // Clean up if we're done firing for good
if ( stack.length ) { if ( locked ) {
fire( stack.shift() );
} // Keep an empty list if we have data for future add calls
} else if ( memory ) { if ( memory ) {
list = []; list = [];
// Otherwise, this object is spent
} else { } else {
self.disable(); list = "";
} }
} }
}, },
// Actual Callbacks object // Actual Callbacks object
self = { self = {
// Add a callback or a collection of callbacks to the list // Add a callback or a collection of callbacks to the list
add: function() { add: function() {
if ( list ) { if ( list ) {
// First, we save the current length
var start = list.length; // If we have memory from a past run, we should fire after adding
(function add( args ) { if ( memory && !firing ) {
firingIndex = list.length - 1;
queue.push( memory );
}
( function add( args ) {
jQuery.each( args, function( _, arg ) { jQuery.each( args, function( _, arg ) {
var type = jQuery.type( arg ); if ( isFunction( arg ) ) {
if ( type === "function" ) {
if ( !options.unique || !self.has( arg ) ) { if ( !options.unique || !self.has( arg ) ) {
list.push( arg ); list.push( arg );
} }
} else if ( arg && arg.length && type !== "string" ) { } else if ( arg && arg.length && toType( arg ) !== "string" ) {
// Inspect recursively // Inspect recursively
add( arg ); add( arg );
} }
}); } );
})( arguments ); } )( arguments );
// Do we need to add the callbacks to the
// current firing batch? if ( memory && !firing ) {
if ( firing ) { fire();
firingLength = list.length;
// With memory, if we're not firing then
// we should call right away
} else if ( memory ) {
firingStart = start;
fire( memory );
} }
} }
return this; return this;
}, },
// Remove a callback from the list // Remove a callback from the list
remove: function() { remove: function() {
if ( list ) { jQuery.each( arguments, function( _, arg ) {
jQuery.each( arguments, function( _, arg ) { var index;
var index; while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 );
list.splice( index, 1 );
// Handle firing indexes // Handle firing indexes
if ( firing ) { if ( index <= firingIndex ) {
if ( index <= firingLength ) { firingIndex--;
firingLength--;
}
if ( index <= firingIndex ) {
firingIndex--;
}
}
} }
}); }
} } );
return this; return this;
}, },
// Check if a given callback is in the list. // Check if a given callback is in the list.
// If no argument is given, return whether or not list has callbacks attached. // If no argument is given, return whether or not list has callbacks attached.
has: function( fn ) { has: function( fn ) {
return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); return fn ?
jQuery.inArray( fn, list ) > -1 :
list.length > 0;
}, },
// Remove all callbacks from the list // Remove all callbacks from the list
empty: function() { empty: function() {
list = []; if ( list ) {
firingLength = 0; list = [];
return this;
},
// Have the list do nothing anymore
disable: function() {
list = stack = memory = undefined;
return this;
},
// Is it disabled?
disabled: function() {
return !list;
},
// Lock the list in its current state
lock: function() {
stack = undefined;
if ( !memory ) {
self.disable();
} }
return this; return this;
}, },
// Is it locked?
locked: function() { // Disable .fire and .add
return !stack; // Abort any current/pending executions
// Clear all callbacks and values
disable: function() {
locked = queue = [];
list = memory = "";
return this;
}, },
disabled: function() {
return !list;
},
// Disable .fire
// Also disable .add unless we have memory (since it would have no effect)
// Abort any pending executions
lock: function() {
locked = queue = [];
if ( !memory && !firing ) {
list = memory = "";
}
return this;
},
locked: function() {
return !!locked;
},
// Call all callbacks with the given context and arguments // Call all callbacks with the given context and arguments
fireWith: function( context, args ) { fireWith: function( context, args ) {
if ( list && ( !fired || stack ) ) { if ( !locked ) {
args = args || []; args = args || [];
args = [ context, args.slice ? args.slice() : args ]; args = [ context, args.slice ? args.slice() : args ];
if ( firing ) { queue.push( args );
stack.push( args ); if ( !firing ) {
} else { fire();
fire( args );
} }
} }
return this; return this;
}, },
// Call all the callbacks with the given arguments // Call all the callbacks with the given arguments
fire: function() { fire: function() {
self.fireWith( this, arguments ); self.fireWith( this, arguments );
return this; return this;
}, },
// To know if the callbacks have already been called at least once // To know if the callbacks have already been called at least once
fired: function() { fired: function() {
return !!fired; return !!fired;
@ -202,4 +233,4 @@ jQuery.Callbacks = function( options ) {
}; };
return jQuery; return jQuery;
}); } );

View File

@ -1,50 +1,49 @@
define([ /* global Symbol */
// Defining this global in .eslintrc.json would create a danger of using the global
// unguarded in another place, it seems safer to define global only for this module
define( [
"./var/arr", "./var/arr",
"./var/getProto",
"./var/slice", "./var/slice",
"./var/concat", "./var/flat",
"./var/push", "./var/push",
"./var/indexOf", "./var/indexOf",
"./var/class2type", "./var/class2type",
"./var/toString", "./var/toString",
"./var/hasOwn", "./var/hasOwn",
"./var/support" "./var/fnToString",
], function( arr, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { "./var/ObjectFunctionString",
"./var/support",
"./var/isFunction",
"./var/isWindow",
"./core/DOMEval",
"./core/toType"
], function( arr, getProto, slice, flat, push, indexOf,
class2type, toString, hasOwn, fnToString, ObjectFunctionString,
support, isFunction, isWindow, DOMEval, toType ) {
var "use strict";
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
version = "@VERSION", var version = "3.7.1",
rhtmlSuffix = /HTML$/i,
// 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
// Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
// Matches dashed string for camelizing
rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi,
// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
}; };
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,
@ -55,13 +54,14 @@ jQuery.fn = jQuery.prototype = {
// Get the Nth element in the matched element set OR // Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array // Get the whole matched element set as a clean array
get: function( num ) { get: function( num ) {
return num != null ?
// Return just the one element from the set // Return all the elements in a clean array
( num < 0 ? this[ num + this.length ] : this[ num ] ) : if ( num == null ) {
return slice.call( this );
}
// Return all the elements in a clean array // Return just the one element from the set
slice.call( this ); return num < 0 ? this[ num + this.length ] : this[ num ];
}, },
// Take an array of elements and push it onto the stack // Take an array of elements and push it onto the stack
@ -73,23 +73,20 @@ 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;
}, },
// Execute a callback for every element in the matched set. // Execute a callback for every element in the matched set.
// (You can seed the arguments with an array of args, but this is each: function( callback ) {
// only used internally.) return jQuery.each( this, callback );
each: function( callback, args ) {
return jQuery.each( this, callback, args );
}, },
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() {
@ -104,14 +101,26 @@ jQuery.fn = jQuery.prototype = {
return this.eq( -1 ); return this.eq( -1 );
}, },
even: function() {
return this.pushStack( jQuery.grep( this, function( _elem, i ) {
return ( i + 1 ) % 2;
} ) );
},
odd: function() {
return this.pushStack( jQuery.grep( this, function( _elem, i ) {
return i % 2;
} ) );
},
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.
@ -123,7 +132,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.extend = jQuery.fn.extend = function() { jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone, var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {}, target = arguments[ 0 ] || {},
i = 1, i = 1,
length = arguments.length, length = arguments.length,
deep = false; deep = false;
@ -138,7 +147,7 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
// 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" && !isFunction( target ) ) {
target = {}; target = {};
} }
@ -149,27 +158,34 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
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 ];
copy = options[ name ]; copy = options[ name ];
// Prevent Object.prototype pollution
// Prevent never-ending loop // Prevent never-ending loop
if ( target === copy ) { if ( name === "__proto__" || target === copy ) {
continue; continue;
} }
// Recurse if we're merging plain objects or arrays // Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
if ( copyIsArray ) { ( copyIsArray = Array.isArray( copy ) ) ) ) {
copyIsArray = false; src = target[ name ];
clone = src && jQuery.isArray(src) ? src : [];
// Ensure proper type for the source value
if ( copyIsArray && !Array.isArray( src ) ) {
clone = [];
} else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
clone = {};
} else { } else {
clone = src && jQuery.isPlainObject(src) ? src : {}; clone = src;
} }
copyIsArray = false;
// Never move original objects, clone them // Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy ); target[ name ] = jQuery.extend( deep, clone, copy );
@ -186,7 +202,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, "" ),
@ -199,138 +216,56 @@ jQuery.extend({
noop: function() {}, noop: function() {},
isFunction: function( obj ) {
return jQuery.type(obj) === "function";
},
isArray: Array.isArray,
isWindow: function( obj ) {
return obj != null && obj === obj.window;
},
isNumeric: function( obj ) {
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
// adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
},
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
// Not plain objects: var proto, Ctor;
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// - DOM nodes // Detect obvious negatives
// - window // Use toString instead of jQuery.type to catch host objects
if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { if ( !obj || toString.call( obj ) !== "[object Object]" ) {
return false; return false;
} }
if ( obj.constructor && proto = getProto( obj );
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false; // Objects with no prototype (e.g., `Object.create( null )`) are plain
if ( !proto ) {
return true;
} }
// If the function hasn't returned already, we're confident that // Objects with prototype are plain iff they were constructed by a global Object function
// |obj| is a plain object, created by {} or constructed with new Object Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
return true; return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
}, },
isEmptyObject: function( obj ) { isEmptyObject: function( obj ) {
var name; var name;
for ( name in obj ) { for ( name in obj ) {
return false; return false;
} }
return true; return true;
}, },
type: function( obj ) { // Evaluates a script in a provided context; falls back to the global one
if ( obj == null ) { // if not specified.
return obj + ""; globalEval: function( code, options, doc ) {
} DOMEval( code, { nonce: options && options.nonce }, doc );
// Support: Android<4.0, iOS<6 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" :
typeof obj;
}, },
// Evaluates a script in a global context each: function( obj, callback ) {
globalEval: function( code ) { var length, i = 0;
var script,
indirect = eval;
code = jQuery.trim( code ); if ( isArrayLike( obj ) ) {
length = obj.length;
if ( code ) { for ( ; i < length; i++ ) {
// If the code includes a valid, prologue position if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
// strict mode pragma, execute code by injecting a break;
// script tag into the document.
if ( code.indexOf("use strict") === 1 ) {
script = document.createElement("script");
script.text = code;
document.head.appendChild( script ).parentNode.removeChild( script );
} else {
// Otherwise, avoid the DOM node creation, insertion
// and removal by using an indirect global eval
indirect( code );
}
}
},
// Convert dashed to camelCase; used by the css and data modules
// Support: IE9-11+
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
},
// args is for internal usage only
each: function( obj, callback, args ) {
var value,
i = 0,
length = obj.length,
isArray = isArraylike( obj );
if ( args ) {
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback.apply( obj[ i ], args );
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.apply( obj[ i ], args );
if ( value === false ) {
break;
}
} }
} }
// A special, fast, case for the most common use of each
} else { } else {
if ( isArray ) { for ( i in obj ) {
for ( ; i < length; i++ ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
value = callback.call( obj[ i ], i, obj[ i ] ); break;
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.call( obj[ i ], i, obj[ i ] );
if ( value === false ) {
break;
}
} }
} }
} }
@ -338,11 +273,36 @@ jQuery.extend({
return obj; return obj;
}, },
// Support: Android<4.1
trim: function( text ) { // Retrieve the text value of an array of DOM nodes
return text == null ? text: function( elem ) {
"" : var node,
( text + "" ).replace( rtrim, "" ); ret = "",
i = 0,
nodeType = elem.nodeType;
if ( !nodeType ) {
// If no nodeType, this is expected to be an array
while ( ( node = elem[ i++ ] ) ) {
// Do not traverse comment nodes
ret += jQuery.text( node );
}
}
if ( nodeType === 1 || nodeType === 11 ) {
return elem.textContent;
}
if ( nodeType === 9 ) {
return elem.documentElement.textContent;
}
if ( nodeType === 3 || nodeType === 4 ) {
return elem.nodeValue;
}
// Do not include comment or processing instruction nodes
return ret;
}, },
// results is for internal usage only // results is for internal usage only
@ -350,10 +310,10 @@ 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
); );
} else { } else {
push.call( ret, arr ); push.call( ret, arr );
@ -367,6 +327,17 @@ jQuery.extend({
return arr == null ? -1 : indexOf.call( arr, elem, i ); return arr == null ? -1 : indexOf.call( arr, elem, i );
}, },
isXMLDoc: function( elem ) {
var namespace = elem && elem.namespaceURI,
docElem = elem && ( elem.ownerDocument || elem ).documentElement;
// Assume HTML when documentElement doesn't yet exist, such as inside
// document fragments.
return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
},
// Support: Android <=4.0 only, PhantomJS 1 only
// 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,
@ -402,14 +373,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 );
@ -430,73 +400,43 @@ jQuery.extend({
} }
// Flatten any nested arrays // Flatten any nested arrays
return concat.apply( [], ret ); return flat( ret );
}, },
// A global GUID counter for objects // A global GUID counter for objects
guid: 1, guid: 1,
// Bind a function to a context, optionally partially applying any
// arguments.
proxy: function( fn, context ) {
var tmp, args, proxy;
if ( typeof context === "string" ) {
tmp = fn[ context ];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( !jQuery.isFunction( fn ) ) {
return undefined;
}
// Simulated bind
args = slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
},
now: Date.now,
// 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
}); } );
if ( typeof Symbol === "function" ) {
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
}
// Populate the class2type map // Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
class2type[ "[object " + name + "]" ] = name.toLowerCase(); function( _i, name ) {
}); class2type[ "[object " + name + "]" ] = name.toLowerCase();
} );
function isArraylike( obj ) { function isArrayLike( obj ) {
// Support: iOS 8.2 (not reproducible in simulator) // Support: real iOS 8.2 only (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 = toType( obj );
if ( type === "function" || jQuery.isWindow( obj ) ) { if ( isFunction( obj ) || isWindow( obj ) ) {
return false; return false;
} }
if ( obj.nodeType === 1 && length ) {
return true;
}
return type === "array" || length === 0 || return type === "array" || length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj; typeof length === "number" && length > 0 && ( length - 1 ) in obj;
} }
return jQuery; return jQuery;
}); } );

View File

@ -0,0 +1,43 @@
define( [
"../var/document"
], function( document ) {
"use strict";
var preservedScriptAttributes = {
type: true,
src: true,
nonce: true,
noModule: true
};
function DOMEval( code, node, doc ) {
doc = doc || document;
var i, val,
script = doc.createElement( "script" );
script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
// Support: Firefox 64+, Edge 18+
// Some browsers don't support the "nonce" property on scripts.
// On the other hand, just using `getAttribute` is not enough as
// the `nonce` attribute is reset to an empty string whenever it
// becomes browsing-context connected.
// See https://github.com/whatwg/html/issues/2369
// See https://html.spec.whatwg.org/#nonce-attributes
// The `node.getAttribute` check was added for the sake of
// `jQuery.globalEval` so that it can fake a nonce-containing node
// via an object.
val = node[ i ] || node.getAttribute && node.getAttribute( i );
if ( val ) {
script.setAttribute( i, val );
}
}
}
doc.head.appendChild( script ).parentNode.removeChild( script );
}
return DOMEval;
} );

View File

@ -1,30 +1,35 @@
define([ define( [
"../core" "../core",
], function( jQuery ) { "../core/toType",
"../var/isFunction"
], function( jQuery, toType, isFunction ) {
"use strict";
// 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, len = elems.length,
bulk = key == null; bulk = key == null;
// Sets many values // Sets many values
if ( jQuery.type( key ) === "object" ) { if ( toType( key ) === "object" ) {
chainable = true; chainable = true;
for ( i in key ) { for ( i in key ) {
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); access( elems, fn, i, key[ i ], true, emptyGet, raw );
} }
// Sets one value // Sets one value
} else if ( value !== undefined ) { } else if ( value !== undefined ) {
chainable = true; chainable = true;
if ( !jQuery.isFunction( value ) ) { if ( !isFunction( value ) ) {
raw = true; raw = true;
} }
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 );
@ -33,7 +38,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
// ...except when executing function values // ...except when executing function values
} else { } else {
bulk = fn; bulk = fn;
fn = function( elem, key, value ) { fn = function( elem, _key, value ) {
return bulk.call( jQuery( elem ), value ); return bulk.call( jQuery( elem ), value );
}; };
} }
@ -41,20 +46,27 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
if ( fn ) { if ( fn ) {
for ( ; i < len; i++ ) { for ( ; i < len; 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 ) )
);
} }
} }
} }
return chainable ? if ( chainable ) {
elems : return elems;
}
// Gets // Gets
bulk ? if ( bulk ) {
fn.call( elems ) : return fn.call( elems );
len ? fn( elems[0], key ) : emptyGet; }
return len ? fn( elems[ 0 ], key ) : emptyGet;
}; };
return access; return access;
}); } );

View File

@ -0,0 +1,23 @@
define( [], function() {
"use strict";
// Matches dashed string for camelizing
var rmsPrefix = /^-ms-/,
rdashAlpha = /-([a-z])/g;
// Used by camelCase as callback to replace()
function fcamelCase( _all, letter ) {
return letter.toUpperCase();
}
// Convert dashed to camelCase; used by the css and data modules
// Support: IE <=9 - 11, Edge 12 - 15
// Microsoft forgot to hump their vendor prefix (trac-9572)
function camelCase( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
}
return camelCase;
} );

View File

@ -1,19 +1,25 @@
// Initialize a jQuery object // Initialize a jQuery object
define([ define( [
"../core", "../core",
"../var/document",
"../var/isFunction",
"./var/rsingleTag", "./var/rsingleTag",
"../traversing/findFilter" "../traversing/findFilter"
], function( jQuery, rsingleTag ) { ], function( jQuery, document, isFunction, rsingleTag ) {
"use strict";
// A central reference to the root jQuery(document) // A central reference to the root jQuery(document)
var rootjQuery, 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 (trac-9521)
// Strict HTML recognition (#11290: must start with <) // Strict HTML recognition (trac-11290: must start with <)
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, // Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context ) { init = jQuery.fn.init = function( selector, context, root ) {
var match, elem; var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false) // HANDLE: $(""), $(null), $(undefined), $(false)
@ -21,9 +27,16 @@ var rootjQuery,
return this; return this;
} }
// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
// Handle HTML strings // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
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
match = [ null, selector, null ]; match = [ null, selector, null ];
@ -32,25 +45,26 @@ 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 // Option to run 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 ( isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] ); this[ match ]( context[ match ] );
// ...and otherwise set as attributes // ...and otherwise set as attributes
@ -64,24 +78,20 @@ var rootjQuery,
// HANDLE: $(#id) // HANDLE: $(#id)
} else { } else {
elem = document.getElementById( match[2] ); elem = document.getElementById( match[ 2 ] );
if ( elem ) {
// Support: Blackberry 4.6
// gEBID returns nodes no longer in the document (#6963)
if ( elem && elem.parentNode ) {
// Inject the element directly into the jQuery object // Inject the element directly into the jQuery object
this[ 0 ] = elem;
this.length = 1; this.length = 1;
this[0] = elem;
} }
this.context = document;
this.selector = selector;
return this; return this;
} }
// HANDLE: $(expr, $(...)) // HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) { } else if ( !context || context.jquery ) {
return ( context || rootjQuery ).find( selector ); return ( context || root ).find( selector );
// HANDLE: $(expr, context) // HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr) // (which is just equivalent to: $(context).find(expr)
@ -91,24 +101,20 @@ var rootjQuery,
// HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
} else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
this.context = this[0] = selector; this[ 0 ] = selector;
this.length = 1; this.length = 1;
return this; return this;
// HANDLE: $(function) // HANDLE: $(function)
// Shortcut for document ready // Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) { } else if ( isFunction( selector ) ) {
return typeof rootjQuery.ready !== "undefined" ? return root.ready !== undefined ?
rootjQuery.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 );
}; };
@ -120,4 +126,4 @@ rootjQuery = jQuery( document );
return init; return init;
}); } );

View File

@ -0,0 +1,26 @@
define( [
"../core",
"../var/documentElement",
"../selector/contains" // jQuery.contains
], function( jQuery, documentElement ) {
"use strict";
var isAttached = function( elem ) {
return jQuery.contains( elem.ownerDocument, elem );
},
composed = { composed: true };
// Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
// Check attachment across shadow DOM boundaries when possible (gh-3504)
// Support: iOS 10.0-10.2 only
// Early iOS 10 versions support `attachShadow` but not `getRootNode`,
// leading to errors. We need to check for `getRootNode`.
if ( documentElement.getRootNode ) {
isAttached = function( elem ) {
return jQuery.contains( elem.ownerDocument, elem ) ||
elem.getRootNode( composed ) === elem.ownerDocument;
};
}
return isAttached;
} );

View File

@ -0,0 +1,13 @@
define( function() {
"use strict";
function nodeName( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
}
return nodeName;
} );

View File

@ -1,31 +1,57 @@
define([ define( [
"../core", "../core",
"../var/document",
"./var/rsingleTag", "./var/rsingleTag",
"../manipulation" // buildFragment "../manipulation/buildFragment",
], function( jQuery, rsingleTag ) {
// data: string of html // This is the only module that needs core/support
// context (optional): If specified, the fragment will be created in this context, defaults to document "./support"
], function( jQuery, document, rsingleTag, buildFragment, support ) {
"use strict";
// Argument "data" should be string of html
// context (optional): If specified, the fragment will be created in this context,
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) { jQuery.parseHTML = function( data, context, keepScripts ) {
if ( !data || typeof data !== "string" ) { if ( typeof data !== "string" ) {
return null; return [];
} }
if ( typeof context === "boolean" ) { if ( typeof context === "boolean" ) {
keepScripts = context; keepScripts = context;
context = false; context = false;
} }
context = context || document;
var parsed = rsingleTag.exec( data ), var base, parsed, scripts;
scripts = !keepScripts && [];
if ( !context ) {
// Stop scripts or inline event handlers from being executed immediately
// by using document.implementation
if ( support.createHTMLDocument ) {
context = document.implementation.createHTMLDocument( "" );
// Set the base href for the created document
// so any parsed elements with URLs
// are based on the document's URL (gh-2965)
base = context.createElement( "base" );
base.href = document.location.href;
context.head.appendChild( base );
} else {
context = document;
}
}
parsed = rsingleTag.exec( data );
scripts = !keepScripts && [];
// Single tag // Single tag
if ( parsed ) { if ( parsed ) {
return [ context.createElement( parsed[1] ) ]; return [ context.createElement( parsed[ 1 ] ) ];
} }
parsed = jQuery.buildFragment( [ data ], context, scripts ); parsed = buildFragment( [ data ], context, scripts );
if ( scripts && scripts.length ) { if ( scripts && scripts.length ) {
jQuery( scripts ).remove(); jQuery( scripts ).remove();
@ -36,4 +62,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
return jQuery.parseHTML; return jQuery.parseHTML;
}); } );

View File

@ -0,0 +1,35 @@
define( [
"../core"
], function( jQuery ) {
"use strict";
// Cross-browser xml parsing
jQuery.parseXML = function( data ) {
var xml, parserErrorElem;
if ( !data || typeof data !== "string" ) {
return null;
}
// Support: IE 9 - 11 only
// IE throws on parseFromString with invalid input.
try {
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
} catch ( e ) {}
parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
if ( !xml || parserErrorElem ) {
jQuery.error( "Invalid XML: " + (
parserErrorElem ?
jQuery.map( parserErrorElem.childNodes, function( el ) {
return el.textContent;
} ).join( "\n" ) :
data
) );
}
return xml;
};
return jQuery.parseXML;
} );

View File

@ -0,0 +1,97 @@
define( [
"../core",
"../var/document",
"../var/isFunction"
], function( jQuery, document, isFunction ) {
"use strict";
var readyCallbacks = [],
whenReady = function( fn ) {
readyCallbacks.push( fn );
},
executeReady = function( fn ) {
// Prevent errors from freezing future callback execution (gh-1823)
// Not backwards-compatible as this does not execute sync
window.setTimeout( function() {
fn.call( document, jQuery );
} );
};
jQuery.fn.ready = function( fn ) {
whenReady( fn );
return this;
};
jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See trac-6781
readyWait: 1,
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
whenReady = function( fn ) {
readyCallbacks.push( fn );
while ( readyCallbacks.length ) {
fn = readyCallbacks.shift();
if ( isFunction( fn ) ) {
executeReady( fn );
}
}
};
whenReady();
}
} );
// Make jQuery.ready Promise consumable (gh-1778)
jQuery.ready.then = jQuery.fn.ready;
/**
* The ready event handler and self cleanup method
*/
function completed() {
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
jQuery.ready();
}
// Catch cases where $(document).ready() is called
// after the browser event has already occurred.
// Support: IE9-10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
} else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed );
}
} );

View File

@ -1,36 +1,39 @@
define([ define( [
"../core", "../core",
"../core/init", "../var/document",
"../core/readyException",
"../deferred" "../deferred"
], function( jQuery ) { ], function( jQuery, document ) {
"use strict";
// The deferred used on DOM ready // The deferred used on DOM ready
var readyList; var readyList = jQuery.Deferred();
jQuery.fn.ready = function( fn ) { jQuery.fn.ready = function( fn ) {
// Add the callback
jQuery.ready.promise().done( fn ); readyList
.then( fn )
// Wrap jQuery.readyException in a function so that the lookup
// happens at the time of error handling instead of callback
// registration.
.catch( function( error ) {
jQuery.readyException( error );
} );
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,
// A counter to track how many items to wait for before // A counter to track how many items to wait for before
// the ready event fires. See #6781 // the ready event fires. See trac-6781
readyWait: 1, readyWait: 1,
// Hold (or release) the ready event
holdReady: function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
},
// Handle when the DOM is ready // Handle when the DOM is ready
ready: function( wait ) { ready: function( wait ) {
@ -49,49 +52,35 @@ 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" );
}
} }
}); } );
/** jQuery.ready.then = readyList.then;
* The ready event handler and self cleanup method
*/ // The ready event handler and self cleanup method
function completed() { function completed() {
document.removeEventListener( "DOMContentLoaded", completed, false ); document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed, false ); window.removeEventListener( "load", completed );
jQuery.ready(); jQuery.ready();
} }
jQuery.ready.promise = function( obj ) { // Catch cases where $(document).ready() is called
if ( !readyList ) { // after the browser event has already occurred.
// Support: IE <=9 - 10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
readyList = jQuery.Deferred(); // Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
// Catch cases where $(document).ready() is called after the browser event has already occurred. } else {
// We once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready );
} else { // Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
// Use the handy event callback // A fallback to window.onload, that will always work
document.addEventListener( "DOMContentLoaded", completed, false ); window.addEventListener( "load", completed );
}
// A fallback to window.onload, that will always work } );
window.addEventListener( "load", completed, false );
}
}
return readyList.promise( obj );
};
// Kick off the DOM ready check even if the user does not
jQuery.ready.promise();
});

View File

@ -0,0 +1,13 @@
define( [
"../core"
], function( jQuery ) {
"use strict";
jQuery.readyException = function( error ) {
window.setTimeout( function() {
throw error;
} );
};
} );

View File

@ -0,0 +1,14 @@
define( [
"../var/rnothtmlwhite"
], function( rnothtmlwhite ) {
"use strict";
// Strip and collapse whitespace according to HTML spec
// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
function stripAndCollapse( value ) {
var tokens = value.match( rnothtmlwhite ) || [];
return tokens.join( " " );
}
return stripAndCollapse;
} );

View File

@ -0,0 +1,20 @@
define( [
"../var/document",
"../var/support"
], function( document, support ) {
"use strict";
// Support: Safari 8 only
// In Safari 8 documents created via document.implementation.createHTMLDocument
// collapse sibling forms: the second one becomes a child of the first one.
// 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() {
var body = document.implementation.createHTMLDocument( "" ).body;
body.innerHTML = "<form></form><form></form>";
return body.childNodes.length === 2;
} )();
return support;
} );

View File

@ -0,0 +1,20 @@
define( [
"../var/class2type",
"../var/toString"
], function( class2type, toString ) {
"use strict";
function toType( obj ) {
if ( obj == null ) {
return obj + "";
}
// Support: Android <=2.3 only (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call( obj ) ] || "object" :
typeof obj;
}
return toType;
} );

View File

@ -0,0 +1,7 @@
define( function() {
"use strict";
return ( /HTML$/i );
} );

View File

@ -1,4 +1,7 @@
define(function() { define( function() {
// Match a standalone tag "use strict";
return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
}); // rsingleTag matches a string consisting of a single HTML element with no attributes
// and captures the element's name
return ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
} );

View File

@ -1,206 +1,201 @@
define([ define( [
"./core", "./core",
"./var/pnum",
"./core/access", "./core/access",
"./css/var/rmargin", "./core/camelCase",
"./core/nodeName",
"./var/rcssNum",
"./css/var/rnumnonpx", "./css/var/rnumnonpx",
"./css/var/rcustomProp",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/var/isHidden",
"./css/var/getStyles", "./css/var/getStyles",
"./css/var/swap",
"./css/curCSS", "./css/curCSS",
"./css/defaultDisplay", "./css/adjustCSS",
"./css/addGetHookIf", "./css/addGetHookIf",
"./css/support", "./css/support",
"./data/var/data_priv", "./css/finalPropName",
"./core/init", "./core/init",
"./css/swap",
"./core/ready", "./core/ready",
"./selector" // contains "./selector" // contains
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden, ], function( jQuery, access, camelCase, nodeName, rcssNum, rnumnonpx,
getStyles, curCSS, defaultDisplay, addGetHookIf, support, data_priv ) { rcustomProp, cssExpand, getStyles, swap, curCSS, adjustCSS, addGetHookIf,
support, finalPropName ) {
"use strict";
var var
// Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// 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 // 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" ),
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = { cssNormalTransform = {
letterSpacing: "0", letterSpacing: "0",
fontWeight: "400" fontWeight: "400"
}, };
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; function setPositiveNumber( _elem, value, subtract ) {
// Return a css property mapped to a potentially vendor prefixed property // Any relative (+/-) values have already been
function vendorPropName( style, name ) { // normalized at this point
var matches = rcssNum.exec( value );
// Shortcut for names that are not vendor prefixed
if ( name in style ) {
return name;
}
// Check for vendor prefixed names
var capName = name[0].toUpperCase() + name.slice(1),
origName = name,
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in style ) {
return name;
}
}
return origName;
}
function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value );
return matches ? return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks // Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
value; value;
} }
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ? var i = dimension === "width" ? 1 : 0,
// If we already have the right measurement, avoid augmentation extra = 0,
4 : delta = 0,
// Otherwise initialize for horizontal or vertical properties marginDelta = 0;
name === "width" ? 1 : 0,
val = 0; // Adjustment may not be necessary
if ( box === ( isBorderBox ? "border" : "content" ) ) {
return 0;
}
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { // Both box models exclude margin
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); // Count margin delta separately to only add it after scroll gutter adjustment.
// This is needed to make negative margins work with `outerHeight( true )` (gh-3982).
if ( box === "margin" ) {
marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
} }
if ( isBorderBox ) { // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
// border-box includes padding, so remove it if we want content if ( !isBorderBox ) {
if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); // Add padding
delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// For "border" or "margin", add border
if ( box !== "padding" ) {
delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
// But still keep track of it otherwise
} else {
extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
// At this point, extra isn't border nor margin, so remove border // If we get here with a border-box (content + padding + border), we're seeking "content" or
if ( extra !== "margin" ) { // "padding" or "margin"
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
} else { } else {
// At this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// At this point, extra isn't content nor padding, so add border // For "content", subtract padding
if ( extra !== "padding" ) { if ( box === "content" ) {
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
}
// For "content" or "padding", subtract border
if ( box !== "margin" ) {
delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
} }
} }
return val; // Account for positive content-box scroll gutter when requested by providing computedVal
if ( !isBorderBox && computedVal >= 0 ) {
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
// Assuming integer scroll gutter, subtract the rest and round down
delta += Math.max( 0, Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
computedVal -
delta -
extra -
0.5
// If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
// Use an explicit zero to avoid NaN (gh-3964)
) ) || 0;
}
return delta + marginDelta;
} }
function getWidthOrHeight( elem, name, extra ) { function getWidthOrHeight( elem, dimension, extra ) {
// Start with offset property, which is equivalent to the border-box value // Start with computed style
var valueIsBorderBox = true, var styles = getStyles( elem ),
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Some non-html elements return undefined for offsetWidth, so check for null/undefined // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // Fake content-box until we know it's needed to know the true value.
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 boxSizingNeeded = !support.boxSizingReliable() || extra,
if ( val <= 0 || val == null ) { isBorderBox = boxSizingNeeded &&
// Fall back to computed then uncomputed css if necessary jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
val = curCSS( elem, name, styles ); valueIsBorderBox = isBorderBox,
if ( val < 0 || val == null ) {
val = elem.style[ name ];
}
// Computed unit is not pixels. Stop here and return. val = curCSS( elem, dimension, styles ),
if ( rnumnonpx.test(val) ) { offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
// Support: Firefox <=54
// Return a confounding non-pixel value or feign ignorance, as appropriate.
if ( rnumnonpx.test( val ) ) {
if ( !extra ) {
return val; return val;
} }
val = "auto";
// Check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] );
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
} }
// Use the active box-sizing model to add/subtract irrelevant styles
// Support: IE 9 - 11 only
// Use offsetWidth/offsetHeight for when box sizing is unreliable.
// In those cases, the computed value can be trusted to be border-box.
if ( ( !support.boxSizingReliable() && isBorderBox ||
// Support: IE 10 - 11+, Edge 15 - 18+
// IE/Edge misreport `getComputedStyle` of table rows with width/height
// set in CSS while `offset*` properties report correct values.
// Interestingly, in some cases IE 9 doesn't suffer from this issue.
!support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
// Fall back to offsetWidth/offsetHeight when value is "auto"
// This happens for inline elements with no explicit setting (gh-3571)
val === "auto" ||
// Support: Android <=4.1 - 4.3 only
// Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
!parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
// Make sure the element is visible & connected
elem.getClientRects().length ) {
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Where available, offsetWidth/offsetHeight approximate border box dimensions.
// Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
// retrieved value as a content box dimension.
valueIsBorderBox = offsetProp in elem;
if ( valueIsBorderBox ) {
val = elem[ offsetProp ];
}
}
// Normalize "" and auto
val = parseFloat( val ) || 0;
// Adjust for the element's box model
return ( val + return ( val +
augmentWidthOrHeight( boxModelAdjustment(
elem, elem,
name, dimension,
extra || ( isBorderBox ? "border" : "content" ), extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox, valueIsBorderBox,
styles styles,
// Provide the current computed size to request scroll gutter calculation (gh-3589)
val
) )
) + "px"; ) + "px";
} }
function showHide( elements, show ) { jQuery.extend( {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
values[ index ] = data_priv.get( elem, "olddisplay" );
display = elem.style.display;
if ( show ) {
// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if ( !values[ index ] && display === "none" ) {
elem.style.display = "";
}
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if ( elem.style.display === "" && isHidden( elem ) ) {
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
}
} else {
hidden = isHidden( elem );
if ( display !== "none" || !hidden ) {
data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
}
}
}
// Set the display of most of the elements in a second loop
// to avoid the constant reflow
for ( index = 0; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
elem.style.display = show ? values[ index ] || "" : "none";
}
}
return elements;
}
jQuery.extend({
// 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
@ -219,25 +214,40 @@ jQuery.extend({
// Don't automatically add "px" to these possibly-unitless properties // Don't automatically add "px" to these possibly-unitless properties
cssNumber: { cssNumber: {
"columnCount": true, animationIterationCount: true,
"fillOpacity": true, aspectRatio: true,
"flexGrow": true, borderImageSlice: true,
"flexShrink": true, columnCount: true,
"fontWeight": true, flexGrow: true,
"lineHeight": true, flexShrink: true,
"opacity": true, fontWeight: true,
"order": true, gridArea: true,
"orphans": true, gridColumn: true,
"widows": true, gridColumnEnd: true,
"zIndex": true, gridColumnStart: true,
"zoom": true gridRow: true,
gridRowEnd: true,
gridRowStart: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
scale: true,
widows: true,
zIndex: true,
zoom: true,
// SVG-related
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeMiterlimit: true,
strokeOpacity: true
}, },
// 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"
},
// Get and set the style property on a DOM Node // Get and set the style property on a DOM Node
style: function( elem, name, value, extra ) { style: function( elem, name, value, extra ) {
@ -249,10 +259,16 @@ jQuery.extend({
// Make sure that we're working with the right name // Make sure that we're working with the right name
var ret, type, hooks, var ret, type, hooks,
origName = jQuery.camelCase( name ), origName = camelCase( name ),
isCustomProp = rcustomProp.test( name ),
style = elem.style; style = elem.style;
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); // Make sure that we're working with the right name. We don't
// want to query the value if it is a CSS custom property
// since they are user-defined.
if ( !isCustomProp ) {
name = finalPropName( origName );
}
// Gets hook for the prefixed version, then unprefixed version // Gets hook for the prefixed version, then unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
@ -261,37 +277,48 @@ jQuery.extend({
if ( value !== undefined ) { if ( value !== undefined ) {
type = typeof value; type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345) // Convert "+=" or "-=" to relative numbers (trac-7345)
if ( type === "string" && (ret = rrelNum.exec( value )) ) { if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); value = adjustCSS( elem, name, ret );
// Fixes bug #9237
// Fixes bug trac-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 (trac-7116)
if ( value == null || value !== value ) { if ( value == null || value !== value ) {
return; return;
} }
// If a number, add 'px' to the (except for certain CSS properties) // If a number was passed in, add the unit (except for certain CSS properties)
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
value += "px"; // "px" to a few hardcoded values.
if ( type === "number" && !isCustomProp ) {
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
} }
// Support: IE9-11+
// background-* props affect original clone's values // background-* props affect original clone's values
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) || (value = hooks.set( elem, value, extra )) !== undefined ) { if ( !hooks || !( "set" in hooks ) ||
style[ name ] = value; ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
if ( isCustomProp ) {
style.setProperty( name, value );
} else {
style[ name ] = value;
}
} }
} 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 && (ret = hooks.get( elem, false, extra )) !== undefined ) { if ( hooks && "get" in hooks &&
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret; return ret;
} }
@ -302,10 +329,15 @@ jQuery.extend({
css: function( elem, name, extra, styles ) { css: function( elem, name, extra, styles ) {
var val, num, hooks, var val, num, hooks,
origName = jQuery.camelCase( name ); origName = camelCase( name ),
isCustomProp = rcustomProp.test( name );
// Make sure that we're working with the right name // Make sure that we're working with the right name. We don't
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); // want to modify the value if it is a CSS custom property
// since they are user-defined.
if ( !isCustomProp ) {
name = finalPropName( origName );
}
// Try prefixed name followed by the unprefixed name // Try prefixed name followed by the unprefixed name
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
@ -328,54 +360,98 @@ jQuery.extend({
// Make numeric if forced or a qualifier was provided and val looks numeric // Make numeric 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, dimension ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ dimension ] = {
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 // but it must have a current display style that would benefit
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
jQuery.swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra ); // Support: Safari 8+
}) : // Table columns in Safari have non-zero offsetWidth & zero
getWidthOrHeight( elem, name, extra ); // 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() {
return getWidthOrHeight( elem, dimension, extra );
} ) :
getWidthOrHeight( elem, dimension, extra );
} }
}, },
set: function( elem, value, extra ) { set: function( elem, value, extra ) {
var styles = extra && getStyles( elem ); var matches,
return setPositiveNumber( elem, value, extra ? styles = getStyles( elem ),
augmentWidthOrHeight(
elem, // Only read styles.position if the test has a chance to fail
name, // to avoid forcing a reflow.
extra, scrollboxSizeBuggy = !support.scrollboxSize() &&
styles.position === "absolute",
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
boxSizingNeeded = scrollboxSizeBuggy || extra,
isBorderBox = boxSizingNeeded &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box", jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles subtract = extra ?
) : 0 boxModelAdjustment(
); elem,
dimension,
extra,
isBorderBox,
styles
) :
0;
// Account for unreliable border-box dimensions by comparing offset* to computed and
// faking a content-box to get border and padding (gh-3699)
if ( isBorderBox && scrollboxSizeBuggy ) {
subtract -= Math.ceil(
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
parseFloat( styles[ dimension ] ) -
boxModelAdjustment( elem, dimension, "border", false, styles ) -
0.5
);
}
// Convert to pixels if value adjustment is needed
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
( matches[ 3 ] || "px" ) !== "px" ) {
elem.style[ dimension ] = value;
value = jQuery.css( elem, dimension );
}
return setPositiveNumber( elem, value, subtract );
} }
}; };
}); } );
// Support: Android 2.3 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
return jQuery.swap( elem, { "display": "inline-block" }, return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
curCSS, [ elem, "marginRight" ] ); elem.getBoundingClientRect().left -
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left;
} )
) + "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"
@ -386,7 +462,7 @@ jQuery.each({
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 ] =
@ -397,19 +473,19 @@ jQuery.each({
} }
}; };
if ( !rmargin.test( prefix ) ) { if ( prefix !== "margin" ) {
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,
map = {}, map = {},
i = 0; i = 0;
if ( jQuery.isArray( name ) ) { if ( Array.isArray( name ) ) {
styles = getStyles( elem ); styles = getStyles( elem );
len = name.length; len = name.length;
@ -424,27 +500,8 @@ jQuery.fn.extend({
jQuery.style( elem, name, value ) : jQuery.style( elem, name, value ) :
jQuery.css( elem, name ); jQuery.css( elem, name );
}, name, value, arguments.length > 1 ); }, name, value, arguments.length > 1 );
},
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each(function() {
if ( isHidden( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
});
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,10 +1,14 @@
define(function() { define( function() {
"use strict";
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 +16,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;
}); } );

View File

@ -0,0 +1,74 @@
define( [
"../core",
"../var/rcssNum"
], function( jQuery, rcssNum ) {
"use strict";
function adjustCSS( elem, prop, valueParts, tween ) {
var adjusted, scale,
maxIterations = 20,
currentValue = tween ?
function() {
return tween.cur();
} :
function() {
return jQuery.css( elem, prop, "" );
},
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = elem.nodeType &&
( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Support: Firefox <=54
// Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
initial = initial / 2;
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
// Iteratively approximate from a nonzero starting point
initialInUnit = +initial || 1;
while ( maxIterations-- ) {
// Evaluate and update our best guess (doubling guesses that zero out).
// Finish if the scale equals or crosses 1 (making the old*new product non-positive).
jQuery.style( elem, prop, initialInUnit + unit );
if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
maxIterations = 0;
}
initialInUnit = initialInUnit / scale;
}
initialInUnit = initialInUnit * 2;
jQuery.style( elem, prop, initialInUnit + unit );
// Make sure we update the tween properties later on
valueParts = valueParts || [];
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+valueParts[ 2 ];
if ( tween ) {
tween.unit = unit;
tween.start = initialInUnit;
tween.end = adjusted;
}
}
return adjusted;
}
return adjustCSS;
} );

View File

@ -1,34 +1,76 @@
define([ define( [
"../core", "../core",
"../core/isAttached",
"./var/rboxStyle",
"./var/rnumnonpx", "./var/rnumnonpx",
"./var/rmargin",
"./var/getStyles", "./var/getStyles",
"../selector" // contains "./var/rcustomProp",
], function( jQuery, rnumnonpx, rmargin, getStyles ) { "../var/rtrimCSS",
"./support"
], function( jQuery, isAttached, rboxStyle, rnumnonpx, getStyles,
rcustomProp, rtrimCSS, support ) {
"use strict";
function curCSS( elem, name, computed ) { function curCSS( elem, name, computed ) {
var width, minWidth, maxWidth, ret, var width, minWidth, maxWidth, ret,
isCustomProp = rcustomProp.test( name ),
// Support: Firefox 51+
// Retrieving style before computed somehow
// fixes an issue with getting wrong values
// on detached elements
style = elem.style; style = elem.style;
computed = computed || getStyles( elem ); computed = computed || getStyles( elem );
// Support: IE9 // getPropertyValue is needed for:
// getPropertyValue is only needed for .css('filter') (#12537) // .css('filter') (IE 9 only, trac-12537)
// .css('--customProperty) (gh-3144)
if ( computed ) { if ( computed ) {
// Support: IE <=9 - 11+
// IE only supports `"float"` in `getPropertyValue`; in computed styles
// it's only available as `"cssFloat"`. We no longer modify properties
// sent to `.css()` apart from camelCasing, so we need to check both.
// Normally, this would create difference in behavior: if
// `getPropertyValue` returns an empty string, the value returned
// by `.css()` would be `undefined`. This is usually the case for
// disconnected elements. However, in IE even disconnected elements
// with no styles return `"none"` for `getPropertyValue( "float" )`
ret = computed.getPropertyValue( name ) || computed[ name ]; ret = computed.getPropertyValue( name ) || computed[ name ];
}
if ( computed ) { if ( isCustomProp && ret ) {
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { // Support: Firefox 105+, Chrome <=105+
// Spec requires trimming whitespace for custom properties (gh-4926).
// Firefox only trims leading whitespace. Chrome just collapses
// both leading & trailing whitespace to a single space.
//
// Fall back to `undefined` if empty string returned.
// This collapses a missing definition with property defined
// and set to an empty string but there's no standard API
// allowing us to differentiate them without a performance penalty
// and returning `undefined` aligns with older jQuery.
//
// rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
// as whitespace while CSS does not, but this is not a problem
// because CSS preprocessing replaces them with U+000A LINE FEED
// (which *is* CSS whitespace)
// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
ret = ret.replace( rtrimCSS, "$1" ) || undefined;
}
if ( ret === "" && !isAttached( elem ) ) {
ret = jQuery.style( elem, name ); ret = jQuery.style( elem, name );
} }
// Support: iOS < 6
// A tribute to the "awesome hack by Dean Edwards" // A tribute to the "awesome hack by Dean Edwards"
// iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels // Android Browser returns percentage for some values,
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values // but width seems to be reliably pixels.
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { // This is against the CSSOM draft spec:
// https://drafts.csswg.org/cssom/#resolved-values
if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
// Remember the original values // Remember the original values
width = style.width; width = style.width;
@ -47,11 +89,12 @@ function curCSS( elem, name, computed ) {
} }
return ret !== undefined ? return ret !== undefined ?
// Support: IE
// Support: IE <=9 - 11 only
// IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
ret + "" : ret + "" :
ret; ret;
} }
return curCSS; return curCSS;
}); } );

View File

@ -1,70 +0,0 @@
define([
"../core",
"../manipulation" // appendTo
], function( jQuery ) {
var iframe,
elemdisplay = {};
/**
* 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 style,
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
// getDefaultComputedStyle might be reliably used only on attached element
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
// Use of this method is a temporary fix (more like optimization) until something better comes along,
// since it was removed from specification and supported only in FF
style.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 ].contentDocument;
// Support: IE
doc.write();
doc.close();
display = actualDisplay( nodeName, doc );
iframe.detach();
}
// Store the correct default display
elemdisplay[ nodeName ] = display;
}
return display;
}
return defaultDisplay;
});

View File

@ -0,0 +1,42 @@
define( [
"../var/document",
"../core"
], function( document, jQuery ) {
"use strict";
var cssPrefixes = [ "Webkit", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style,
vendorProps = {};
// Return a vendor-prefixed property or undefined
function vendorPropName( name ) {
// Check for vendor prefixed names
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in emptyStyle ) {
return name;
}
}
}
// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
function finalPropName( name ) {
var final = jQuery.cssProps[ name ] || vendorProps[ name ];
if ( final ) {
return final;
}
if ( name in emptyStyle ) {
return name;
}
return vendorProps[ name ] = vendorPropName( name ) || name;
}
return finalPropName;
} );

View File

@ -1,15 +1,15 @@
define([ define( [
"../core", "../core",
"../selector" "../selector"
], function( jQuery ) { ], function( jQuery ) {
jQuery.expr.filters.hidden = function( elem ) { "use strict";
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements jQuery.expr.pseudos.hidden = function( elem ) {
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; return !jQuery.expr.pseudos.visible( elem );
}; };
jQuery.expr.filters.visible = function( elem ) { jQuery.expr.pseudos.visible = function( elem ) {
return !jQuery.expr.filters.hidden( elem ); return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
}; };
}); } );

View File

@ -0,0 +1,105 @@
define( [
"../core",
"../data/var/dataPriv",
"../css/var/isHiddenWithinTree"
], function( jQuery, dataPriv, isHiddenWithinTree ) {
"use strict";
var defaultDisplayMap = {};
function getDefaultDisplay( elem ) {
var temp,
doc = elem.ownerDocument,
nodeName = elem.nodeName,
display = defaultDisplayMap[ nodeName ];
if ( display ) {
return display;
}
temp = doc.body.appendChild( doc.createElement( nodeName ) );
display = jQuery.css( temp, "display" );
temp.parentNode.removeChild( temp );
if ( display === "none" ) {
display = "block";
}
defaultDisplayMap[ nodeName ] = display;
return display;
}
function showHide( elements, show ) {
var display, elem,
values = [],
index = 0,
length = elements.length;
// Determine new display value for elements that need to change
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
display = elem.style.display;
if ( show ) {
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
// check is required in this first loop unless we have a nonempty display value (either
// inline or about-to-be-restored)
if ( display === "none" ) {
values[ index ] = dataPriv.get( elem, "display" ) || null;
if ( !values[ index ] ) {
elem.style.display = "";
}
}
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
values[ index ] = getDefaultDisplay( elem );
}
} else {
if ( display !== "none" ) {
values[ index ] = "none";
// Remember what we're overwriting
dataPriv.set( elem, "display", display );
}
}
}
// Set the display of the elements in a second loop to avoid constant reflow
for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ];
}
}
return elements;
}
jQuery.fn.extend( {
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHiddenWithinTree( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
}
} );
return showHide;
} );

View File

@ -1,96 +1,152 @@
define([ define( [
"../core", "../core",
"../var/document",
"../var/documentElement",
"../var/support" "../var/support"
], function( jQuery, support ) { ], function( jQuery, document, documentElement, support ) {
(function() { "use strict";
var pixelPositionVal, boxSizingReliableVal,
docElem = document.documentElement, ( function() {
// Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation.
function computeStyleTests() {
// This is a singleton, we need to execute it only once
if ( !div ) {
return;
}
container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
"margin-top:1px;padding:0;border:0";
div.style.cssText =
"position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
"margin:auto;border:1px;padding:1px;" +
"width:60%;top:1%";
documentElement.appendChild( container ).appendChild( div );
var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%";
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
// Some styles come back with percentage values, even though they shouldn't
div.style.right = "60%";
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
// Support: IE 9 - 11 only
// Detect misreporting of content dimensions for box-sizing:border-box elements
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
// Support: IE 9 only
// Detect overflow:scroll screwiness (gh-3699)
// Support: Chrome <=64
// Don't get tricked when zoom affects offsetWidth (gh-4029)
div.style.position = "absolute";
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
documentElement.removeChild( container );
// Nullify the div so it wouldn't be stored in the memory and
// it will also be a sign that checks already performed
div = null;
}
function roundPixelMeasures( measure ) {
return Math.round( parseFloat( measure ) );
}
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
reliableTrDimensionsVal, reliableMarginLeftVal,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
// Finish early in limited (non-browser) environments
if ( !div.style ) { if ( !div.style ) {
return; return;
} }
// Support: IE9-11+ // Support: IE <=9 - 11 only
// Style of cloned element affects source element cloned (#8908) // Style of cloned element affects source element cloned (trac-8908)
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.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" + jQuery.extend( support, {
"position:absolute"; boxSizingReliable: function() {
container.appendChild( div ); computeStyleTests();
return boxSizingReliableVal;
},
pixelBoxStyles: function() {
computeStyleTests();
return pixelBoxStylesVal;
},
pixelPosition: function() {
computeStyleTests();
return pixelPositionVal;
},
reliableMarginLeft: function() {
computeStyleTests();
return reliableMarginLeftVal;
},
scrollboxSize: function() {
computeStyleTests();
return scrollboxSizeVal;
},
// Executing both pixelPosition & boxSizingReliable tests require only one layout // Support: IE 9 - 11+, Edge 15 - 18+
// so they're executed at the same time to save the second computation. // IE/Edge misreport `getComputedStyle` of table rows with width/height
function computePixelPositionAndBoxSizingReliable() { // set in CSS while `offset*` properties report correct values.
div.style.cssText = // Behavior in IE 9 is more subtle than in newer versions & it passes
// Support: Firefox<29, Android 2.3 // some versions of this test; make sure not to make it pass there!
// Vendor-prefix box-sizing //
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + // Support: Firefox 70+
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" + // Only Firefox includes border widths
"border:1px;padding:1px;width:4px;position:absolute"; // in computed dimensions. (gh-4529)
div.innerHTML = ""; reliableTrDimensions: function() {
docElem.appendChild( container ); var table, tr, trChild, trStyle;
if ( reliableTrDimensionsVal == null ) {
table = document.createElement( "table" );
tr = document.createElement( "tr" );
trChild = document.createElement( "div" );
var divStyle = window.getComputedStyle( div, null ); table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
pixelPositionVal = divStyle.top !== "1%"; tr.style.cssText = "box-sizing:content-box;border:1px solid";
boxSizingReliableVal = divStyle.width === "4px";
docElem.removeChild( container ); // Support: Chrome 86+
} // Height set through cssText does not get applied.
// Computed height then comes back as 0.
tr.style.height = "1px";
trChild.style.height = "9px";
// Support: node.js jsdom // Support: Android 8 Chrome 86+
// Don't assume that getComputedStyle is a property of the global object // In our bodyBackground.html iframe,
if ( window.getComputedStyle ) { // display for all div elements is set to "inline",
jQuery.extend( support, { // which causes a problem only in Android 8 Chrome 86.
pixelPosition: function() { // Ensuring the div is `display: block`
// gets around this issue.
trChild.style.display = "block";
// This test is executed only once but we still do memoizing documentElement
// since we can use the boxSizingReliable pre-computing. .appendChild( table )
// No need to check if the test was already performed, though. .appendChild( tr )
computePixelPositionAndBoxSizingReliable(); .appendChild( trChild );
return pixelPositionVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
computePixelPositionAndBoxSizingReliable();
}
return boxSizingReliableVal;
},
reliableMarginRight: function() {
// Support: Android 2.3 trStyle = window.getComputedStyle( tr );
// Check if div with explicit width and no margin-right incorrectly reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
// gets computed margin-right based on width of container. (#3333) parseInt( trStyle.borderTopWidth, 10 ) +
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
// This support function is only executed once so no memoizing is needed.
var ret,
marginDiv = div.appendChild( document.createElement( "div" ) );
// Reset CSS: box-sizing; display; margin; border; padding documentElement.removeChild( table );
marginDiv.style.cssText = 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:0";
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
docElem.appendChild( container );
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
docElem.removeChild( container );
div.removeChild( marginDiv );
return ret;
} }
}); return reliableTrDimensionsVal;
} }
})(); } );
} )();
return support; return support;
}); } );

View File

@ -1,3 +1,5 @@
define(function() { define( function() {
"use strict";
return [ "Top", "Right", "Bottom", "Left" ]; return [ "Top", "Right", "Bottom", "Left" ];
}); } );

View File

@ -1,12 +1,17 @@
define(function() { define( function() {
"use strict";
return function( elem ) { return function( elem ) {
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
// Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)
// IE throws on elements created in popups // IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle" // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
if ( elem.ownerDocument.defaultView.opener ) { var view = elem.ownerDocument.defaultView;
return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
if ( !view || !view.opener ) {
view = window;
} }
return window.getComputedStyle( elem, null ); return view.getComputedStyle( elem );
}; };
}); } );

View File

@ -1,13 +0,0 @@
define([
"../../core",
"../../selector"
// css is assumed
], function( jQuery ) {
return function( elem, el ) {
// isHidden might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
};
});

View File

@ -0,0 +1,34 @@
define( [
"../../core",
"../../core/isAttached"
// css is assumed
], function( jQuery, isAttached ) {
"use strict";
// isHiddenWithinTree reports if an element has a non-"none" display style (inline and/or
// through the CSS cascade), which is useful in deciding whether or not to make it visible.
// It differs from the :hidden selector (jQuery.expr.pseudos.hidden) in two important ways:
// * A hidden ancestor does not force an element to be classified as hidden.
// * Being disconnected from the document does not force an element to be classified as hidden.
// These differences improve the behavior of .toggle() et al. when applied to elements that are
// detached or contained within hidden ancestors (gh-2404, gh-2863).
return function( elem, el ) {
// isHiddenWithinTree might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
// Inline style trumps all
return elem.style.display === "none" ||
elem.style.display === "" &&
// Otherwise, check computed style
// Support: Firefox <=43 - 45
// Disconnected elements can have computed display: none, so first confirm that elem is
// in the document.
isAttached( elem ) &&
jQuery.css( elem, "display" ) === "none";
};
} );

View File

@ -0,0 +1,7 @@
define( [
"./cssExpand"
], function( cssExpand ) {
"use strict";
return new RegExp( cssExpand.join( "|" ), "i" );
} );

View File

@ -0,0 +1,7 @@
define( function() {
"use strict";
return /^--/;
} );

View File

@ -1,3 +0,0 @@
define(function() {
return (/^margin/);
});

View File

@ -1,5 +1,7 @@
define([ define( [
"../../var/pnum" "../../var/pnum"
], function( pnum ) { ], function( pnum ) {
"use strict";
return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
}); } );

View File

@ -1,9 +1,9 @@
define([ define( function() {
"../core"
], function( jQuery ) { "use strict";
// 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.
jQuery.swap = function( elem, options, callback, args ) { return function( elem, options, callback ) {
var ret, name, var ret, name,
old = {}; old = {};
@ -13,7 +13,7 @@ jQuery.swap = function( elem, options, callback, args ) {
elem.style[ name ] = options[ name ]; elem.style[ name ] = options[ name ];
} }
ret = callback.apply( elem, args || [] ); ret = callback.call( elem );
// Revert the old values // Revert the old values
for ( name in options ) { for ( name in options ) {
@ -23,6 +23,4 @@ jQuery.swap = function( elem, options, callback, args ) {
return ret; return ret;
}; };
return jQuery.swap; } );
});

View File

@ -1,10 +1,12 @@
define([ define( [
"./core", "./core",
"./var/rnotwhite",
"./core/access", "./core/access",
"./data/var/data_priv", "./core/camelCase",
"./data/var/data_user" "./data/var/dataPriv",
], function( jQuery, rnotwhite, access, data_priv, data_user ) { "./data/var/dataUser"
], function( jQuery, access, camelCase, dataPriv, dataUser ) {
"use strict";
// Implementation Summary // Implementation Summary
// //
@ -17,7 +19,32 @@ define([
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 // 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 getData( data ) {
if ( data === "true" ) {
return true;
}
if ( data === "false" ) {
return false;
}
if ( data === "null" ) {
return null;
}
// Only convert to a number if it doesn't change the string
if ( data === +data + "" ) {
return +data;
}
if ( rbrace.test( data ) ) {
return JSON.parse( data );
}
return data;
}
function dataAttr( elem, key, data ) { function dataAttr( elem, key, data ) {
var name; var name;
@ -25,22 +52,16 @@ function dataAttr( elem, key, data ) {
// 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, "-$1" ).toLowerCase(); name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
data = elem.getAttribute( name ); data = elem.getAttribute( name );
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
try { try {
data = data === "true" ? true : data = getData( data );
data === "false" ? false : } catch ( e ) {}
data === "null" ? null :
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} 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
data_user.set( elem, key, data ); dataUser.set( elem, key, data );
} else { } else {
data = undefined; data = undefined;
} }
@ -48,31 +69,31 @@ function dataAttr( elem, key, data ) {
return data; return data;
} }
jQuery.extend({ jQuery.extend( {
hasData: function( elem ) { hasData: function( elem ) {
return data_user.hasData( elem ) || data_priv.hasData( elem ); return dataUser.hasData( elem ) || dataPriv.hasData( elem );
}, },
data: function( elem, name, data ) { data: function( elem, name, data ) {
return data_user.access( elem, name, data ); return dataUser.access( elem, name, data );
}, },
removeData: function( elem, name ) { removeData: function( elem, name ) {
data_user.remove( elem, name ); dataUser.remove( elem, name );
}, },
// TODO: Now that all calls to _data and _removeData have been replaced // TODO: Now that all calls to _data and _removeData have been replaced
// with direct calls to data_priv methods, these can be deprecated. // with direct calls to dataPriv methods, these can be deprecated.
_data: function( elem, name, data ) { _data: function( elem, name, data ) {
return data_priv.access( elem, name, data ); return dataPriv.access( elem, name, data );
}, },
_removeData: function( elem, name ) { _removeData: function( elem, name ) {
data_priv.remove( elem, name ); dataPriv.remove( elem, name );
} }
}); } );
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 ],
@ -81,23 +102,23 @@ jQuery.fn.extend({
// Gets all values // Gets all values
if ( key === undefined ) { if ( key === undefined ) {
if ( this.length ) { if ( this.length ) {
data = data_user.get( elem ); data = dataUser.get( elem );
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
i = attrs.length; i = attrs.length;
while ( i-- ) { while ( i-- ) {
// Support: IE11+ // Support: IE 11 only
// The attrs elements can be null (#14894) // The attrs elements can be null (trac-14894)
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 = camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] ); dataAttr( elem, name, data[ name ] );
} }
} }
} }
data_priv.set( elem, "hasDataAttrs", true ); dataPriv.set( elem, "hasDataAttrs", true );
} }
} }
@ -106,14 +127,13 @@ 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() {
data_user.set( this, key ); dataUser.set( this, key );
}); } );
} }
return access( this, function( value ) { return access( this, function( value ) {
var data, var data;
camelKey = jQuery.camelCase( key );
// The calling jQuery object (element matches) is not empty // The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the // (and therefore has an element appears at this[ 0 ]) and the
@ -121,23 +141,17 @@ jQuery.fn.extend({
// will result in `undefined` for elem = this[ 0 ] which will // will result in `undefined` for elem = this[ 0 ] which will
// throw an exception if an attempt to read a data cache is made. // throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) { if ( elem && value === undefined ) {
// Attempt to get data from the cache
// with the key as-is
data = data_user.get( elem, key );
if ( data !== undefined ) {
return data;
}
// Attempt to get data from the cache // Attempt to get data from the cache
// with the key camelized // The key will always be camelCased in Data
data = data_user.get( elem, camelKey ); data = dataUser.get( elem, key );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
// Attempt to "discover" the data in // Attempt to "discover" the data in
// HTML5 custom data-* attrs // HTML5 custom data-* attrs
data = dataAttr( elem, camelKey, undefined ); data = dataAttr( elem, key );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
@ -147,32 +161,20 @@ jQuery.fn.extend({
} }
// Set the data... // Set the data...
this.each(function() { this.each( function() {
// First, attempt to store a copy or reference of any
// data that might've been store with a camelCased key.
var data = data_user.get( this, camelKey );
// For HTML5 data-* attribute interop, we have to // We always store the camelCased key
// store property names with dashes in a camelCase form. dataUser.set( this, key, value );
// This might not apply to all properties...* } );
data_user.set( this, camelKey, value );
// *... In the case of properties that might _actually_
// have dashes, we need to also store a copy of that
// unchanged property.
if ( key.indexOf("-") !== -1 && data !== undefined ) {
data_user.set( this, key, value );
}
});
}, null, value, arguments.length > 1, null, true ); }, null, value, arguments.length > 1, null, true );
}, },
removeData: function( key ) { removeData: function( key ) {
return this.each(function() { return this.each( function() {
data_user.remove( this, key ); dataUser.remove( this, key );
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,100 +1,81 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite", "../core/camelCase",
"./accepts" "../var/rnothtmlwhite",
], function( jQuery, rnotwhite ) { "./var/acceptData"
], function( jQuery, camelCase, rnothtmlwhite, acceptData ) {
"use strict";
function Data() { function Data() {
// Support: Android<4,
// Old WebKit does not have Object.preventExtensions/freeze method,
// return new empty object instead with no [[set]] accessor
Object.defineProperty( this.cache = {}, 0, {
get: function() {
return {};
}
});
this.expando = jQuery.expando + Data.uid++; this.expando = jQuery.expando + Data.uid++;
} }
Data.uid = 1; Data.uid = 1;
Data.accepts = jQuery.acceptData;
Data.prototype = { Data.prototype = {
key: function( owner ) {
// We can accept data for non-element nodes in modern browsers,
// but we should not, see #8335.
// Always return the key for a frozen object.
if ( !Data.accepts( owner ) ) {
return 0;
}
var descriptor = {}, cache: function( owner ) {
// Check if the owner object already has a cache key
unlock = owner[ this.expando ]; // Check if the owner object already has a cache
var value = owner[ this.expando ];
// If not, create one // If not, create one
if ( !unlock ) { if ( !value ) {
unlock = Data.uid++; value = {};
// Secure it in a non-enumerable, non-writable property // We can accept data for non-element nodes in modern browsers,
try { // but we should not, see trac-8335.
descriptor[ this.expando ] = { value: unlock }; // Always return an empty object.
Object.defineProperties( owner, descriptor ); if ( acceptData( owner ) ) {
// Support: Android<4 // If it is a node unlikely to be stringify-ed or looped over
// Fallback to a less secure definition // use plain assignment
} catch ( e ) { if ( owner.nodeType ) {
descriptor[ this.expando ] = unlock; owner[ this.expando ] = value;
jQuery.extend( owner, descriptor );
// Otherwise secure it in a non-enumerable property
// configurable must be true to allow the property to be
// deleted when data is removed
} else {
Object.defineProperty( owner, this.expando, {
value: value,
configurable: true
} );
}
} }
} }
// Ensure the cache object return value;
if ( !this.cache[ unlock ] ) {
this.cache[ unlock ] = {};
}
return unlock;
}, },
set: function( owner, data, value ) { set: function( owner, data, value ) {
var prop, var prop,
// There may be an unlock assigned to this node, cache = this.cache( owner );
// if there is no entry for this "owner", create one inline
// and set the unlock as though an owner entry had always existed
unlock = this.key( owner ),
cache = this.cache[ unlock ];
// Handle: [ owner, key, value ] args // Handle: [ owner, key, value ] args
// Always use camelCase key (gh-2257)
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
cache[ data ] = value; cache[ camelCase( data ) ] = value;
// Handle: [ owner, { properties } ] args // Handle: [ owner, { properties } ] args
} else { } else {
// Fresh assignments by object are shallow copied
if ( jQuery.isEmptyObject( cache ) ) { // Copy the properties one-by-one to the cache object
jQuery.extend( this.cache[ unlock ], data ); for ( prop in data ) {
// Otherwise, copy the properties one-by-one to the cache object cache[ camelCase( prop ) ] = data[ prop ];
} else {
for ( prop in data ) {
cache[ prop ] = data[ prop ];
}
} }
} }
return cache; return cache;
}, },
get: function( owner, key ) { get: function( owner, key ) {
// Either a valid cache is found, or will be created.
// New caches will be created and the unlock returned,
// allowing direct access to the newly created
// empty data object. A valid owner object must be provided.
var cache = this.cache[ this.key( owner ) ];
return key === undefined ? return key === undefined ?
cache : cache[ key ]; this.cache( owner ) :
// Always use camelCase key (gh-2257)
owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
}, },
access: function( owner, key, value ) { access: function( owner, key, value ) {
var stored;
// In cases where either: // In cases where either:
// //
// 1. No key was specified // 1. No key was specified
@ -107,15 +88,12 @@ Data.prototype = {
// 2. The data stored at the key // 2. The data stored at the key
// //
if ( key === undefined || if ( key === undefined ||
((key && typeof key === "string") && value === undefined) ) { ( ( key && typeof key === "string" ) && value === undefined ) ) {
stored = this.get( owner, key ); return this.get( owner, key );
return stored !== undefined ?
stored : this.get( owner, jQuery.camelCase(key) );
} }
// [*]When the key is not a string, or both a key and value // When the key is not a string, or both a key and value
// are specified, set or extend (existing objects) with either: // are specified, set or extend (existing objects) with either:
// //
// 1. An object of properties // 1. An object of properties
@ -128,54 +106,57 @@ Data.prototype = {
return value !== undefined ? value : key; return value !== undefined ? value : key;
}, },
remove: function( owner, key ) { remove: function( owner, key ) {
var i, name, camel, var i,
unlock = this.key( owner ), cache = owner[ this.expando ];
cache = this.cache[ unlock ];
if ( key === undefined ) { if ( cache === undefined ) {
this.cache[ unlock ] = {}; return;
}
if ( key !== undefined ) {
} else {
// Support array or space separated string of keys // Support array or space separated string of keys
if ( jQuery.isArray( key ) ) { if ( Array.isArray( key ) ) {
// If "name" is an array of keys...
// When data is initially created, via ("key", "val") signature, // If key is an array of keys...
// keys will be converted to camelCase. // We always set camelCase keys, so remove that.
// Since there is no way to tell _how_ a key was added, remove key = key.map( camelCase );
// both plain key and camelCase key. #12786
// This will only penalize the array argument path.
name = key.concat( key.map( jQuery.camelCase ) );
} else { } else {
camel = jQuery.camelCase( key ); key = camelCase( key );
// Try the string as a key before any manipulation
if ( key in cache ) { // If a key with the spaces exists, use it.
name = [ key, camel ]; // Otherwise, create an array by matching non-whitespace
} else { key = key in cache ?
// If a key with the spaces exists, use it. [ key ] :
// Otherwise, create an array by matching non-whitespace ( key.match( rnothtmlwhite ) || [] );
name = camel;
name = name in cache ?
[ name ] : ( name.match( rnotwhite ) || [] );
}
} }
i = name.length; i = key.length;
while ( i-- ) { while ( i-- ) {
delete cache[ name[ i ] ]; delete cache[ key[ i ] ];
}
}
// Remove the expando if there's no more data
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
// Support: Chrome <=35 - 45
// Webkit & Blink performance suffers when deleting properties
// from DOM nodes, so set to undefined instead
// https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
if ( owner.nodeType ) {
owner[ this.expando ] = undefined;
} else {
delete owner[ this.expando ];
} }
} }
}, },
hasData: function( owner ) { hasData: function( owner ) {
return !jQuery.isEmptyObject( var cache = owner[ this.expando ];
this.cache[ owner[ this.expando ] ] || {} return cache !== undefined && !jQuery.isEmptyObject( cache );
);
},
discard: function( owner ) {
if ( owner[ this.expando ] ) {
delete this.cache[ owner[ this.expando ] ];
}
} }
}; };
return Data; return Data;
}); } );

View File

@ -1,20 +1,19 @@
define([ define( function() {
"../core"
], function( jQuery ) { "use strict";
/** /**
* Determines whether an object can have data * Determines whether an object can have data
*/ */
jQuery.acceptData = function( owner ) { return function( owner ) {
// Accepts only: // Accepts only:
// - Node // - Node
// - Node.ELEMENT_NODE // - Node.ELEMENT_NODE
// - Node.DOCUMENT_NODE // - Node.DOCUMENT_NODE
// - Object // - Object
// - Any // - Any
/* jshint -W018 */
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
}; };
return jQuery.acceptData; } );
});

View File

@ -1,5 +1,7 @@
define([ define( [
"../Data" "../Data"
], function( Data ) { ], function( Data ) {
"use strict";
return new Data(); return new Data();
}); } );

View File

@ -1,5 +1,7 @@
define([ define( [
"../Data" "../Data"
], function( Data ) { ], function( Data ) {
"use strict";
return new Data(); return new Data();
}); } );

View File

@ -1,17 +1,65 @@
define([ define( [
"./core", "./core",
"./var/isFunction",
"./var/slice", "./var/slice",
"./callbacks" "./callbacks"
], function( jQuery, slice ) { ], function( jQuery, isFunction, slice ) {
jQuery.extend({ "use strict";
function Identity( v ) {
return v;
}
function Thrower( ex ) {
throw ex;
}
function adoptValue( value, resolve, reject, noValue ) {
var method;
try {
// Check for promise aspect first to privilege synchronous behavior
if ( value && isFunction( ( method = value.promise ) ) ) {
method.call( value ).done( resolve ).fail( reject );
// Other thenables
} else if ( value && isFunction( ( method = value.then ) ) ) {
method.call( value, resolve, reject );
// Other non-thenables
} else {
// Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
// * false: [ value ].slice( 0 ) => resolve( value )
// * true: [ value ].slice( 1 ) => resolve()
resolve.apply( undefined, [ value ].slice( noValue ) );
}
// For Promises/A+, convert exceptions into rejections
// Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
// Deferred#then to conditionally suppress rejection.
} catch ( value ) {
// Support: Android 4.0 only
// Strict mode functions invoked without .call/.apply get global-object context
reject.apply( undefined, [ value ] );
}
}
jQuery.extend( {
Deferred: function( func ) { Deferred: function( func ) {
var tuples = [ var tuples = [
// action, add listener, listener list, final state
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], // action, add listener, callbacks,
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], // ... .then handlers, argument index, [final state]
[ "notify", "progress", jQuery.Callbacks("memory") ] [ "notify", "progress", jQuery.Callbacks( "memory" ),
jQuery.Callbacks( "memory" ), 2 ],
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
], ],
state = "pending", state = "pending",
promise = { promise = {
@ -22,27 +70,213 @@ jQuery.extend({
deferred.done( arguments ).fail( arguments ); deferred.done( arguments ).fail( arguments );
return this; return this;
}, },
then: function( /* fnDone, fnFail, fnProgress */ ) { "catch": function( fn ) {
var fns = arguments; return promise.then( null, fn );
return jQuery.Deferred(function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// deferred[ done | fail | progress ] for forwarding actions to newDefer
deferred[ tuple[1] ](function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise()
.done( newDefer.resolve )
.fail( newDefer.reject )
.progress( newDefer.notify );
} else {
newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
}
});
});
fns = null;
}).promise();
}, },
// Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( _i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && isFunction( returned.promise ) ) {
returned.promise()
.progress( newDefer.notify )
.done( newDefer.resolve )
.fail( newDefer.reject );
} else {
newDefer[ tuple[ 0 ] + "With" ](
this,
fn ? [ returned ] : arguments
);
}
} );
} );
fns = null;
} ).promise();
},
then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0;
function resolve( depth, deferred, handler, special ) {
return function() {
var that = 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 ( 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.notifyWith )
);
}
// Handle all other returned values
} else {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Identity ) {
that = undefined;
args = [ returned ];
}
// Process the value(s)
// Default process is resolve
( special || deferred.resolveWith )( that, args );
}
},
// Only normal processors (resolve) catch and reject exceptions
process = special ?
mightThrow :
function() {
try {
mightThrow();
} catch ( e ) {
if ( jQuery.Deferred.exceptionHook ) {
jQuery.Deferred.exceptionHook( e,
process.error );
}
// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Thrower ) {
that = undefined;
args = [ e ];
}
deferred.rejectWith( that, args );
}
}
};
// Support: Promises/A+ section 2.3.3.3.1
// https://promisesaplus.com/#point-57
// Re-resolve promises immediately to dodge false rejection from
// subsequent errors
if ( depth ) {
process();
} else {
// Call an optional hook to record the error, in case of exception
// since it's otherwise lost when execution goes async
if ( jQuery.Deferred.getErrorHook ) {
process.error = jQuery.Deferred.getErrorHook();
// The deprecated alias of the above. While the name suggests
// returning the stack, not an error instance, jQuery just passes
// it directly to `console.warn` so both will work; an instance
// just better cooperates with source maps.
} else if ( jQuery.Deferred.getStackHook ) {
process.error = jQuery.Deferred.getStackHook();
}
window.setTimeout( process );
}
};
}
return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add(
resolve(
0,
newDefer,
isFunction( onProgress ) ?
onProgress :
Identity,
newDefer.notifyWith
)
);
// fulfilled_handlers.add( ... )
tuples[ 1 ][ 3 ].add(
resolve(
0,
newDefer,
isFunction( onFulfilled ) ?
onFulfilled :
Identity
)
);
// rejected_handlers.add( ... )
tuples[ 2 ][ 3 ].add(
resolve(
0,
newDefer,
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 ) {
@ -51,34 +285,60 @@ 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[ 3 ]; stateString = tuple[ 5 ];
// promise[ done | fail | progress ] = list.add // promise.progress = list.add
promise[ tuple[1] ] = list.add; // promise.done = list.add
// promise.fail = list.add
promise[ tuple[ 1 ] ] = list.add;
// Handle state // Handle state
if ( stateString ) { if ( stateString ) {
list.add(function() { list.add(
// state = [ resolved | rejected ] function() {
state = stateString;
// [ reject_list | resolve_list ].disable; progress_list.lock // state = "resolved" (i.e., fulfilled)
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); // state = "rejected"
state = stateString;
},
// rejected_callbacks.disable
// fulfilled_callbacks.disable
tuples[ 3 - i ][ 2 ].disable,
// rejected_handlers.disable
// fulfilled_handlers.disable
tuples[ 3 - i ][ 3 ].disable,
// progress_callbacks.lock
tuples[ 0 ][ 2 ].lock,
// progress_handlers.lock
tuples[ 0 ][ 3 ].lock
);
} }
// deferred[ resolve | reject | notify ] // progress_handlers.fire
deferred[ tuple[0] ] = function() { // fulfilled_handlers.fire
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); // rejected_handlers.fire
list.add( tuple[ 3 ].fire );
// deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : 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 );
@ -93,57 +353,54 @@ jQuery.extend({
}, },
// Deferred helper // Deferred helper
when: function( subordinate /* , ..., subordinateN */ ) { when: function( singleValue ) {
var i = 0, var
// count of uncompleted subordinates
remaining = arguments.length,
// count of unprocessed arguments
i = remaining,
// subordinate fulfillment data
resolveContexts = Array( i ),
resolveValues = slice.call( arguments ), resolveValues = slice.call( arguments ),
length = resolveValues.length,
// the count of uncompleted subordinates // the primary Deferred
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, primary = jQuery.Deferred(),
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. // subordinate callback factory
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), updateFunc = function( i ) {
// Update function for both resolve and progress values
updateFunc = function( i, contexts, values ) {
return function( value ) { return function( value ) {
contexts[ i ] = this; resolveContexts[ i ] = this;
values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( values === progressValues ) { if ( !( --remaining ) ) {
deferred.notifyWith( contexts, values ); primary.resolveWith( resolveContexts, resolveValues );
} else if ( !( --remaining ) ) {
deferred.resolveWith( contexts, values );
} }
}; };
}, };
progressValues, progressContexts, resolveContexts; // Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) {
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
!remaining );
// Add listeners to Deferred subordinates; treat others as resolved // Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( length > 1 ) { if ( primary.state() === "pending" ||
progressValues = new Array( length ); isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
progressContexts = new Array( length );
resolveContexts = new Array( length ); return primary.then();
for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
resolveValues[ i ].promise()
.done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( deferred.reject )
.progress( updateFunc( i, progressContexts, progressValues ) );
} else {
--remaining;
}
} }
} }
// If we're not waiting on anything, resolve the master // Multiple arguments are aggregated like Promise.all array elements
if ( !remaining ) { while ( i-- ) {
deferred.resolveWith( resolveContexts, resolveValues ); adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
} }
return deferred.promise(); return primary.promise();
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -0,0 +1,25 @@
define( [
"../core",
"../deferred"
], function( jQuery ) {
"use strict";
// These usually indicate a programmer mistake during development,
// warn about them ASAP rather than swallowing them by default.
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error
// captured before the async barrier to get the original error cause
// which may otherwise be hidden.
jQuery.Deferred.exceptionHook = function( error, asyncError ) {
// Support: IE 8 - 9 only
// Console exists when dev tools are open, which can happen at any time
if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
window.console.warn( "jQuery.Deferred exception: " + error.message,
error.stack, asyncError );
}
};
} );

View File

@ -1,13 +1,89 @@
define([ define( [
"./core", "./core",
"./traversing" "./core/nodeName",
], function( jQuery ) { "./core/camelCase",
"./core/toType",
"./var/isFunction",
"./var/isWindow",
"./var/slice",
// The number of elements contained in the matched element set "./deprecated/ajax-event-alias",
jQuery.fn.size = function() { "./deprecated/event"
return this.length; ], function( jQuery, nodeName, camelCase, toType, isFunction, isWindow, slice ) {
"use strict";
// Support: Android <=4.0 only
// Make sure we trim BOM and NBSP
// Require that the "whitespace run" starts from a non-whitespace
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
// Bind a function to a context, optionally partially applying any
// arguments.
// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
// However, it is not slated for removal any time soon
jQuery.proxy = function( fn, context ) {
var tmp, args, proxy;
if ( typeof context === "string" ) {
tmp = fn[ context ];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( !isFunction( fn ) ) {
return undefined;
}
// Simulated bind
args = slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
}; };
jQuery.fn.andSelf = jQuery.fn.addBack; jQuery.holdReady = function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
};
jQuery.isArray = Array.isArray;
jQuery.parseJSON = JSON.parse;
jQuery.nodeName = nodeName;
jQuery.isFunction = isFunction;
jQuery.isWindow = isWindow;
jQuery.camelCase = camelCase;
jQuery.type = toType;
}); jQuery.now = Date.now;
jQuery.isNumeric = function( obj ) {
// As of jQuery 3.0, isNumeric is limited to
// strings and numbers (primitives or objects)
// that can be coerced to finite numbers (gh-2662)
var type = jQuery.type( obj );
return ( type === "number" || type === "string" ) &&
// parseFloat NaNs numeric-cast false positives ("")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
!isNaN( obj - parseFloat( obj ) );
};
jQuery.trim = function( text ) {
return text == null ?
"" :
( text + "" ).replace( rtrim, "$1" );
};
} );

View File

@ -0,0 +1,22 @@
define( [
"../core",
"../ajax",
"../event"
], function( jQuery ) {
"use strict";
jQuery.each( [
"ajaxStart",
"ajaxStop",
"ajaxComplete",
"ajaxError",
"ajaxSuccess",
"ajaxSend"
], function( _i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
} );
} );

View File

@ -0,0 +1,52 @@
define( [
"../core",
"../event",
"../event/trigger"
], function( jQuery ) {
"use strict";
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 );
},
hover: function( fnOver, fnOut ) {
return this
.on( "mouseenter", fnOver )
.on( "mouseleave", fnOut || fnOver );
}
} );
jQuery.each(
( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( _i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
}
);
} );

View File

@ -1,12 +1,20 @@
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./var/isWindow",
"./css" "./css"
], function( jQuery, access ) { ], function( jQuery, access, isWindow ) {
"use strict";
// 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 }, function( defaultExtra, funcName ) { jQuery.each( {
padding: "inner" + name,
content: type,
"": "outer" + name
}, 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" ),
@ -15,11 +23,12 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
return access( this, function( elem, type, value ) { return access( this, function( elem, type, value ) {
var doc; var doc;
if ( jQuery.isWindow( elem ) ) { if ( isWindow( elem ) ) {
// 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: // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
// https://github.com/jquery/jquery/pull/764 return funcName.indexOf( "outer" ) === 0 ?
return elem.document.documentElement[ "client" + name ]; elem[ "inner" + name ] :
elem.document.documentElement[ "client" + name ];
} }
// Get document width or height // Get document width or height
@ -36,15 +45,16 @@ 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 ) :
// Set width or height on the element // Set width or height on the element
jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable, null ); }, type, chainable ? margin : undefined, chainable );
}; };
}); } );
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,82 +1,51 @@
define([ define( [
"./core", "./core",
"./var/pnum", "./core/camelCase",
"./var/document",
"./var/isFunction",
"./var/rcssNum",
"./var/rnothtmlwhite",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/var/isHidden", "./css/var/isHiddenWithinTree",
"./css/defaultDisplay", "./css/adjustCSS",
"./data/var/data_priv", "./data/var/dataPriv",
"./css/showHide",
"./core/init", "./core/init",
"./effects/Tween",
"./queue", "./queue",
"./css",
"./deferred", "./deferred",
"./traversing" "./traversing",
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) { "./manipulation",
"./css",
"./effects/Tween"
], function( jQuery, camelCase, document, isFunction, rcssNum, rnothtmlwhite, cssExpand,
isHiddenWithinTree, adjustCSS, dataPriv, showHide ) {
"use strict";
var var
fxNow, timerId, fxNow, inProgress,
rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), rrun = /queueHooks$/;
rrun = /queueHooks$/,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [ function( prop, value ) {
var tween = this.createTween( prop, value ),
target = tween.cur(),
parts = rfxnum.exec( value ),
unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches function schedule() {
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && if ( inProgress ) {
rfxnum.exec( jQuery.css( tween.elem, prop ) ), if ( document.hidden === false && window.requestAnimationFrame ) {
scale = 1, window.requestAnimationFrame( schedule );
maxIterations = 20; } else {
window.setTimeout( schedule, jQuery.fx.interval );
}
if ( start && start[ 3 ] !== unit ) { jQuery.fx.tick();
// Trust units reported by jQuery.css }
unit = unit || start[ 3 ]; }
// Make sure we update the tween properties later on
parts = parts || [];
// Iteratively approximate from a nonzero starting point
start = +target || 1;
do {
// If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5";
// Adjust and apply
start = start / scale;
jQuery.style( tween.elem, prop, start + unit );
// 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
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
}
// Update tween properties
if ( parts ) {
start = tween.start = +start || +target || 0;
tween.unit = unit;
// If a +=/-= token was provided, we're doing a relative animation
tween.end = parts[ 1 ] ?
start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
+parts[ 2 ];
}
return tween;
} ]
};
// Animations created synchronously will run synchronously // Animations created synchronously will run synchronously
function createFxNow() { function createFxNow() {
setTimeout(function() { window.setTimeout( function() {
fxNow = undefined; fxNow = undefined;
}); } );
return ( fxNow = jQuery.now() ); return ( fxNow = Date.now() );
} }
// Generate parameters to create a standard animation // Generate parameters to create a standard animation
@ -88,7 +57,7 @@ function genFx( type, includeWidth ) {
// 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 // otherwise 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 ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
} }
@ -102,11 +71,11 @@ function genFx( type, includeWidth ) {
function createTween( value, prop, animation ) { function createTween( value, prop, animation ) {
var tween, var tween,
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
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;
@ -115,15 +84,15 @@ function createTween( value, prop, animation ) {
} }
function defaultPrefilter( elem, props, opts ) { function defaultPrefilter( elem, props, opts ) {
/* 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 && isHiddenWithinTree( elem ),
dataShow = data_priv.get( elem, "fxshow" ); dataShow = dataPriv.get( elem, "fxshow" );
// Handle queue: false promises // Queue-skipping animations hijack the fx hooks
if ( !opts.queue ) { if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" ); hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) { if ( hooks.unqueued == null ) {
@ -137,113 +106,152 @@ function defaultPrefilter( elem, props, opts ) {
} }
hooks.unqueued++; hooks.unqueued++;
anim.always(function() { anim.always( function() {
// Ensure the complete handler is called before this completes // Ensure the complete handler is called before this completes
anim.always(function() { anim.always( function() {
hooks.unqueued--; hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire(); hooks.empty.fire();
} }
}); } );
}); } );
} }
// Height/width overflow pass // Detect show/hide animations
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE9-10 do 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" ?
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
style.display = "inline-block";
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
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.exec( value ) ) { if ( rfxtypes.test( 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" ) ) {
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden // Pretend to be hidden if this is a "show" and
// there is still data from a stopped show/hide
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 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 );
// Any non-fx value stops us from restoring the original display value
} else {
display = undefined;
} }
} }
if ( !jQuery.isEmptyObject( orig ) ) { // Bail out if this is a no-op like .hide().hide()
if ( dataShow ) { propTween = !jQuery.isEmptyObject( props );
if ( "hidden" in dataShow ) { if ( !propTween && jQuery.isEmptyObject( orig ) ) {
hidden = dataShow.hidden; return;
}
// Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) {
// Support: IE <=9 - 11, Edge 12 - 15
// Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY and Edge just mirrors
// the overflowX value there.
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Identify a display type, preferring old show/hide data over the CSS cascade
restoreDisplay = dataShow && dataShow.display;
if ( restoreDisplay == null ) {
restoreDisplay = dataPriv.get( elem, "display" );
}
display = jQuery.css( elem, "display" );
if ( display === "none" ) {
if ( restoreDisplay ) {
display = restoreDisplay;
} else {
// Get nonempty value(s) by temporarily forcing visibility
showHide( [ elem ], true );
restoreDisplay = elem.style.display || restoreDisplay;
display = jQuery.css( elem, "display" );
showHide( [ elem ] );
} }
} else {
dataShow = data_priv.access( elem, "fxshow", {} );
} }
// Store state if its toggle - enables .stop().toggle() to "reverse" // Animate inline elements as inline-block
if ( toggle ) { if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
dataShow.hidden = !hidden; if ( jQuery.css( elem, "float" ) === "none" ) {
}
if ( hidden ) {
jQuery( elem ).show();
} else {
anim.done(function() {
jQuery( elem ).hide();
});
}
anim.done(function() {
var prop;
data_priv.remove( elem, "fxshow" ); // Restore the original display value at the end of pure show/hide animations
for ( prop in orig ) { if ( !propTween ) {
jQuery.style( elem, prop, orig[ prop ] ); anim.done( function() {
} style.display = restoreDisplay;
}); } );
for ( prop in orig ) { if ( restoreDisplay == null ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); display = style.display;
restoreDisplay = display === "none" ? "" : display;
if ( !( prop in dataShow ) ) { }
dataShow[ prop ] = tween.start;
if ( hidden ) {
tween.end = tween.start;
tween.start = prop === "width" || prop === "height" ? 1 : 0;
} }
style.display = "inline-block";
} }
} }
}
// If this is a noop like .hide().hide(), restore an overwritten display value if ( opts.overflow ) {
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { style.overflow = "hidden";
style.display = display; anim.always( function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
} );
}
// 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 );
}
/* eslint-disable no-loop-func */
anim.done( function() {
/* eslint-enable no-loop-func */
// 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
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = propTween.start;
if ( hidden ) {
propTween.end = propTween.start;
propTween.start = 0;
}
}
} }
} }
@ -252,10 +260,10 @@ function propFilter( props, specialEasing ) {
// camelCase, specialEasing and expand cssHook pass // camelCase, specialEasing and expand cssHook pass
for ( index in props ) { for ( index in props ) {
name = jQuery.camelCase( index ); name = camelCase( index );
easing = specialEasing[ name ]; easing = specialEasing[ name ];
value = props[ index ]; value = props[ index ];
if ( jQuery.isArray( value ) ) { if ( Array.isArray( value ) ) {
easing = value[ 1 ]; easing = value[ 1 ];
value = props[ index ] = value[ 0 ]; value = props[ index ] = value[ 0 ];
} }
@ -288,41 +296,53 @@ function Animation( elem, properties, options ) {
var result, var result,
stopped, stopped,
index = 0, index = 0,
length = animationPrefilters.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
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) // Support: Android 2.3 only
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)
temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
percent = 1 - temp, percent = 1 - temp,
index = 0, index = 0,
length = animation.tweens.length; length = animation.tweens.length;
for ( ; index < length ; index++ ) { for ( ; index < length; index++ ) {
animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
} }
deferred.notifyWith( elem, [ animation, percent, remaining ]); deferred.notifyWith( elem, [ animation, percent, remaining ] );
// If there's more to do, yield
if ( percent < 1 && length ) { if ( percent < 1 && length ) {
return remaining; return remaining;
} else {
deferred.resolveWith( elem, [ animation ] );
return false;
} }
// If this was an empty animation, synthesize a final progress notification
if ( !length ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
}
// Resolve the animation and report its conclusion
deferred.resolveWith( elem, [ animation ] );
return false;
}, },
animation = deferred.promise({ animation = deferred.promise( {
elem: elem, elem: elem,
props: jQuery.extend( {}, properties ), props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, { specialEasing: {} }, options ), opts: jQuery.extend( true, {
specialEasing: {},
easing: jQuery.easing._default
}, options ),
originalProperties: properties, originalProperties: properties,
originalOptions: options, originalOptions: options,
startTime: fxNow || createFxNow(), startTime: fxNow || createFxNow(),
@ -330,12 +350,13 @@ function Animation( elem, properties, options ) {
tweens: [], tweens: [],
createTween: function( prop, end ) { createTween: function( prop, end ) {
var tween = jQuery.Tween( elem, animation.opts, prop, end, var tween = jQuery.Tween( elem, animation.opts, prop, end,
animation.opts.specialEasing[ prop ] || animation.opts.easing ); animation.opts.specialEasing[ prop ] || animation.opts.easing );
animation.tweens.push( tween ); animation.tweens.push( tween );
return tween; return tween;
}, },
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;
@ -343,91 +364,121 @@ function Animation( elem, properties, options ) {
return this; return this;
} }
stopped = true; stopped = true;
for ( ; index < length ; index++ ) { for ( ; index < length; index++ ) {
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 );
for ( ; index < length ; index++ ) { for ( ; index < length; index++ ) {
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
if ( result ) { if ( result ) {
if ( isFunction( result.stop ) ) {
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
result.stop.bind( result );
}
return result; return result;
} }
} }
jQuery.map( props, createTween, animation ); jQuery.map( props, createTween, animation );
if ( jQuery.isFunction( animation.opts.start ) ) { if ( isFunction( animation.opts.start ) ) {
animation.opts.start.call( elem, animation ); animation.opts.start.call( elem, animation );
} }
// Attach callbacks from options
animation
.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
.fail( animation.opts.fail )
.always( animation.opts.always );
jQuery.fx.timer( jQuery.fx.timer(
jQuery.extend( tick, { jQuery.extend( tick, {
elem: elem, elem: elem,
anim: animation, anim: animation,
queue: animation.opts.queue queue: animation.opts.queue
}) } )
); );
// attach callbacks from options return animation;
return animation.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
.fail( animation.opts.fail )
.always( animation.opts.always );
} }
jQuery.Animation = jQuery.extend( Animation, { jQuery.Animation = jQuery.extend( Animation, {
tweeners: {
"*": [ function( prop, value ) {
var tween = this.createTween( prop, value );
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
return tween;
} ]
},
tweener: function( props, callback ) { tweener: function( props, callback ) {
if ( jQuery.isFunction( props ) ) { if ( isFunction( props ) ) {
callback = props; callback = props;
props = [ "*" ]; props = [ "*" ];
} else { } else {
props = props.split(" "); props = props.match( rnothtmlwhite );
} }
var prop, var prop,
index = 0, index = 0,
length = props.length; length = props.length;
for ( ; index < length ; index++ ) { for ( ; index < length; index++ ) {
prop = props[ index ]; prop = props[ index ];
tweeners[ prop ] = tweeners[ prop ] || []; Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
tweeners[ prop ].unshift( callback ); Animation.tweeners[ prop ].unshift( callback );
} }
}, },
prefilters: [ defaultPrefilter ],
prefilter: function( callback, prepend ) { prefilter: function( callback, prepend ) {
if ( prepend ) { if ( prepend ) {
animationPrefilters.unshift( callback ); Animation.prefilters.unshift( callback );
} else { } else {
animationPrefilters.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 ) : {
complete: fn || !fn && easing || complete: fn || !fn && easing ||
jQuery.isFunction( speed ) && speed, isFunction( speed ) && speed,
duration: speed, duration: speed,
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing easing: fn && easing || easing && !isFunction( easing ) && easing
}; };
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : // Go to the end state if fx are off
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; if ( jQuery.fx.off ) {
opt.duration = 0;
} else {
if ( typeof opt.duration !== "number" ) {
if ( opt.duration in jQuery.fx.speeds ) {
opt.duration = jQuery.fx.speeds[ opt.duration ];
} else {
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 ) {
@ -438,7 +489,7 @@ jQuery.speed = function( speed, easing, fn ) {
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function() { opt.complete = function() {
if ( jQuery.isFunction( opt.old ) ) { if ( isFunction( opt.old ) ) {
opt.old.call( this ); opt.old.call( this );
} }
@ -450,28 +501,30 @@ 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( isHiddenWithinTree ).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 || data_priv.get( this, "finish" ) ) { if ( empty || dataPriv.get( this, "finish" ) ) {
anim.stop( true ); anim.stop( true );
} }
}; };
doAnimation.finish = doAnimation;
doAnimation.finish = doAnimation;
return empty || optall.queue === false ? return empty || optall.queue === false ?
this.each( doAnimation ) : this.each( doAnimation ) :
@ -489,15 +542,15 @@ jQuery.fn.extend({
clearQueue = type; clearQueue = type;
type = undefined; type = undefined;
} }
if ( clearQueue && type !== false ) { if ( clearQueue ) {
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 = data_priv.get( this ); data = dataPriv.get( this );
if ( index ) { if ( index ) {
if ( data[ index ] && data[ index ].stop ) { if ( data[ index ] && data[ index ].stop ) {
@ -512,7 +565,9 @@ jQuery.fn.extend({
} }
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { if ( timers[ index ].elem === this &&
( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd ); timers[ index ].anim.stop( gotoEnd );
dequeue = false; dequeue = false;
timers.splice( index, 1 ); timers.splice( index, 1 );
@ -525,15 +580,15 @@ jQuery.fn.extend({
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 = data_priv.get( this ), data = dataPriv.get( this ),
queue = data[ type + "queue" ], queue = data[ type + "queue" ],
hooks = data[ type + "queueHooks" ], hooks = data[ type + "queueHooks" ],
timers = jQuery.timers, timers = jQuery.timers,
@ -566,24 +621,24 @@ jQuery.fn.extend({
// 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" }
@ -591,7 +646,7 @@ 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() {
@ -599,11 +654,12 @@ jQuery.fx.tick = function() {
i = 0, i = 0,
timers = jQuery.timers; timers = jQuery.timers;
fxNow = jQuery.now(); fxNow = Date.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
// Run the timer and safely remove it when done (allowing for external removal)
if ( !timer() && timers[ i ] === timer ) { if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 ); timers.splice( i--, 1 );
} }
@ -617,32 +673,30 @@ jQuery.fx.tick = function() {
jQuery.fx.timer = function( timer ) { jQuery.fx.timer = function( timer ) {
jQuery.timers.push( timer ); jQuery.timers.push( timer );
if ( timer() ) { jQuery.fx.start();
jQuery.fx.start();
} else {
jQuery.timers.pop();
}
}; };
jQuery.fx.interval = 13; jQuery.fx.interval = 13;
jQuery.fx.start = function() { jQuery.fx.start = function() {
if ( !timerId ) { if ( inProgress ) {
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); return;
} }
inProgress = true;
schedule();
}; };
jQuery.fx.stop = function() { jQuery.fx.stop = function() {
clearInterval( timerId ); inProgress = 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;
}); } );

View File

@ -1,7 +1,11 @@
define([ define( [
"../core", "../core",
"../css/finalPropName",
"../css" "../css"
], function( jQuery ) { ], function( jQuery, finalPropName ) {
"use strict";
function Tween( elem, options, prop, end, easing ) { function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing ); return new Tween.prototype.init( elem, options, prop, end, easing );
@ -13,7 +17,7 @@ Tween.prototype = {
init: function( elem, options, prop, end, easing, unit ) { init: function( elem, options, prop, end, easing, unit ) {
this.elem = elem; this.elem = elem;
this.prop = prop; this.prop = prop;
this.easing = easing || "swing"; this.easing = easing || jQuery.easing._default;
this.options = options; this.options = options;
this.start = this.now = this.cur(); this.start = this.now = this.cur();
this.end = end; this.end = end;
@ -59,8 +63,10 @@ Tween.propHooks = {
get: function( tween ) { get: function( tween ) {
var result; var result;
if ( tween.elem[ tween.prop ] != null && // Use a property on the element directly when it is not a DOM element,
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { // or when there is no matching style property that exists.
if ( tween.elem.nodeType !== 1 ||
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
return tween.elem[ tween.prop ]; return tween.elem[ tween.prop ];
} }
@ -69,16 +75,20 @@ Tween.propHooks = {
// Simple values such as "10px" are parsed to Float; // 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 step hook for back compat.
// Use cssHook if its there. // Use cssHook if its there.
// Use .style if available and use plain properties where available. // Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) { if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween ); jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { } else if ( tween.elem.nodeType === 1 && (
jQuery.cssHooks[ tween.prop ] ||
tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
} else { } else {
tween.elem[ tween.prop ] = tween.now; tween.elem[ tween.prop ] = tween.now;
@ -87,7 +97,7 @@ Tween.propHooks = {
} }
}; };
// Support: IE9 // Support: IE <=9 only
// 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 ) {
@ -103,12 +113,13 @@ jQuery.easing = {
}, },
swing: function( p ) { swing: function( p ) {
return 0.5 - Math.cos( p * Math.PI ) / 2; return 0.5 - Math.cos( p * Math.PI ) / 2;
} },
_default: "swing"
}; };
jQuery.fx = Tween.prototype.init; jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point // Back compat <1.8 extension point
jQuery.fx.step = {}; jQuery.fx.step = {};
}); } );

View File

@ -1,13 +1,15 @@
define([ define( [
"../core", "../core",
"../selector", "../selector",
"../effects" "../effects"
], function( jQuery ) { ], function( jQuery ) {
jQuery.expr.filters.animated = function( elem ) { "use strict";
return jQuery.grep(jQuery.timers, function( fn ) {
jQuery.expr.pseudos.animated = function( elem ) {
return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem; return elem === fn.elem;
}).length; } ).length;
}; };
}); } );

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
define([
"../core",
"../event"
], function( jQuery ) {
// Attach a bunch of functions for handling common AJAX events
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
});
});

View File

@ -1,39 +0,0 @@
define([
"../core",
"../event"
], function( jQuery ) {
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
});
jQuery.fn.extend({
hover: function( fnOver, fnOut ) {
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 );
}
});
});

View File

@ -1,9 +0,0 @@
define([
"../var/support"
], function( support ) {
support.focusinBubbles = "onfocusin" in window;
return support;
});

View File

@ -0,0 +1,199 @@
define( [
"../core",
"../var/document",
"../data/var/dataPriv",
"../data/var/acceptData",
"../var/hasOwn",
"../var/isFunction",
"../var/isWindow",
"../event"
], function( jQuery, document, dataPriv, acceptData, hasOwn, isFunction, isWindow ) {
"use strict";
var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
stopPropagationCallback = function( e ) {
e.stopPropagation();
};
jQuery.extend( jQuery.event, {
trigger: function( event, data, elem, onlyHandlers ) {
var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = lastElement = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split( "." );
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (trac-9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
lastElement = cur;
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
dataPriv.get( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
}
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( ( !special._default ||
special._default.apply( eventPath.pop(), data ) === false ) &&
acceptData( elem ) ) {
// Call a native DOM method on the target with the same name as the event.
// Don't do default actions on window, that's where global variables be (trac-6170)
if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
if ( event.isPropagationStopped() ) {
lastElement.addEventListener( type, stopPropagationCallback );
}
elem[ type ]();
if ( event.isPropagationStopped() ) {
lastElement.removeEventListener( type, stopPropagationCallback );
}
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
}
return event.result;
},
// Piggyback on a donor event to simulate a different one
// Used only for `focus(in | out)` events
simulate: function( type, elem, event ) {
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true
}
);
jQuery.event.trigger( e, null, elem );
}
} );
jQuery.fn.extend( {
trigger: function( type, data ) {
return this.each( function() {
jQuery.event.trigger( type, data, this );
} );
},
triggerHandler: function( type, data ) {
var elem = this[ 0 ];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
}
} );
return jQuery;
} );

View File

@ -1,7 +1,9 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
"use strict";
// Register as a named AMD module, since jQuery can be concatenated with other // Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that // files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust // understands anonymous AMD modules. A named AMD is safest and most robust
@ -18,7 +20,7 @@ define([
if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() { define( "jquery", [], function() {
return jQuery; return jQuery;
}); } );
} }
}); } );

View File

@ -1,9 +1,11 @@
define([ define( [
"../core", "../core"
"../var/strundefined" ], function( jQuery ) {
], function( jQuery, strundefined ) {
"use strict";
var var
// Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
_jQuery = window.jQuery, _jQuery = window.jQuery,
@ -23,10 +25,10 @@ jQuery.noConflict = function( deep ) {
}; };
// Expose jQuery and $ identifiers, even in AMD // Expose jQuery and $ identifiers, even in AMD
// (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (trac-13566)
if ( typeof noGlobal === strundefined ) { if ( typeof noGlobal === "undefined" ) {
window.jQuery = window.$ = jQuery; window.jQuery = window.$ = jQuery;
} }
}); } );

View File

@ -1,44 +0,0 @@
/*!
* jQuery JavaScript Library v@VERSION
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: @DATE
*/
(function( global, factory ) {
if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
// For environments that do not have a `window` with a `document`
// (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info.
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Support: Firefox 18+
// Can't be in strict mode, several libs including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
//"use strict";

View File

@ -1,16 +1,16 @@
define([ define( [
"./core", "./core",
"./selector", "./selector",
"./traversing", "./traversing",
"./callbacks", "./callbacks",
"./deferred", "./deferred",
"./deferred/exceptionHook",
"./core/ready", "./core/ready",
"./data", "./data",
"./queue", "./queue",
"./queue/delay", "./queue/delay",
"./attributes", "./attributes",
"./event", "./event",
"./event/alias",
"./manipulation", "./manipulation",
"./manipulation/_evalUrl", "./manipulation/_evalUrl",
"./wrap", "./wrap",
@ -22,7 +22,8 @@ define([
"./ajax/script", "./ajax/script",
"./ajax/jsonp", "./ajax/jsonp",
"./ajax/load", "./ajax/load",
"./event/ajax", "./core/parseXML",
"./core/parseHTML",
"./effects", "./effects",
"./effects/animatedSelector", "./effects/animatedSelector",
"./offset", "./offset",
@ -32,6 +33,8 @@ define([
"./exports/global" "./exports/global"
], function( jQuery ) { ], function( jQuery ) {
"use strict";
return jQuery; return jQuery;
}); } );

View File

@ -1,107 +1,88 @@
define([ define( [
"./core", "./core",
"./var/concat", "./core/isAttached",
"./var/flat",
"./var/isFunction",
"./var/push", "./var/push",
"./var/rcheckableType",
"./core/access", "./core/access",
"./manipulation/var/rcheckableType", "./manipulation/var/rtagName",
"./manipulation/var/rscriptType",
"./manipulation/wrapMap",
"./manipulation/getAll",
"./manipulation/setGlobalEval",
"./manipulation/buildFragment",
"./manipulation/support", "./manipulation/support",
"./data/var/data_priv",
"./data/var/data_user", "./data/var/dataPriv",
"./data/var/dataUser",
"./data/var/acceptData",
"./core/DOMEval",
"./core/nodeName",
"./core/init", "./core/init",
"./data/accepts",
"./traversing", "./traversing",
"./selector", "./selector",
"./event" "./event"
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) { ], function( jQuery, isAttached, flat, isFunction, push, rcheckableType,
access, rtagName, rscriptType,
wrapMap, getAll, setGlobalEval, buildFragment, support,
dataPriv, dataUser, acceptData, DOMEval, nodeName ) {
"use strict";
var var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/, // Support: IE <=10 - 11, Edge 12 - 13 only
rhtml = /<|&#?\w+;/, // In IE/Edge using regex groups here causes severe slowdowns.
rnoInnerhtml = /<(?:script|style|link)/i, // 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,
rscriptType = /^$|\/(?:java|ecma)script/i,
rscriptTypeMasked = /^true\/(.*)/,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
// We have to close these tags to support XHTML (#13200) rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g;
wrapMap = {
// Support: IE9 // Prefer a tbody over its parent table for containing new rows
option: [ 1, "<select multiple='multiple'>", "</select>" ],
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
// Support: IE9
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
// Support: 1.x compatibility
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) { function manipulationTarget( elem, content ) {
return jQuery.nodeName( elem, "table" ) && if ( nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
elem.getElementsByTagName("tbody")[0] || return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
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 = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
return elem; return elem;
} }
function restoreScript( elem ) { function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type ); if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
elem.type = elem.type.slice( 5 );
if ( match ) {
elem.type = match[ 1 ];
} else { } else {
elem.removeAttribute("type"); elem.removeAttribute( "type" );
} }
return elem; return elem;
} }
// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
data_priv.set(
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
);
}
}
function cloneCopyEvent( src, dest ) { function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; var i, l, type, pdataOld, udataOld, udataCur, events;
if ( dest.nodeType !== 1 ) { if ( dest.nodeType !== 1 ) {
return; return;
} }
// 1. Copy private data: events, handlers, etc. // 1. Copy private data: events, handlers, etc.
if ( data_priv.hasData( src ) ) { if ( dataPriv.hasData( src ) ) {
pdataOld = data_priv.access( src ); pdataOld = dataPriv.get( src );
pdataCur = data_priv.set( dest, pdataOld );
events = pdataOld.events; events = pdataOld.events;
if ( events ) { if ( events ) {
delete pdataCur.handle; dataPriv.remove( dest, "handle events" );
pdataCur.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++ ) {
@ -112,24 +93,14 @@ function cloneCopyEvent( src, dest ) {
} }
// 2. Copy user data // 2. Copy user data
if ( data_user.hasData( src ) ) { if ( dataUser.hasData( src ) ) {
udataOld = data_user.access( src ); udataOld = dataUser.access( src );
udataCur = jQuery.extend( {}, udataOld ); udataCur = jQuery.extend( {}, udataOld );
data_user.set( dest, udataCur ); dataUser.set( dest, udataCur );
} }
} }
function getAll( context, tag ) {
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
[];
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}
// Fix IE bugs, see support tests // Fix IE bugs, see support tests
function fixInput( src, dest ) { function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase(); var nodeName = dest.nodeName.toLowerCase();
@ -144,17 +115,141 @@ function fixInput( src, dest ) {
} }
} }
jQuery.extend({ function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays
args = flat( args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[ 0 ],
valueIsFunction = isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( valueIsFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return collection.each( function( index ) {
var self = collection.eq( index );
if ( valueIsFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
domManip( self, args, callback, ignored );
} );
}
if ( l ) {
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
// Require either new content or an interest in ignored elements to invoke the callback
if ( first || ignored ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item
// instead of the first because it can end up
// being emptied incorrectly in certain situations (trac-8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Re-enable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!dataPriv.access( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) {
if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl && !node.noModule ) {
jQuery._evalUrl( node.src, {
nonce: node.nonce || node.getAttribute( "nonce" )
}, doc );
}
} else {
// Unwrap a CDATA section containing script contents. This shouldn't be
// needed as in XML documents they're already not visible when
// inspecting element contents and in HTML documents they have no
// meaning but we're preserving that logic for backwards compatibility.
// This will be removed completely in 4.0. See gh-4904.
DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
}
}
}
}
}
}
return collection;
}
function remove( elem, selector, keepData ) {
var node,
nodes = selector ? jQuery.filter( selector, elem ) : elem,
i = 0;
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) );
}
if ( node.parentNode ) {
if ( keepData && isAttached( node ) ) {
setGlobalEval( getAll( node, "script" ) );
}
node.parentNode.removeChild( node );
}
}
return elem;
}
jQuery.extend( {
htmlPrefilter: function( html ) {
return html;
},
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var i, l, srcElements, destElements, var i, l, srcElements, destElements,
clone = elem.cloneNode( true ), clone = elem.cloneNode( true ),
inPage = jQuery.contains( elem.ownerDocument, elem ); inPage = isAttached( elem );
// Fix IE cloning issues // Fix IE cloning issues
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) { !jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 // We eschew jQuery#find here for performance reasons:
// https://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone ); destElements = getAll( clone );
srcElements = getAll( elem ); srcElements = getAll( elem );
@ -187,102 +282,14 @@ jQuery.extend({
return clone; return clone;
}, },
buildFragment: function( elems, context, scripts, selection ) {
var elem, tmp, tag, wrap, contains, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement("div") );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (#12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( (elem = nodes[ i++ ]) ) {
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
continue;
}
contains = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( contains ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
},
cleanData: function( elems ) { cleanData: function( elems ) {
var data, elem, type, key, var data, elem, type,
special = jQuery.event.special, special = jQuery.event.special,
i = 0; i = 0;
for ( ; (elem = elems[ i ]) !== undefined; i++ ) { for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
if ( jQuery.acceptData( elem ) ) { if ( acceptData( elem ) ) {
key = elem[ data_priv.expando ]; if ( ( data = elem[ dataPriv.expando ] ) ) {
if ( key && (data = data_priv.cache[ key ]) ) {
if ( data.events ) { if ( data.events ) {
for ( type in data.events ) { for ( type in data.events ) {
if ( special[ type ] ) { if ( special[ type ] ) {
@ -294,91 +301,82 @@ jQuery.extend({
} }
} }
} }
if ( data_priv.cache[ key ] ) {
// Discard any remaining `private` data // Support: Chrome <=35 - 45+
delete data_priv.cache[ key ]; // Assign undefined instead of using delete, see Data#remove
} elem[ dataPriv.expando ] = undefined;
}
if ( elem[ dataUser.expando ] ) {
// Support: Chrome <=35 - 45+
// Assign undefined instead of using delete, see Data#remove
elem[ dataUser.expando ] = undefined;
} }
} }
// Discard any remaining `user` data
delete data_user.cache[ elem[ data_user.expando ] ];
} }
} }
}); } );
jQuery.fn.extend( {
detach: function( selector ) {
return remove( this, selector, true );
},
remove: function( selector ) {
return remove( this, selector );
},
jQuery.fn.extend({
text: function( value ) { text: function( value ) {
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().each( function() {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
this.textContent = value; this.textContent = value;
} }
}); } );
}, null, value, arguments.length ); }, null, value, arguments.length );
}, },
append: function() { append: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.appendChild( elem ); target.appendChild( elem );
} }
}); } );
}, },
prepend: function() { prepend: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild ); target.insertBefore( elem, target.firstChild );
} }
}); } );
}, },
before: function() { before: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
} }
}); } );
}, },
after: function() { after: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
} }
}); } );
},
remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
}
if ( elem.parentNode ) {
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
setGlobalEval( getAll( elem, "script" ) );
}
elem.parentNode.removeChild( elem );
}
}
return this;
}, },
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 ) { if ( elem.nodeType === 1 ) {
// Prevent memory leaks // Prevent memory leaks
@ -396,9 +394,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 ) {
@ -415,7 +413,7 @@ jQuery.fn.extend({
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
value = value.replace( rxhtmlTag, "<$1></$2>" ); value = jQuery.htmlPrefilter( value );
try { try {
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
@ -431,7 +429,7 @@ jQuery.fn.extend({
elem = 0; elem = 0;
// If using innerHTML throws an exception, use the fallback method // If using innerHTML throws an exception, use the fallback method
} catch( e ) {} } catch ( e ) {}
} }
if ( elem ) { if ( elem ) {
@ -441,115 +439,25 @@ jQuery.fn.extend({
}, },
replaceWith: function() { replaceWith: function() {
var arg = arguments[ 0 ]; var ignored = [];
// Make the changes, replacing each context element with the new content // Make the changes, replacing each non-ignored context element with the new content
this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
arg = this.parentNode; var parent = this.parentNode;
jQuery.cleanData( getAll( this ) ); if ( jQuery.inArray( this, ignored ) < 0 ) {
jQuery.cleanData( getAll( this ) );
if ( arg ) { if ( parent ) {
arg.replaceChild( elem, this ); parent.replaceChild( elem, this );
}
});
// Force removal if there was no new content (e.g., from empty arguments)
return arg && (arg.length || arg.nodeType) ? this : this.remove();
},
detach: function( selector ) {
return this.remove( selector, true );
},
domManip: function( args, callback ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = this.length,
set = this,
iNoClone = l - 1,
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
self.domManip( args, callback );
});
}
if ( l ) {
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
if ( first ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: QtWebKit
// jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( this[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
}
}
}
} }
} }
}
return this; // Force callback invocation
}, ignored );
} }
}); } );
jQuery.each({ jQuery.each( {
appendTo: "append", appendTo: "append",
prependTo: "prepend", prependTo: "prepend",
insertBefore: "before", insertBefore: "before",
@ -567,14 +475,14 @@ jQuery.each({
elems = i === last ? this : this.clone( true ); elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems ); jQuery( insert[ i ] )[ original ]( elems );
// Support: QtWebKit // Support: Android <=4.0 only, PhantomJS 1 only
// .get() because push.apply(_, arraylike) throws // .get() because push.apply(_, arraylike) throws on ancient WebKit
push.apply( ret, elems.get() ); push.apply( ret, elems.get() );
} }
return this.pushStack( ret ); return this.pushStack( ret );
}; };
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,18 +1,32 @@
define([ define( [
"../ajax" "../ajax"
], function( jQuery ) { ], function( jQuery ) {
jQuery._evalUrl = function( url ) { "use strict";
return jQuery.ajax({
jQuery._evalUrl = function( url, options, doc ) {
return jQuery.ajax( {
url: url, url: url,
// Make this explicit, since user can override this through ajaxSetup (trac-11264)
type: "GET", type: "GET",
dataType: "script", dataType: "script",
cache: true,
async: false, async: false,
global: false, global: false,
"throws": true
}); // Only evaluate the response if it is successful (gh-4126)
// dataFilter is not invoked for failure responses, so using it instead
// of the default converter is kludgy but it works.
converters: {
"text script": function() {}
},
dataFilter: function( response ) {
jQuery.globalEval( response, options, doc );
}
} );
}; };
return jQuery._evalUrl; return jQuery._evalUrl;
}); } );

View File

@ -0,0 +1,106 @@
define( [
"../core",
"../core/toType",
"../core/isAttached",
"./var/rtagName",
"./var/rscriptType",
"./wrapMap",
"./getAll",
"./setGlobalEval"
], function( jQuery, toType, isAttached, rtagName, rscriptType, wrapMap, getAll, setGlobalEval ) {
"use strict";
var rhtml = /<|&#?\w+;/;
function buildFragment( elems, context, scripts, selection, ignored ) {
var elem, tmp, tag, wrap, attached, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( toType( elem ) === "object" ) {
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Support: Android <=4.0 only, PhantomJS 1 only
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (trac-12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( ( elem = nodes[ i++ ] ) ) {
// Skip elements already in the context collection (trac-4087)
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
if ( ignored ) {
ignored.push( elem );
}
continue;
}
attached = isAttached( elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( attached ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( ( elem = tmp[ j++ ] ) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
}
return buildFragment;
} );

View File

@ -0,0 +1,32 @@
define( [
"../core",
"../core/nodeName"
], function( jQuery, nodeName ) {
"use strict";
function getAll( context, tag ) {
// Support: IE <=9 - 11 only
// Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
var ret;
if ( typeof context.getElementsByTagName !== "undefined" ) {
ret = context.getElementsByTagName( tag || "*" );
} else if ( typeof context.querySelectorAll !== "undefined" ) {
ret = context.querySelectorAll( tag || "*" );
} else {
ret = [];
}
if ( tag === undefined || tag && nodeName( context, tag ) ) {
return jQuery.merge( [ context ], ret );
}
return ret;
}
return getAll;
} );

View File

@ -0,0 +1,22 @@
define( [
"../data/var/dataPriv"
], function( dataPriv ) {
"use strict";
// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
dataPriv.set(
elems[ i ],
"globalEval",
!refElements || dataPriv.get( refElements[ i ], "globalEval" )
);
}
}
return setGlobalEval;
} );

View File

@ -1,32 +1,41 @@
define([ define( [
"../var/document",
"../var/support" "../var/support"
], function( support ) { ], function( document, support ) {
(function() { "use strict";
( function() {
var fragment = document.createDocumentFragment(), var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ), div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" ); input = document.createElement( "input" );
// Support: Safari<=5.1 // Support: Android 4.0 - 4.3 only
// Check state lost if the name is set (#11217) // Check state lost if the name is set (trac-11217)
// Support: Windows Web Apps (WWA) // Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901) // `name` and `type` must use .setAttribute for WWA (trac-14901)
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: Safari<=5.1, Android<4.2 // Support: Android <=4.1 only
// Older WebKit doesn't clone checked state correctly in fragments // Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE<=11+ // Support: IE <=11 only
// Make sure textarea (and checkbox) defaultValue is properly cloned // Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>"; div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
})();
// Support: IE <=9 only
// IE <=9 replaces <option> tags with their contents when inserted outside of
// the select element.
div.innerHTML = "<option></option>";
support.option = !!div.lastChild;
} )();
return support; return support;
}); } );

View File

@ -1,3 +0,0 @@
define(function() {
return (/^(?:checkbox|radio)$/i);
});

View File

@ -0,0 +1,5 @@
define( function() {
"use strict";
return ( /^$|^module$|\/(?:java|ecma)script/i );
} );

View File

@ -0,0 +1,8 @@
define( function() {
"use strict";
// rtagName captures the name from the first start tag in a string of HTML
// https://html.spec.whatwg.org/multipage/syntax.html#tag-open-state
// https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state
return ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
} );

View File

@ -0,0 +1,30 @@
define( [
"./support"
], function( support ) {
"use strict";
// We have to close these tags to support XHTML (trac-13200)
var wrapMap = {
// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
// Support: IE <=9 only
if ( !support.option ) {
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
}
return wrapMap;
} );

View File

@ -1,25 +1,20 @@
define([ define( [
"./core", "./core",
"./var/strundefined",
"./core/access", "./core/access",
"./var/documentElement",
"./var/isFunction",
"./css/var/rnumnonpx", "./css/var/rnumnonpx",
"./css/curCSS", "./css/curCSS",
"./css/addGetHookIf", "./css/addGetHookIf",
"./css/support", "./css/support",
"./var/isWindow",
"./core/init", "./core/init",
"./css", "./css",
"./selector" // contains "./selector" // contains
], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) { ], function( jQuery, access, documentElement, isFunction, rnumnonpx,
curCSS, addGetHookIf, support, isWindow ) {
var docElem = window.document.documentElement; "use strict";
/**
* Gets a window from an element
*/
function getWindow( elem ) {
return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
}
jQuery.offset = { jQuery.offset = {
setOffset: function( elem, options, i ) { setOffset: function( elem, options, i ) {
@ -37,7 +32,7 @@ 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; ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
// Need to be able to calculate position if either // Need to be able to calculate position if either
// top or left is auto and position is either absolute or fixed // top or left is auto and position is either absolute or fixed
@ -51,8 +46,10 @@ jQuery.offset = {
curLeft = parseFloat( curCSSLeft ) || 0; curLeft = parseFloat( curCSSLeft ) || 0;
} }
if ( jQuery.isFunction( options ) ) { if ( isFunction( options ) ) {
options = options.call( elem, i, curOffset );
// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
} }
if ( options.top != null ) { if ( options.top != null ) {
@ -71,71 +68,81 @@ jQuery.offset = {
} }
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
// offset() relates an element's border box to the document origin
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, var rect, win,
elem = this[ 0 ], elem = this[ 0 ];
box = { top: 0, left: 0 },
doc = elem && elem.ownerDocument;
if ( !doc ) { if ( !elem ) {
return; return;
} }
docElem = doc.documentElement; // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
// Support: IE <=11 only
// Make sure it's not a disconnected DOM node // Running getBoundingClientRect on a
if ( !jQuery.contains( docElem, elem ) ) { // disconnected node in IE throws an error
return box; if ( !elem.getClientRects().length ) {
return { top: 0, left: 0 };
} }
// Support: BlackBerry 5, iOS 3 (original iPhone) // Get document-relative position by adding viewport scroll to viewport-relative gBCR
// If we don't have gBCR, just use 0,0 rather than error rect = elem.getBoundingClientRect();
if ( typeof elem.getBoundingClientRect !== strundefined ) { win = elem.ownerDocument.defaultView;
box = elem.getBoundingClientRect();
}
win = getWindow( doc );
return { return {
top: box.top + win.pageYOffset - docElem.clientTop, top: rect.top + win.pageYOffset,
left: box.left + win.pageXOffset - docElem.clientLeft left: rect.left + win.pageXOffset
}; };
}, },
// position() relates an element's margin box to its offset parent's padding box
// This corresponds to the behavior of CSS absolute positioning
position: function() { position: function() {
if ( !this[ 0 ] ) { if ( !this[ 0 ] ) {
return; return;
} }
var offsetParent, offset, var offsetParent, offset, doc,
elem = this[ 0 ], elem = this[ 0 ],
parentOffset = { top: 0, left: 0 }; parentOffset = { top: 0, left: 0 };
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent // position:fixed elements are offset from the viewport, which itself always has zero offset
if ( jQuery.css( elem, "position" ) === "fixed" ) { if ( jQuery.css( elem, "position" ) === "fixed" ) {
// Assume getBoundingClientRect is there when computed position is fixed
// Assume position:fixed implies availability of getBoundingClientRect
offset = elem.getBoundingClientRect(); offset = elem.getBoundingClientRect();
} else { } else {
// Get *real* offsetParent
offsetParent = this.offsetParent();
// Get correct offsets
offset = this.offset(); offset = this.offset();
if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
parentOffset = offsetParent.offset();
}
// Add offsetParent borders // Account for the *real* offset parent, which can be the document or its root element
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); // when a statically positioned element is identified
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); doc = elem.ownerDocument;
offsetParent = elem.offsetParent || doc.documentElement;
while ( offsetParent &&
( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
jQuery.css( offsetParent, "position" ) === "static" ) {
offsetParent = offsetParent.parentNode;
}
if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
// Incorporate borders into its offset, since they are outside its content origin
parentOffset = jQuery( offsetParent ).offset();
parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
}
} }
// Subtract parent offsets and element margins // Subtract parent offsets and element margins
@ -145,18 +152,28 @@ jQuery.fn.extend({
}; };
}, },
// 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 || docElem; var offsetParent = this.offsetParent;
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) { while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
offsetParent = offsetParent.offsetParent; offsetParent = offsetParent.offsetParent;
} }
return offsetParent || docElem; 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 ) {
@ -164,7 +181,14 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
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 );
// Coalesce documents and windows
var win;
if ( isWindow( elem ) ) {
win = elem;
} else if ( elem.nodeType === 9 ) {
win = elem.defaultView;
}
if ( val === undefined ) { if ( val === undefined ) {
return win ? win[ prop ] : elem[ method ]; return win ? win[ prop ] : elem[ method ];
@ -172,28 +196,29 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
if ( win ) { if ( win ) {
win.scrollTo( win.scrollTo(
!top ? val : window.pageXOffset, !top ? val : win.pageXOffset,
top ? val : window.pageYOffset top ? val : win.pageYOffset
); );
} else { } else {
elem[ method ] = val; elem[ method ] = val;
} }
}, method, val, arguments.length, null ); }, method, val, arguments.length );
}; };
}); } );
// Support: Safari<7+, Chrome<37+ // Support: Safari <=7 - 9.1, Chrome <=37 - 49
// 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 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
// 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, 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" :
@ -201,7 +226,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
} }
} }
); );
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1 +0,0 @@
}));

View File

@ -1,22 +1,24 @@
define([ define( [
"./core", "./core",
"./data/var/data_priv", "./data/var/dataPriv",
"./deferred", "./deferred",
"./callbacks" "./callbacks"
], function( jQuery, data_priv ) { ], function( jQuery, dataPriv ) {
jQuery.extend({ "use strict";
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 = data_priv.get( elem, type ); queue = dataPriv.get( 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 || Array.isArray( data ) ) {
queue = data_priv.access( elem, type, jQuery.makeArray(data) ); queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
} else { } else {
queue.push( data ); queue.push( data );
} }
@ -63,15 +65,15 @@ jQuery.extend({
// Not public - generate a queueHooks object, or return the current one // Not public - generate a queueHooks object, or return the current one
_queueHooks: function( elem, type ) { _queueHooks: function( elem, type ) {
var key = type + "queueHooks"; var key = type + "queueHooks";
return data_priv.get( elem, key ) || data_priv.access( elem, key, { return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
empty: jQuery.Callbacks("once memory").add(function() { empty: jQuery.Callbacks( "once memory" ).add( function() {
data_priv.remove( elem, [ type + "queue", key ] ); dataPriv.remove( elem, [ type + "queue", key ] );
}) } )
}); } );
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
queue: function( type, data ) { queue: function( type, data ) {
var setter = 2; var setter = 2;
@ -82,30 +84,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 +130,7 @@ jQuery.fn.extend({
type = type || "fx"; type = type || "fx";
while ( i-- ) { while ( i-- ) {
tmp = data_priv.get( elements[ i ], type + "queueHooks" ); tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
if ( tmp && tmp.empty ) { if ( tmp && tmp.empty ) {
count++; count++;
tmp.empty.add( resolve ); tmp.empty.add( resolve );
@ -136,7 +139,7 @@ jQuery.fn.extend({
resolve(); resolve();
return defer.promise( obj ); return defer.promise( obj );
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,22 +1,23 @@
define([ define( [
"../core", "../core",
"../queue", "../queue",
"../effects" // Delay is optional because of this dependency "../effects" // Delay is optional because of this dependency
], function( jQuery ) { ], function( jQuery ) {
"use strict";
// Based off of the plugin by Clint Helfers, with permission. // Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/
jQuery.fn.delay = function( time, type ) { jQuery.fn.delay = function( time, type ) {
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
type = type || "fx"; type = type || "fx";
return this.queue( type, function( next, hooks ) { return this.queue( type, function( next, hooks ) {
var timeout = setTimeout( next, time ); var timeout = window.setTimeout( next, time );
hooks.stop = function() { hooks.stop = function() {
clearTimeout( timeout ); window.clearTimeout( timeout );
}; };
}); } );
}; };
return jQuery.fn.delay; return jQuery.fn.delay;
}); } );

Some files were not shown because too many files have changed in this diff Show More