Comparing version 2.1.4 to 3.0.0-alpha1
@@ -228,1 +228,35 @@ Authors ordered by first contribution. | ||
TJ VanToll <tj.vantoll@gmail.com> | ||
Senya Pugach <upisfree@outlook.com> | ||
Aurelio De Rosa <aurelioderosa@gmail.com> | ||
Nazar Mokrynskyi <nazar@mokrynskyi.com> | ||
Amit Merchant <bullredeyes@gmail.com> | ||
Jason Bedard <jason+github@jbedard.ca> | ||
Arthur Verschaeve <contact@arthurverschaeve.be> | ||
Dan Hart <danhart@notonthehighstreet.com> | ||
Bin Xin <rhyzix@gmail.com> | ||
David Corbacho <davidcorbacho@gmail.com> | ||
Veaceslav Grimalschi <grimalschi@yandex.ru> | ||
Daniel Husar <dano.husar@gmail.com> | ||
Frederic Hemberger <mail@frederic-hemberger.de> | ||
Ben Toews <mastahyeti@gmail.com> | ||
Aditya Raghavan <araghavan3@gmail.com> | ||
Victor Homyakov <vkhomyackov@gmail.com> | ||
Shivaji Varma <contact@shivajivarma.com> | ||
Nicolas HENRY <icewil@gmail.com> | ||
Anne-Gaelle Colom <coloma@westminster.ac.uk> | ||
George Mauer <gmauer@gmail.com> | ||
Leonardo Braga <leonardo.braga@gmail.com> | ||
Stephen Edgar <stephen@netweb.com.au> | ||
Thomas Tortorini <thomastortorini@gmail.com> | ||
Winston Howes <winstonhowes@gmail.com> | ||
Jon Hester <jon.d.hester@gmail.com> | ||
Alexander O'Mara <me@alexomara.com> | ||
Bastian Buchholz <buchholz.bastian@googlemail.com> | ||
Arthur Stolyar <nekr.fabula@gmail.com> | ||
Calvin Metcalf <calvin.metcalf@gmail.com> | ||
Mu Haibao <mhbseal@163.com> | ||
Richard McDaniel <rm0026@uah.edu> | ||
Chris Rebert <github@rebertia.com> | ||
Gabriel Schulhof <gabriel.schulhof@intel.com> | ||
Gilad Peleg <giladp007@gmail.com> | ||
Martin Naumann <martin@geekonaut.de> |
{ | ||
"name": "jquery", | ||
"version": "2.1.4", | ||
"main": "dist/jquery.js", | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"build", | ||
"dist/cdn", | ||
"speed", | ||
"test", | ||
"*.md", | ||
"AUTHORS.txt", | ||
"Gruntfile.js", | ||
"package.json" | ||
], | ||
"devDependencies": { | ||
"sizzle": "2.1.1-jquery.2.1.2", | ||
"requirejs": "2.1.10", | ||
"qunit": "1.14.0", | ||
"sinon": "1.8.1" | ||
}, | ||
"keywords": [ | ||
"jquery", | ||
"javascript", | ||
"browser", | ||
"library" | ||
] | ||
} | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "JavaScript library for DOM operations", | ||
"version": "2.1.4", | ||
"version": "3.0.0-alpha1", | ||
"main": "dist/jquery.js", | ||
@@ -11,3 +11,3 @@ "homepage": "http://jquery.com", | ||
"name": "jQuery Foundation and other contributors", | ||
"url": "https://github.com/jquery/jquery/blob/2.1.4/AUTHORS.txt" | ||
"url": "https://github.com/jquery/jquery/blob/3.0.0-alpha1/AUTHORS.txt" | ||
}, | ||
@@ -25,34 +25,66 @@ "repository": { | ||
"bugs": { | ||
"url": "http://bugs.jquery.com" | ||
"url": "https://github.com/jquery/jquery/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/jquery/jquery/blob/2.1.4/MIT-LICENSE.txt" | ||
} | ||
], | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"commitplease": "2.0.0", | ||
"grunt": "0.4.2", | ||
"grunt-bowercopy": "0.7.1", | ||
"core-js": "0.9.17", | ||
"grunt": "0.4.5", | ||
"grunt-babel": "5.0.1", | ||
"grunt-cli": "0.1.13", | ||
"grunt-compare-size": "0.4.0", | ||
"grunt-contrib-jshint": "0.8.0", | ||
"grunt-contrib-uglify": "0.3.2", | ||
"grunt-contrib-watch": "0.5.3", | ||
"grunt-git-authors": "1.2.0", | ||
"grunt-jscs-checker": "0.4.1", | ||
"grunt-contrib-jshint": "0.11.2", | ||
"grunt-contrib-uglify": "0.7.0", | ||
"grunt-contrib-watch": "0.6.1", | ||
"grunt-git-authors": "2.0.1", | ||
"grunt-jscs-checker": "0.8.1", | ||
"grunt-jsonlint": "1.0.4", | ||
"grunt-npmcopy": "0.1.0", | ||
"gzip-js": "0.3.2", | ||
"jsdom": "1.5.0", | ||
"load-grunt-tasks": "0.3.0", | ||
"requirejs": "2.1.10", | ||
"testswarm": "1.1.0" | ||
"load-grunt-tasks": "1.0.0", | ||
"native-promise-only": "0.7.8-a", | ||
"promises-aplus-tests": "2.1.0", | ||
"q": "1.1.2", | ||
"qunitjs": "1.17.1", | ||
"requirejs": "2.1.17", | ||
"sinon": "1.10.3", | ||
"sizzle": "2.2.0", | ||
"testswarm": "1.1.0", | ||
"win-spawn": "2.0.0" | ||
}, | ||
"jsdomVersions": { | ||
"node": "3.1.2", | ||
"iojs": "5.3.0" | ||
}, | ||
"scripts": { | ||
"build": "npm install && grunt", | ||
"start": "grunt watch", | ||
"test": "grunt" | ||
"test": "grunt && grunt test" | ||
}, | ||
"commitplease": { | ||
"components": [ | ||
"Docs", | ||
"Tests", | ||
"Build", | ||
"Release", | ||
"Core", | ||
"Ajax", | ||
"Attributes", | ||
"Callbacks", | ||
"CSS", | ||
"Data", | ||
"Deferred", | ||
"Dimensions", | ||
"Effects", | ||
"Event", | ||
"Manipulation", | ||
"Offset", | ||
"Queue", | ||
"Selector", | ||
"Serialize", | ||
"Traversing", | ||
"Wrap" | ||
] | ||
} | ||
} |
373
README.md
@@ -1,372 +0,5 @@ | ||
[jQuery](http://jquery.com/) - New Wave JavaScript | ||
================================================== | ||
# jQuery Dist | ||
Contribution Guides | ||
-------------------------------------- | ||
This repo only contains package distribution files for jQuery Core. | ||
In the spirit of open source software development, jQuery always encourages community code contribution. To help you get started and before you jump into writing code, be sure to read these important contribution guidelines thoroughly: | ||
1. [Getting Involved](http://contribute.jquery.org/) | ||
2. [Core Style Guide](http://contribute.jquery.org/style-guide/js/) | ||
3. [Writing Code for jQuery Foundation Projects](http://contribute.jquery.org/code/) | ||
Environments in which to use jQuery | ||
-------------------------------------- | ||
- [Browser support](http://jquery.com/browser-support/) differs between the master (2.x) branch and the 1.x-master branch. Specifically, 2.x does not support legacy browsers such as IE6-8. The jQuery team continues to provide support for legacy browsers on the 1.x-master branch. Use the latest 1.x release if support for those browsers is required. See [browser support](http://jquery.com/browser-support/) for more info. | ||
- To use jQuery in Node, browser extensions, and other non-browser environments, use only **2.x** releases. 1.x does not support these environments. | ||
What you need to build your own jQuery | ||
-------------------------------------- | ||
In order to build jQuery, you need to have Node.js/npm latest and git 1.7 or later. | ||
(Earlier versions might work OK, but are not tested.) | ||
For Windows you have to download and install [git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/download/). | ||
Mac OS users should install [Homebrew](http://mxcl.github.com/homebrew/). Once Homebrew is installed, run `brew install git` to install git, | ||
and `brew install node` to install Node.js. | ||
Linux/BSD users should use their appropriate package managers to install git and Node.js, or build from source | ||
if you swing that way. Easy-peasy. | ||
How to build your own jQuery | ||
---------------------------- | ||
Clone a copy of the main jQuery git repo by running: | ||
```bash | ||
git clone git://github.com/jquery/jquery.git | ||
``` | ||
Enter the jquery directory and run the build script: | ||
```bash | ||
cd jquery && npm run build | ||
``` | ||
The built version of jQuery will be put in the `dist/` subdirectory, along with the minified copy and associated map file. | ||
If you want create custom build or help with jQuery development, it would be better to install [grunt command line interface](https://github.com/gruntjs/grunt-cli) as a global package: | ||
``` | ||
npm install -g grunt-cli | ||
``` | ||
Make sure you have `grunt` installed by testing: | ||
``` | ||
grunt -v | ||
``` | ||
Now by running `grunt` command, in the jquery directory, you could build full version of jQuery, just like with `npm run build` command: | ||
``` | ||
grunt | ||
``` | ||
There are many other tasks available for jQuery Core: | ||
``` | ||
grunt -help | ||
``` | ||
### Modules | ||
Special builds can be created that exclude subsets of jQuery functionality. | ||
This allows for smaller custom builds when the builder is certain that those parts of jQuery are not being used. | ||
For example, an app that only used JSONP for `$.ajax()` and did not need to calculate offsets or positions of elements could exclude the offset and ajax/xhr modules. | ||
Any module may be excluded except for `core`, and `selector`. To exclude a module, pass its path relative to the `src` folder (without the `.js` extension). | ||
Some example modules that can be excluded are: | ||
- **ajax**: All AJAX functionality: `$.ajax()`, `$.get()`, `$.post()`, `$.ajaxSetup()`, `.load()`, transports, and ajax event shorthands such as `.ajaxStart()`. | ||
- **ajax/xhr**: The XMLHTTPRequest AJAX transport only. | ||
- **ajax/script**: The `<script>` AJAX transport only; used to retrieve scripts. | ||
- **ajax/jsonp**: The JSONP AJAX transport only; depends on the ajax/script transport. | ||
- **css**: The `.css()` method plus non-animated `.show()`, `.hide()` and `.toggle()`. Also removes **all** modules depending on css (including **effects**, **dimensions**, and **offset**). | ||
- **deprecated**: Methods documented as deprecated but not yet removed; currently only `.andSelf()`. | ||
- **dimensions**: The `.width()` and `.height()` methods, including `inner-` and `outer-` variations. | ||
- **effects**: The `.animate()` method and its shorthands such as `.slideUp()` or `.hide("slow")`. | ||
- **event**: The `.on()` and `.off()` methods and all event functionality. Also removes `event/alias`. | ||
- **event/alias**: All event attaching/triggering shorthands like `.click()` or `.mouseover()`. | ||
- **offset**: The `.offset()`, `.position()`, `.offsetParent()`, `.scrollLeft()`, and `.scrollTop()` methods. | ||
- **wrap**: The `.wrap()`, `.wrapAll()`, `.wrapInner()`, and `.unwrap()` methods. | ||
- **core/ready**: Exclude the ready module if you place your scripts at the end of the body. Any ready callbacks bound with `jQuery()` will simply be called immediately. However, `jQuery(document).ready()` will not be a function and `.on("ready", ...)` or similar will not be triggered. | ||
- **deferred**: Exclude jQuery.Deferred. This also removes jQuery.Callbacks. *Note* that modules that depend on jQuery.Deferred(AJAX, effects, core/ready) will not be removed and will still expect jQuery.Deferred to be there. Include your own jQuery.Deferred implementation or exclude those modules as well (`grunt custom:-deferred,-ajax,-effects,-core/ready`). | ||
- **exports/global**: Exclude the attachment of global jQuery variables ($ and jQuery) to the window. | ||
- **exports/amd**: Exclude the AMD definition. | ||
As a special case, you may also replace Sizzle by using a special flag `grunt custom:-sizzle`. | ||
- **sizzle**: The Sizzle selector engine. When this module is excluded, it is replaced by a rudimentary selector engine based on the browser's `querySelectorAll` method that does not support jQuery selector extensions or enhanced semantics. See the selector-native.js file for details. | ||
*Note*: Excluding Sizzle will also exclude all jQuery selector extensions (such as `effects/animatedSelector` and `css/hiddenVisibleSelectors`). | ||
The build process shows a message for each dependent module it excludes or includes. | ||
##### AMD name | ||
As an option, you can set the module name for jQuery's AMD definition. By default, it is set to "jquery", which plays nicely with plugins and third-party libraries, but there may be cases where you'd like to change this. Simply set the `"amd"` option: | ||
```bash | ||
grunt custom --amd="custom-name" | ||
``` | ||
Or, to define anonymously, set the name to an empty string. | ||
```bash | ||
grunt custom --amd="" | ||
``` | ||
#### Custom Build Examples | ||
To create a custom build of the latest stable version, first check out the version: | ||
```bash | ||
git pull; git checkout $(git describe --abbrev=0 --tags) | ||
``` | ||
Then, make sure all Node dependencies are installed: | ||
```bash | ||
npm install | ||
``` | ||
Create the custom build using the `grunt custom` option, listing the modules to be excluded. | ||
Exclude all **ajax** functionality: | ||
```bash | ||
grunt custom:-ajax | ||
``` | ||
Excluding **css** removes modules depending on CSS: **effects**, **offset**, **dimensions**. | ||
```bash | ||
grunt custom:-css | ||
``` | ||
Exclude a bunch of modules: | ||
```bash | ||
grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event/alias,-offset,-wrap | ||
``` | ||
For questions or requests regarding custom builds, please start a thread on the [Developing jQuery Core](https://forum.jquery.com/developing-jquery-core) section of the forum. Due to the combinatorics and custom nature of these builds, they are not regularly tested in jQuery's unit test process. The non-Sizzle selector engine currently does not pass unit tests because it is missing too much essential functionality. | ||
Running the Unit Tests | ||
-------------------------------------- | ||
Make sure you have the necessary dependencies: | ||
```bash | ||
npm install | ||
``` | ||
Start `grunt watch` or `npm start` to auto-build jQuery as you work: | ||
```bash | ||
cd jquery && grunt watch | ||
``` | ||
Run the unit tests with a local server that supports PHP. Ensure that you run the site from the root directory, not the "test" directory. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options: | ||
- Windows: [WAMP download](http://www.wampserver.com/en/) | ||
- Mac: [MAMP download](http://www.mamp.info/en/index.html) | ||
- Linux: [Setting up LAMP](https://www.linux.com/learn/tutorials/288158-easy-lamp-server-installation) | ||
- [Mongoose (most platforms)](http://code.google.com/p/mongoose/) | ||
Building to a different directory | ||
--------------------------------- | ||
To copy the built jQuery files from `/dist` to another directory: | ||
```bash | ||
grunt && grunt dist:/path/to/special/location/ | ||
``` | ||
With this example, the output files would be: | ||
```bash | ||
/path/to/special/location/jquery.js | ||
/path/to/special/location/jquery.min.js | ||
``` | ||
To add a permanent copy destination, create a file in `dist/` called ".destination.json". Inside the file, paste and customize the following: | ||
```json | ||
{ | ||
"/Absolute/path/to/other/destination": true | ||
} | ||
``` | ||
Additionally, both methods can be combined. | ||
Essential Git | ||
------------- | ||
As the source code is handled by the Git version control system, it's useful to know some features used. | ||
### Cleaning ### | ||
If you want to purge your working directory back to the status of upstream, following commands can be used (remember everything you've worked on is gone after these): | ||
```bash | ||
git reset --hard upstream/master | ||
git clean -fdx | ||
``` | ||
### Rebasing ### | ||
For feature/topic branches, you should always use the `--rebase` flag to `git pull`, or if you are usually handling many temporary "to be in a github pull request" branches, run following to automate this: | ||
```bash | ||
git config branch.autosetuprebase local | ||
``` | ||
(see `man git-config` for more information) | ||
### Handling merge conflicts ### | ||
If you're getting merge conflicts when merging, instead of editing the conflicted files manually, you can use the feature | ||
`git mergetool`. Even though the default tool `xxdiff` looks awful/old, it's rather useful. | ||
Following are some commands that can be used there: | ||
* `Ctrl + Alt + M` - automerge as much as possible | ||
* `b` - jump to next merge conflict | ||
* `s` - change the order of the conflicted lines | ||
* `u` - undo a merge | ||
* `left mouse button` - mark a block to be the winner | ||
* `middle mouse button` - mark a line to be the winner | ||
* `Ctrl + S` - save | ||
* `Ctrl + Q` - quit | ||
[QUnit](http://api.qunitjs.com) Reference | ||
----------------- | ||
### Test methods ### | ||
```js | ||
expect( numAssertions ); | ||
stop(); | ||
start(); | ||
``` | ||
Note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite so that start and stop can be passed as callbacks without worrying about their parameters | ||
### Test assertions ### | ||
```js | ||
ok( value, [message] ); | ||
equal( actual, expected, [message] ); | ||
notEqual( actual, expected, [message] ); | ||
deepEqual( actual, expected, [message] ); | ||
notDeepEqual( actual, expected, [message] ); | ||
strictEqual( actual, expected, [message] ); | ||
notStrictEqual( actual, expected, [message] ); | ||
throws( block, [expected], [message] ); | ||
``` | ||
Test Suite Convenience Methods Reference (See [test/data/testinit.js](https://github.com/jquery/jquery/blob/master/test/data/testinit.js)) | ||
------------------------------ | ||
### Returns an array of elements with the given IDs ### | ||
```js | ||
q( ... ); | ||
``` | ||
Example: | ||
```js | ||
q("main", "foo", "bar"); | ||
=> [ div#main, span#foo, input#bar ] | ||
``` | ||
### Asserts that a selection matches the given IDs ### | ||
```js | ||
t( testName, selector, [ "array", "of", "ids" ] ); | ||
``` | ||
Example: | ||
```js | ||
t("Check for something", "//[a]", ["foo", "baar"]); | ||
``` | ||
### Fires a native DOM event without going through jQuery ### | ||
```js | ||
fireNative( node, eventType ) | ||
``` | ||
Example: | ||
```js | ||
fireNative( jQuery("#elem")[0], "click" ); | ||
``` | ||
### Add random number to url to stop caching ### | ||
```js | ||
url( "some/url.php" ); | ||
``` | ||
Example: | ||
```js | ||
url("data/test.html"); | ||
=> "data/test.html?10538358428943" | ||
url("data/test.php?foo=bar"); | ||
=> "data/test.php?foo=bar&10538358345554" | ||
``` | ||
### Load tests in an iframe ### | ||
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"` | ||
and fires the given callback on jQuery ready (using the jQuery loading from that page) | ||
and passes the iFrame's jQuery to the callback. | ||
```js | ||
testIframe( fileName, testName, callback ); | ||
``` | ||
Callback arguments: | ||
```js | ||
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument ); | ||
``` | ||
### Load tests in an iframe (window.iframeCallback) ### | ||
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"` | ||
The given callback is fired when window.iframeCallback is called by the page. | ||
The arguments passed to the callback are the same as the | ||
arguments passed to window.iframeCallback, whatever that may be | ||
```js | ||
testIframeWithCallback( testName, fileName, callback ); | ||
``` | ||
Questions? | ||
---------- | ||
If you have any questions, please feel free to ask on the | ||
[Developing jQuery Core forum](http://forum.jquery.com/developing-jquery-core) or in #jquery on irc.freenode.net. | ||
For source files and issues, visit the [jQuery repo](https://github.com/jquery/jquery). |
define([ | ||
"./core", | ||
"./var/document", | ||
"./var/rnotwhite", | ||
"./ajax/var/location", | ||
"./ajax/var/nonce", | ||
@@ -10,3 +12,3 @@ "./ajax/var/rquery", | ||
"./deferred" | ||
], function( jQuery, rnotwhite, nonce, rquery ) { | ||
], function( jQuery, document, rnotwhite, location, nonce, rquery ) { | ||
@@ -21,3 +23,2 @@ var | ||
rprotocol = /^\/\//, | ||
rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/, | ||
@@ -45,8 +46,6 @@ /* Prefilters | ||
// Document location | ||
ajaxLocation = window.location.href, | ||
// Anchor tag for parsing the document origin | ||
originAnchor = document.createElement( "a" ); | ||
originAnchor.href = location.href; | ||
// Segment location into parts | ||
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; | ||
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport | ||
@@ -95,3 +94,5 @@ function addToPrefiltersOrTransports( structure ) { | ||
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); | ||
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { | ||
if ( typeof dataTypeOrTransport === "string" && | ||
!seekingTransport && !inspected[ dataTypeOrTransport ] ) { | ||
options.dataTypes.unshift( dataTypeOrTransport ); | ||
@@ -269,3 +270,6 @@ inspect( dataTypeOrTransport ); | ||
} 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 | ||
}; | ||
} | ||
@@ -291,5 +295,5 @@ } | ||
ajaxSettings: { | ||
url: ajaxLocation, | ||
url: location.href, | ||
type: "GET", | ||
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), | ||
isLocal: rlocalProtocol.test( location.protocol ), | ||
global: true, | ||
@@ -394,4 +398,4 @@ processData: true, | ||
timeoutTimer, | ||
// Cross-domain detection vars | ||
parts, | ||
// Url cleanup var | ||
urlAnchor, | ||
// To know if global events are to be dispatched | ||
@@ -406,5 +410,6 @@ fireGlobals, | ||
// Context for global events is callbackContext if it is a DOM node or jQuery collection | ||
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? | ||
jQuery( callbackContext ) : | ||
jQuery.event, | ||
globalEventContext = s.context && | ||
( callbackContext.nodeType || callbackContext.jquery ) ? | ||
jQuery( callbackContext ) : | ||
jQuery.event, | ||
// Deferreds | ||
@@ -493,5 +498,3 @@ deferred = jQuery.Deferred(), | ||
// Attach deferreds | ||
deferred.promise( jqXHR ).complete = completeDeferred.add; | ||
jqXHR.success = jqXHR.done; | ||
jqXHR.error = jqXHR.fail; | ||
deferred.promise( jqXHR ); | ||
@@ -502,4 +505,4 @@ // Remove hash character (#7531: and string promotion) | ||
// We also use the url parameter if available | ||
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ) | ||
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); | ||
s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" ) | ||
.replace( rprotocol, location.protocol + "//" ); | ||
@@ -512,10 +515,20 @@ // Alias method option to type as per ticket #12004 | ||
// 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 ) { | ||
parts = rurl.exec( s.url.toLowerCase() ); | ||
s.crossDomain = !!( parts && | ||
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || | ||
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== | ||
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) | ||
); | ||
urlAnchor = document.createElement( "a" ); | ||
// Support: IE8-11+ | ||
// IE throws exception if url is malformed, e.g. http://example.com:80x/ | ||
try { | ||
urlAnchor.href = s.url; | ||
// Support: IE8-11+ | ||
// Anchor's host property isn't correctly set when s.url is relative | ||
urlAnchor.href = urlAnchor.href; | ||
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== | ||
urlAnchor.protocol + "//" + urlAnchor.host; | ||
} catch ( e ) { | ||
// If there is an error parsing the URL, assume it is crossDomain, | ||
// it can be rejected by the transport if it is invalid | ||
s.crossDomain = true; | ||
} | ||
} | ||
@@ -596,3 +609,4 @@ | ||
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[ "*" ] | ||
@@ -607,3 +621,5 @@ ); | ||
// 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 || state === 2 ) ) { | ||
// Abort if not done already and return | ||
@@ -617,5 +633,5 @@ return jqXHR.abort(); | ||
// Install callbacks on deferreds | ||
for ( i in { success: 1, error: 1, complete: 1 } ) { | ||
jqXHR[ i ]( s[ i ] ); | ||
} | ||
completeDeferred.add( s.complete ); | ||
jqXHR.done( s.success ); | ||
jqXHR.fail( s.error ); | ||
@@ -635,5 +651,11 @@ // Get transport | ||
} | ||
// If request was aborted inside ajaxSend, stop there | ||
if ( state === 2 ) { | ||
return jqXHR; | ||
} | ||
// Timeout | ||
if ( s.async && s.timeout > 0 ) { | ||
timeoutTimer = setTimeout(function() { | ||
timeoutTimer = window.setTimeout(function() { | ||
jqXHR.abort("timeout"); | ||
@@ -672,3 +694,3 @@ }, s.timeout ); | ||
if ( timeoutTimer ) { | ||
clearTimeout( timeoutTimer ); | ||
window.clearTimeout( timeoutTimer ); | ||
} | ||
@@ -791,3 +813,4 @@ | ||
return jQuery.ajax({ | ||
// The url can be an options object (which then must have .url) | ||
return jQuery.ajax( jQuery.extend({ | ||
url: url, | ||
@@ -798,3 +821,3 @@ type: method, | ||
success: callback | ||
}); | ||
}, jQuery.isPlainObject( url ) && url ) ); | ||
}; | ||
@@ -801,0 +824,0 @@ }); |
@@ -27,3 +27,6 @@ define([ | ||
"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" | ||
); | ||
@@ -65,5 +68,11 @@ | ||
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 | ||
@@ -70,0 +79,0 @@ if ( s[ callbackName ] ) { |
@@ -7,10 +7,5 @@ define([ | ||
"../manipulation", | ||
"../selector", | ||
// Optional event/alias dependency | ||
"../event/alias" | ||
"../selector" | ||
], function( jQuery ) { | ||
// Keep a copy of the old load method | ||
var _load = jQuery.fn.load; | ||
/** | ||
@@ -20,6 +15,2 @@ * Load a url into a page | ||
jQuery.fn.load = function( url, params, callback ) { | ||
if ( typeof url !== "string" && _load ) { | ||
return _load.apply( this, arguments ); | ||
} | ||
var selector, type, response, | ||
@@ -29,3 +20,3 @@ self = this, | ||
if ( off >= 0 ) { | ||
if ( off > -1 ) { | ||
selector = jQuery.trim( url.slice( off ) ); | ||
@@ -52,4 +43,6 @@ url = url.slice( 0, off ); | ||
// if "type" variable is undefined, then "GET" method will be used | ||
type: type, | ||
// If "type" variable is undefined, then "GET" method will be used. | ||
// Make value of this field explicit since | ||
// user can override it through ajaxSetup method | ||
type: type || "GET", | ||
dataType: "html", | ||
@@ -71,4 +64,9 @@ data: params | ||
}).complete( callback && function( jqXHR, status ) { | ||
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); | ||
// If the request succeeds, this function gets "data", "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( self, response || [ jqXHR.responseText, status, jqXHR ] ); | ||
}); | ||
}); | ||
@@ -75,0 +73,0 @@ } |
@@ -7,3 +7,3 @@ define([ | ||
jQuery.parseXML = function( data ) { | ||
var xml, tmp; | ||
var xml; | ||
if ( !data || typeof data !== "string" ) { | ||
@@ -15,4 +15,3 @@ return null; | ||
try { | ||
tmp = new DOMParser(); | ||
xml = tmp.parseFromString( data, "text/xml" ); | ||
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); | ||
} catch ( e ) { | ||
@@ -19,0 +18,0 @@ xml = undefined; |
define([ | ||
"../core", | ||
"../var/document", | ||
"../ajax" | ||
], function( jQuery ) { | ||
], function( jQuery, document ) { | ||
@@ -9,3 +10,4 @@ // Install script dataType | ||
accepts: { | ||
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" | ||
script: "text/javascript, application/javascript, " + | ||
"application/ecmascript, application/x-ecmascript" | ||
}, | ||
@@ -41,3 +43,2 @@ contents: { | ||
script = jQuery("<script>").prop({ | ||
async: true, | ||
charset: s.scriptCharset, | ||
@@ -55,2 +56,4 @@ src: s.url | ||
); | ||
// Use native DOM manipulation to avoid our domManip AJAX trickery | ||
document.head.appendChild( script[ 0 ] ); | ||
@@ -57,0 +60,0 @@ }, |
@@ -9,9 +9,7 @@ define([ | ||
try { | ||
return new XMLHttpRequest(); | ||
} catch( e ) {} | ||
return new window.XMLHttpRequest(); | ||
} catch ( e ) {} | ||
}; | ||
var xhrId = 0, | ||
xhrCallbacks = {}, | ||
xhrSuccessStatus = { | ||
var xhrSuccessStatus = { | ||
// file protocol always yields status code 0, assume 200 | ||
@@ -25,13 +23,2 @@ 0: 200, | ||
// 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 ); | ||
@@ -48,6 +35,11 @@ support.ajax = xhrSupported = !!xhrSupported; | ||
var i, | ||
xhr = options.xhr(), | ||
id = ++xhrId; | ||
xhr = options.xhr(); | ||
xhr.open( options.type, options.url, options.async, options.username, options.password ); | ||
xhr.open( | ||
options.type, | ||
options.url, | ||
options.async, | ||
options.username, | ||
options.password | ||
); | ||
@@ -84,3 +76,2 @@ // Apply custom fields if provided | ||
if ( callback ) { | ||
delete xhrCallbacks[ id ]; | ||
callback = xhr.onload = xhr.onerror = null; | ||
@@ -118,3 +109,3 @@ | ||
// Create the abort callback | ||
callback = xhrCallbacks[ id ] = callback("abort"); | ||
callback = callback("abort"); | ||
@@ -121,0 +112,0 @@ try { |
define([ | ||
"../core", | ||
"../var/rnotwhite", | ||
"../var/strundefined", | ||
"../core/access", | ||
"./support", | ||
"../var/rnotwhite", | ||
"../selector" | ||
], function( jQuery, rnotwhite, strundefined, access, support ) { | ||
], function( jQuery, access, support, rnotwhite ) { | ||
var nodeHook, boolHook, | ||
var boolHook, | ||
attrHandle = jQuery.expr.attrHandle; | ||
@@ -27,7 +26,7 @@ | ||
attr: function( elem, name, value ) { | ||
var hooks, ret, | ||
var ret, hooks, | ||
nType = elem.nodeType; | ||
// don't get/set attributes on text, comment and attribute nodes | ||
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | ||
// Don't get/set attributes on text, comment and attribute nodes | ||
if ( nType === 3 || nType === 8 || nType === 2 ) { | ||
return; | ||
@@ -37,3 +36,3 @@ } | ||
// Fallback to prop when attributes are not supported | ||
if ( typeof elem.getAttribute === strundefined ) { | ||
if ( typeof elem.getAttribute === "undefined" ) { | ||
return jQuery.prop( elem, name, value ); | ||
@@ -47,28 +46,43 @@ } | ||
hooks = jQuery.attrHooks[ name ] || | ||
( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); | ||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); | ||
} | ||
if ( value !== undefined ) { | ||
if ( value === null ) { | ||
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; | ||
} 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; | ||
} | ||
} else { | ||
ret = jQuery.find.attr( elem, name ); | ||
ret = jQuery.find.attr( elem, name ); | ||
// Non-existent attributes return null, we normalize to undefined | ||
return ret == null ? | ||
undefined : | ||
ret; | ||
// Non-existent attributes return null, we normalize to undefined | ||
return ret == null ? undefined : ret; | ||
}, | ||
attrHooks: { | ||
type: { | ||
set: function( elem, value ) { | ||
if ( !support.radioValue && value === "radio" && | ||
jQuery.nodeName( elem, "input" ) ) { | ||
var val = elem.value; | ||
elem.setAttribute( "type", value ); | ||
if ( val ) { | ||
elem.value = val; | ||
} | ||
return value; | ||
} | ||
} | ||
} | ||
@@ -83,3 +97,3 @@ }, | ||
if ( attrNames && elem.nodeType === 1 ) { | ||
while ( (name = attrNames[i++]) ) { | ||
while ( ( name = attrNames[i++] ) ) { | ||
propName = jQuery.propFix[ name ] || name; | ||
@@ -89,2 +103,3 @@ | ||
if ( jQuery.expr.match.bool.test( name ) ) { | ||
// Set corresponding property to false | ||
@@ -97,18 +112,2 @@ elem[ propName ] = false; | ||
} | ||
}, | ||
attrHooks: { | ||
type: { | ||
set: function( elem, value ) { | ||
if ( !support.radioValue && value === "radio" && | ||
jQuery.nodeName( elem, "input" ) ) { | ||
var val = elem.value; | ||
elem.setAttribute( "type", value ); | ||
if ( val ) { | ||
elem.value = val; | ||
} | ||
return value; | ||
} | ||
} | ||
} | ||
} | ||
@@ -115,0 +114,0 @@ }); |
define([ | ||
"../core", | ||
"../var/rnotwhite", | ||
"../var/strundefined", | ||
"../data/var/data_priv", | ||
"../data/var/dataPriv", | ||
"../core/init" | ||
], function( jQuery, rnotwhite, strundefined, data_priv ) { | ||
], function( jQuery, rnotwhite, dataPriv ) { | ||
var rclass = /[\t\r\n\f]/g; | ||
function getClass( elem ) { | ||
return elem.getAttribute && elem.getAttribute( "class" ) || ""; | ||
} | ||
jQuery.fn.extend({ | ||
addClass: function( value ) { | ||
var classes, elem, cur, clazz, j, finalValue, | ||
var classes, elem, cur, curValue, clazz, j, finalValue, | ||
proceed = typeof value === "string" && value, | ||
@@ -20,3 +23,3 @@ i = 0, | ||
return this.each(function( j ) { | ||
jQuery( this ).addClass( value.call( this, j, this.className ) ); | ||
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); | ||
}); | ||
@@ -31,6 +34,5 @@ } | ||
elem = this[ i ]; | ||
cur = elem.nodeType === 1 && ( elem.className ? | ||
( " " + elem.className + " " ).replace( rclass, " " ) : | ||
" " | ||
); | ||
curValue = getClass( elem ); | ||
cur = elem.nodeType === 1 && | ||
( " " + curValue + " " ).replace( rclass, " " ); | ||
@@ -47,4 +49,4 @@ if ( cur ) { | ||
finalValue = jQuery.trim( cur ); | ||
if ( elem.className !== finalValue ) { | ||
elem.className = finalValue; | ||
if ( curValue !== finalValue ) { | ||
elem.setAttribute( "class", finalValue ); | ||
} | ||
@@ -59,3 +61,3 @@ } | ||
removeClass: function( value ) { | ||
var classes, elem, cur, clazz, j, finalValue, | ||
var classes, elem, cur, curValue, clazz, j, finalValue, | ||
proceed = arguments.length === 0 || typeof value === "string" && value, | ||
@@ -67,3 +69,3 @@ i = 0, | ||
return this.each(function( j ) { | ||
jQuery( this ).removeClass( value.call( this, j, this.className ) ); | ||
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); | ||
}); | ||
@@ -76,7 +78,7 @@ } | ||
elem = this[ i ]; | ||
curValue = getClass( elem ); | ||
// This expression is here for better compressibility (see addClass) | ||
cur = elem.nodeType === 1 && ( elem.className ? | ||
( " " + elem.className + " " ).replace( rclass, " " ) : | ||
"" | ||
); | ||
cur = elem.nodeType === 1 && | ||
( " " + curValue + " " ).replace( rclass, " " ); | ||
@@ -87,3 +89,3 @@ if ( cur ) { | ||
// Remove *all* instances | ||
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { | ||
while ( cur.indexOf( " " + clazz + " " ) > -1 ) { | ||
cur = cur.replace( " " + clazz + " ", " " ); | ||
@@ -95,4 +97,4 @@ } | ||
finalValue = value ? jQuery.trim( cur ) : ""; | ||
if ( elem.className !== finalValue ) { | ||
elem.className = finalValue; | ||
if ( curValue !== finalValue ) { | ||
elem.setAttribute( "class", finalValue ); | ||
} | ||
@@ -115,3 +117,6 @@ } | ||
return this.each(function( i ) { | ||
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); | ||
jQuery( this ).toggleClass( | ||
value.call( this, i, getClass( this ), stateVal ), | ||
stateVal | ||
); | ||
}); | ||
@@ -121,10 +126,13 @@ } | ||
return this.each(function() { | ||
var className, i, self, classNames; | ||
if ( type === "string" ) { | ||
// Toggle individual class names | ||
var className, | ||
i = 0, | ||
self = jQuery( this ), | ||
classNames = value.match( rnotwhite ) || []; | ||
i = 0; | ||
self = jQuery( this ); | ||
classNames = value.match( rnotwhite ) || []; | ||
while ( (className = classNames[ i++ ]) ) { | ||
while ( ( className = classNames[ i++ ] ) ) { | ||
// Check each className given, space separated list | ||
@@ -139,6 +147,8 @@ if ( self.hasClass( className ) ) { | ||
// Toggle whole class name | ||
} else if ( type === strundefined || type === "boolean" ) { | ||
if ( this.className ) { | ||
} else if ( value === undefined || type === "boolean" ) { | ||
className = getClass( this ); | ||
if ( className ) { | ||
// store className if set | ||
data_priv.set( this, "__className__", this.className ); | ||
dataPriv.set( this, "__className__", className ); | ||
} | ||
@@ -150,3 +160,9 @@ | ||
// 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__" ) || "" | ||
); | ||
} | ||
} | ||
@@ -161,3 +177,6 @@ }); | ||
for ( ; i < l; i++ ) { | ||
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { | ||
if ( this[i].nodeType === 1 && | ||
( " " + getClass( this[i] ) + " " ).replace( rclass, " " ) | ||
.indexOf( className ) > -1 | ||
) { | ||
return true; | ||
@@ -164,0 +183,0 @@ } |
define([ | ||
"../core", | ||
"../core/access", | ||
"./support" | ||
"./support", | ||
"../selector" | ||
], function( jQuery, access, support ) { | ||
@@ -22,19 +23,13 @@ | ||
jQuery.extend({ | ||
propFix: { | ||
"for": "htmlFor", | ||
"class": "className" | ||
}, | ||
prop: function( elem, name, value ) { | ||
var ret, hooks, notxml, | ||
var ret, hooks, | ||
nType = elem.nodeType; | ||
// 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; | ||
} | ||
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); | ||
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { | ||
if ( notxml ) { | ||
// Fix name and attach hooks | ||
@@ -46,11 +41,15 @@ name = jQuery.propFix[ name ] || name; | ||
if ( value !== undefined ) { | ||
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? | ||
ret : | ||
( elem[ name ] = value ); | ||
if ( hooks && "set" in hooks && | ||
( ret = hooks.set( elem, value, name ) ) !== undefined ) { | ||
return ret; | ||
} | ||
} else { | ||
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? | ||
ret : | ||
elem[ name ]; | ||
return ( elem[ name ] = value ); | ||
} | ||
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { | ||
return ret; | ||
} | ||
return elem[ name ]; | ||
}, | ||
@@ -61,7 +60,13 @@ | ||
get: function( elem ) { | ||
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? | ||
elem.tabIndex : | ||
-1; | ||
return elem.hasAttribute( "tabindex" ) || | ||
rfocusable.test( elem.nodeName ) || elem.href ? | ||
elem.tabIndex : | ||
-1; | ||
} | ||
} | ||
}, | ||
propFix: { | ||
"for": "htmlFor", | ||
"class": "className" | ||
} | ||
@@ -68,0 +73,0 @@ }); |
define([ | ||
"../var/document", | ||
"../var/support" | ||
], function( support ) { | ||
], function( document, support ) { | ||
@@ -12,3 +13,3 @@ (function() { | ||
// Support: iOS<=5.1, Android<=4.2+ | ||
// Support: Android<4.4 | ||
// Default value for a checkbox should be "on" | ||
@@ -15,0 +16,0 @@ support.checkOn = input.value !== ""; |
@@ -16,3 +16,4 @@ define([ | ||
if ( elem ) { | ||
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; | ||
hooks = jQuery.valHooks[ elem.type ] || | ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ]; | ||
@@ -77,8 +78,5 @@ if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { | ||
get: function( elem ) { | ||
var val = jQuery.find.attr( elem, "value" ); | ||
return val != null ? | ||
val : | ||
// Support: IE10-11+ | ||
// option.text throws exceptions (#14686, #14858) | ||
jQuery.trim( jQuery.text( elem ) ); | ||
// Support: IE<11 | ||
// option.value not trimmed (#14858) | ||
return jQuery.trim( elem.value ); | ||
} | ||
@@ -102,7 +100,9 @@ }, | ||
// IE6-9 doesn't update selected after form reset (#2551) | ||
// IE8-9 doesn't update selected after form reset (#2551) | ||
if ( ( option.selected || i === index ) && | ||
// Don't return options that are disabled or in a disabled optgroup | ||
( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && | ||
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { | ||
( support.optDisabled ? | ||
!option.disabled : option.getAttribute( "disabled" ) === null ) && | ||
( !option.parentNode.disabled || | ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { | ||
@@ -133,3 +133,4 @@ // Get the specific value for the option | ||
option = options[ i ]; | ||
if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { | ||
if ( (option.selected = | ||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1) ) { | ||
optionSet = true; | ||
@@ -154,3 +155,3 @@ } | ||
if ( jQuery.isArray( value ) ) { | ||
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); | ||
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) > -1 ); | ||
} | ||
@@ -157,0 +158,0 @@ } |
@@ -6,8 +6,5 @@ define([ | ||
// String to Object options format cache | ||
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 ) { | ||
var object = optionsCache[ options ] = {}; | ||
var object = {}; | ||
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { | ||
@@ -46,63 +43,84 @@ object[ flag ] = true; | ||
options = typeof options === "string" ? | ||
( optionsCache[ options ] || createOptions( options ) ) : | ||
createOptions( 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, | ||
// Flag to know if list was already fired | ||
fired, | ||
// Flag to know if list is currently firing | ||
firing, | ||
// First callback to fire (used internally by add and fireWith) | ||
firingStart, | ||
// End of the loop when firing | ||
firingLength, | ||
// Index of currently firing callback (modified by remove if needed) | ||
firingIndex, | ||
// Flag to prevent firing | ||
locked, | ||
// Actual callback 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 = function( data ) { | ||
memory = options.memory && data; | ||
fired = true; | ||
firingIndex = firingStart || 0; | ||
firingStart = 0; | ||
firingLength = list.length; | ||
firing = true; | ||
for ( ; list && firingIndex < firingLength; firingIndex++ ) { | ||
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { | ||
memory = false; // To prevent further calls using add | ||
break; | ||
fire = function() { | ||
// Enforce single-firing | ||
locked = options.once; | ||
// Execute callbacks for all pending executions, | ||
// respecting firingIndex overrides and runtime changes | ||
fired = firing = true; | ||
for ( ; queue.length; firingIndex = -1 ) { | ||
memory = queue.shift(); | ||
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; | ||
if ( list ) { | ||
if ( stack ) { | ||
if ( stack.length ) { | ||
fire( stack.shift() ); | ||
} | ||
} else if ( memory ) { | ||
// Clean up if we're done firing for good | ||
if ( locked ) { | ||
// Keep an empty list if we have data for future add calls | ||
if ( memory ) { | ||
list = []; | ||
// Otherwise, this object is spent | ||
} else { | ||
self.disable(); | ||
list = ""; | ||
} | ||
} | ||
}, | ||
// Actual Callbacks object | ||
self = { | ||
// Add a callback or a collection of callbacks to the list | ||
add: function() { | ||
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 | ||
if ( memory && !firing ) { | ||
firingIndex = list.length - 1; | ||
queue.push( memory ); | ||
} | ||
(function add( args ) { | ||
jQuery.each( args, function( _, arg ) { | ||
var type = jQuery.type( arg ); | ||
if ( type === "function" ) { | ||
if ( jQuery.isFunction( arg ) ) { | ||
if ( !options.unique || !self.has( arg ) ) { | ||
list.push( arg ); | ||
} | ||
} else if ( arg && arg.length && type !== "string" ) { | ||
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { | ||
// Inspect recursively | ||
@@ -113,11 +131,5 @@ add( arg ); | ||
})( arguments ); | ||
// Do we need to add the callbacks to the | ||
// current firing batch? | ||
if ( firing ) { | ||
firingLength = list.length; | ||
// With memory, if we're not firing then | ||
// we should call right away | ||
} else if ( memory ) { | ||
firingStart = start; | ||
fire( memory ); | ||
if ( memory && !firing ) { | ||
fire(); | ||
} | ||
@@ -127,64 +139,69 @@ } | ||
}, | ||
// Remove a callback from the list | ||
remove: function() { | ||
if ( list ) { | ||
jQuery.each( arguments, function( _, arg ) { | ||
var index; | ||
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | ||
list.splice( index, 1 ); | ||
// Handle firing indexes | ||
if ( firing ) { | ||
if ( index <= firingLength ) { | ||
firingLength--; | ||
} | ||
if ( index <= firingIndex ) { | ||
firingIndex--; | ||
} | ||
} | ||
jQuery.each( arguments, function( _, arg ) { | ||
var index; | ||
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { | ||
list.splice( index, 1 ); | ||
// Handle firing indexes | ||
if ( index <= firingIndex ) { | ||
firingIndex--; | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
return this; | ||
}, | ||
// Check if a given callback is in the list. | ||
// If no argument is given, return whether or not list has callbacks attached. | ||
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 | ||
empty: function() { | ||
list = []; | ||
firingLength = 0; | ||
if ( list ) { | ||
list = []; | ||
} | ||
return this; | ||
}, | ||
// Have the list do nothing anymore | ||
// Disable .fire and .add | ||
// Abort any current/pending executions | ||
// Clear all callbacks and values | ||
disable: function() { | ||
list = stack = memory = undefined; | ||
locked = queue = []; | ||
list = memory = ""; | ||
return this; | ||
}, | ||
// Is it disabled? | ||
disabled: function() { | ||
return !list; | ||
}, | ||
// Lock the list in its current state | ||
// Disable .fire | ||
// Also disable .add unless we have memory (since it would have no effect) | ||
// Abort any pending executions | ||
lock: function() { | ||
stack = undefined; | ||
if ( !memory ) { | ||
self.disable(); | ||
locked = queue = []; | ||
if ( !memory && !firing ) { | ||
list = memory = ""; | ||
} | ||
return this; | ||
}, | ||
// Is it locked? | ||
locked: function() { | ||
return !stack; | ||
return !!locked; | ||
}, | ||
// Call all callbacks with the given context and arguments | ||
fireWith: function( context, args ) { | ||
if ( list && ( !fired || stack ) ) { | ||
if ( !locked ) { | ||
args = args || []; | ||
args = [ context, args.slice ? args.slice() : args ]; | ||
if ( firing ) { | ||
stack.push( args ); | ||
} else { | ||
fire( args ); | ||
queue.push( args ); | ||
if ( !firing ) { | ||
fire(); | ||
} | ||
@@ -194,2 +211,3 @@ } | ||
}, | ||
// Call all the callbacks with the given arguments | ||
@@ -200,2 +218,3 @@ fire: function() { | ||
}, | ||
// To know if the callbacks have already been called at least once | ||
@@ -202,0 +221,0 @@ fired: function() { |
110
src/core.js
define([ | ||
"./var/arr", | ||
"./var/document", | ||
"./var/slice", | ||
@@ -11,8 +12,5 @@ "./var/concat", | ||
"./var/support" | ||
], function( arr, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { | ||
], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { | ||
var | ||
// Use the correct document accordingly with window argument (sandbox) | ||
document = window.document, | ||
version = "@VERSION", | ||
@@ -33,3 +31,3 @@ | ||
rmsPrefix = /^-ms-/, | ||
rdashAlpha = /-([\da-z])/gi, | ||
rdashAlpha = /-([a-z])/g, | ||
@@ -47,5 +45,2 @@ // Used by jQuery.camelCase as callback to replace() | ||
// Start with an empty selector | ||
selector: "", | ||
// The default length of a jQuery object is 0 | ||
@@ -79,3 +74,2 @@ length: 0, | ||
ret.prevObject = this; | ||
ret.context = this.context; | ||
@@ -87,6 +81,4 @@ // Return the newly-formed element set | ||
// Execute a callback for every element in the matched set. | ||
// (You can seed the arguments with an array of args, but this is | ||
// only used internally.) | ||
each: function( callback, args ) { | ||
return jQuery.each( this, callback, args ); | ||
each: function( callback ) { | ||
return jQuery.each( this, callback ); | ||
}, | ||
@@ -170,3 +162,5 @@ | ||
// 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) || | ||
(copyIsArray = jQuery.isArray(copy)) ) ) { | ||
if ( copyIsArray ) { | ||
@@ -257,3 +251,3 @@ copyIsArray = false; | ||
} | ||
// Support: Android<4.0, iOS<6 (functionish RegExp) | ||
// Support: Android<4.0 (functionish RegExp) | ||
return typeof obj === "object" || typeof obj === "function" ? | ||
@@ -266,21 +260,6 @@ class2type[ toString.call(obj) ] || "object" : | ||
globalEval: function( code ) { | ||
var script, | ||
indirect = eval; | ||
var script = document.createElement( "script" ); | ||
code = jQuery.trim( code ); | ||
if ( code ) { | ||
// If the code includes a valid, prologue position | ||
// strict mode pragma, execute code by injecting a | ||
// script tag into the document. | ||
if ( code.indexOf("use strict") === 1 ) { | ||
script = document.createElement("script"); | ||
script.text = code; | ||
document.head.appendChild( script ).parentNode.removeChild( script ); | ||
} else { | ||
// Otherwise, avoid the DOM node creation, insertion | ||
// and removal by using an indirect global eval | ||
indirect( code ); | ||
} | ||
} | ||
script.text = code; | ||
document.head.appendChild( script ).parentNode.removeChild( script ); | ||
}, | ||
@@ -299,46 +278,18 @@ | ||
// args is for internal usage only | ||
each: function( obj, callback, args ) { | ||
var value, | ||
i = 0, | ||
each: function( obj, callback ) { | ||
var 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; | ||
} | ||
if ( isArray ) { | ||
for ( ; i < length; i++ ) { | ||
if ( callback.call( obj[ i ], i, obj[ i ] ) === 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 { | ||
if ( isArray ) { | ||
for ( ; i < length; i++ ) { | ||
value = callback.call( obj[ i ], i, obj[ i ] ); | ||
if ( value === false ) { | ||
break; | ||
} | ||
for ( i in obj ) { | ||
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { | ||
break; | ||
} | ||
} else { | ||
for ( i in obj ) { | ||
value = callback.call( obj[ i ], i, obj[ i ] ); | ||
if ( value === false ) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -379,2 +330,4 @@ } | ||
// Support: Android<4.1, PhantomJS<2 | ||
// push.apply(_, arraylike) throws on ancient WebKit | ||
merge: function( first, second ) { | ||
@@ -485,4 +438,15 @@ var len = +second.length, | ||
// JSHint would error on this code due to the Symbol not being defined in ES5. | ||
// Defining this global in .jshintrc would create a danger of using the global | ||
// unguarded in another place, it seems safer to just disable JSHint for these | ||
// three lines. | ||
/* jshint ignore: start */ | ||
if ( typeof Symbol === "function" ) { | ||
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; | ||
} | ||
/* jshint ignore: end */ | ||
// 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".split(" "), | ||
function(i, name) { | ||
class2type[ "[object " + name + "]" ] = name.toLowerCase(); | ||
@@ -504,6 +468,2 @@ }); | ||
if ( obj.nodeType === 1 && length ) { | ||
return true; | ||
} | ||
return type === "array" || length === 0 || | ||
@@ -510,0 +470,0 @@ typeof length === "number" && length > 0 && ( length - 1 ) in obj; |
@@ -16,3 +16,3 @@ define([ | ||
for ( i in key ) { | ||
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); | ||
access( elems, fn, i, key[i], true, emptyGet, raw ); | ||
} | ||
@@ -19,0 +19,0 @@ |
// Initialize a jQuery object | ||
define([ | ||
"../core", | ||
"../var/document", | ||
"./var/rsingleTag", | ||
"../traversing/findFilter" | ||
], function( jQuery, rsingleTag ) { | ||
], function( jQuery, document, rsingleTag ) { | ||
@@ -14,5 +15,6 @@ // A central reference to the root jQuery(document) | ||
// Strict HTML recognition (#11290: must start with <) | ||
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, | ||
// Shortcut simple #id case for speed | ||
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, | ||
init = jQuery.fn.init = function( selector, context ) { | ||
init = jQuery.fn.init = function( selector, context, root ) { | ||
var match, elem; | ||
@@ -25,5 +27,12 @@ | ||
// init accepts an alternate rootjQuery | ||
// so migrate can support jQuery.sub (gh-2101) | ||
root = root || rootjQuery; | ||
// Handle HTML strings | ||
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 | ||
@@ -71,12 +80,7 @@ match = [ null, selector, null ]; | ||
// Support: Blackberry 4.6 | ||
// gEBID returns nodes no longer in the document (#6963) | ||
if ( elem && elem.parentNode ) { | ||
if ( elem ) { | ||
// Inject the element directly into the jQuery object | ||
this[0] = elem; | ||
this.length = 1; | ||
this[0] = elem; | ||
} | ||
this.context = document; | ||
this.selector = selector; | ||
return this; | ||
@@ -87,3 +91,3 @@ } | ||
} else if ( !context || context.jquery ) { | ||
return ( context || rootjQuery ).find( selector ); | ||
return ( context || root ).find( selector ); | ||
@@ -98,3 +102,3 @@ // HANDLE: $(expr, context) | ||
} else if ( selector.nodeType ) { | ||
this.context = this[0] = selector; | ||
this[0] = selector; | ||
this.length = 1; | ||
@@ -106,4 +110,4 @@ return this; | ||
} else if ( jQuery.isFunction( selector ) ) { | ||
return typeof rootjQuery.ready !== "undefined" ? | ||
rootjQuery.ready( selector ) : | ||
return root.ready !== undefined ? | ||
root.ready( selector ) : | ||
// Execute immediately if ready is not present | ||
@@ -113,7 +117,2 @@ selector( jQuery ); | ||
if ( selector.selector !== undefined ) { | ||
this.selector = selector.selector; | ||
this.context = selector.context; | ||
} | ||
return jQuery.makeArray( selector, this ); | ||
@@ -120,0 +119,0 @@ }; |
define([ | ||
"../core", | ||
"../var/document", | ||
"./var/rsingleTag", | ||
"../manipulation" // buildFragment | ||
], function( jQuery, rsingleTag ) { | ||
"../manipulation/buildFragment", | ||
// This is the only module that needs core/support | ||
"./support" | ||
], function( jQuery, document, rsingleTag, buildFragment, support ) { | ||
// data: string of html | ||
// context (optional): If specified, the fragment will be created in this context, defaults to document | ||
// 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 | ||
jQuery.parseHTML = function( data, context, keepScripts ) { | ||
if ( !data || typeof data !== "string" ) { | ||
return null; | ||
if ( typeof data !== "string" ) { | ||
return []; | ||
} | ||
@@ -18,3 +23,7 @@ if ( typeof context === "boolean" ) { | ||
} | ||
context = context || document; | ||
// document.implementation stops scripts or inline event handlers from | ||
// being executed immediately | ||
context = context || ( support.createHTMLDocument ? | ||
document.implementation.createHTMLDocument( "" ) : | ||
document ); | ||
@@ -29,3 +38,3 @@ var parsed = rsingleTag.exec( data ), | ||
parsed = jQuery.buildFragment( [ data ], context, scripts ); | ||
parsed = buildFragment( [ data ], context, scripts ); | ||
@@ -32,0 +41,0 @@ if ( scripts && scripts.length ) { |
define([ | ||
"../core", | ||
"../core/init", | ||
"../var/document", | ||
"../deferred" | ||
], function( jQuery ) { | ||
], function( jQuery, document ) { | ||
@@ -52,8 +52,2 @@ // The deferred used on DOM ready | ||
readyList.resolveWith( document, [ jQuery ] ); | ||
// Trigger any bound ready events | ||
if ( jQuery.fn.triggerHandler ) { | ||
jQuery( document ).triggerHandler( "ready" ); | ||
jQuery( document ).off( "ready" ); | ||
} | ||
} | ||
@@ -66,4 +60,4 @@ }); | ||
function completed() { | ||
document.removeEventListener( "DOMContentLoaded", completed, false ); | ||
window.removeEventListener( "load", completed, false ); | ||
document.removeEventListener( "DOMContentLoaded", completed ); | ||
window.removeEventListener( "load", completed ); | ||
jQuery.ready(); | ||
@@ -77,8 +71,10 @@ } | ||
// Catch cases where $(document).ready() is called after the browser event has already occurred. | ||
// We once tried to use readyState "interactive" here, but it caused issues like the one | ||
// Catch cases where $(document).ready() is called | ||
// after the browser event has already occurred. | ||
// 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 ); | ||
window.setTimeout( jQuery.ready ); | ||
@@ -88,6 +84,6 @@ } else { | ||
// Use the handy event callback | ||
document.addEventListener( "DOMContentLoaded", completed, false ); | ||
document.addEventListener( "DOMContentLoaded", completed ); | ||
// A fallback to window.onload, that will always work | ||
window.addEventListener( "load", completed, false ); | ||
window.addEventListener( "load", completed ); | ||
} | ||
@@ -94,0 +90,0 @@ } |
define(function() { | ||
// Match a standalone tag | ||
return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); | ||
return (/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/); | ||
}); |
140
src/css.js
@@ -6,2 +6,4 @@ define([ | ||
"./css/var/rmargin", | ||
"./var/document", | ||
"./var/rcssNum", | ||
"./css/var/rnumnonpx", | ||
@@ -11,21 +13,21 @@ "./css/var/cssExpand", | ||
"./css/var/getStyles", | ||
"./css/var/swap", | ||
"./css/curCSS", | ||
"./css/defaultDisplay", | ||
"./css/adjustCSS", | ||
"./css/addGetHookIf", | ||
"./css/support", | ||
"./data/var/data_priv", | ||
"./css/showHide", | ||
"./core/init", | ||
"./css/swap", | ||
"./core/ready", | ||
"./selector" // contains | ||
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden, | ||
getStyles, curCSS, defaultDisplay, addGetHookIf, support, data_priv ) { | ||
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, | ||
isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) { | ||
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 | ||
rdisplayswap = /^(none|table(?!-c[ea]).+)/, | ||
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), | ||
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), | ||
@@ -38,9 +40,10 @@ cssShow = { position: "absolute", visibility: "hidden", display: "block" }, | ||
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; | ||
cssPrefixes = [ "Webkit", "Moz", "ms" ], | ||
emptyStyle = document.createElement( "div" ).style; | ||
// Return a css property mapped to a potentially vendor prefixed property | ||
function vendorPropName( style, name ) { | ||
function vendorPropName( name ) { | ||
// Shortcut for names that are not vendor prefixed | ||
if ( name in style ) { | ||
if ( name in emptyStyle ) { | ||
return name; | ||
@@ -51,3 +54,2 @@ } | ||
var capName = name[0].toUpperCase() + name.slice(1), | ||
origName = name, | ||
i = cssPrefixes.length; | ||
@@ -57,8 +59,6 @@ | ||
name = cssPrefixes[ i ] + capName; | ||
if ( name in style ) { | ||
if ( name in emptyStyle ) { | ||
return name; | ||
} | ||
} | ||
return origName; | ||
} | ||
@@ -116,7 +116,21 @@ | ||
// Start with offset property, which is equivalent to the border-box value | ||
var valueIsBorderBox = true, | ||
val = name === "width" ? elem.offsetWidth : elem.offsetHeight, | ||
var val, | ||
valueIsBorderBox = true, | ||
styles = getStyles( elem ), | ||
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; | ||
// Support: IE <= 11 only | ||
// Running getBoundingClientRect on a disconnected node | ||
// in IE throws an error. | ||
if ( elem.getClientRects().length ) { | ||
val = elem.getBoundingClientRect()[ name ]; | ||
} | ||
// Support: IE11 only | ||
// In IE 11 fullscreen elements inside of an iframe have | ||
// 100x too small dimensions (gh-1764). | ||
if ( document.msFullscreenElement && window.top !== window ) { | ||
val *= 100; | ||
} | ||
// Some non-html elements return undefined for offsetWidth, so check for null/undefined | ||
@@ -158,53 +172,2 @@ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 | ||
function showHide( elements, show ) { | ||
var display, elem, hidden, | ||
values = [], | ||
index = 0, | ||
length = elements.length; | ||
for ( ; index < length; index++ ) { | ||
elem = elements[ index ]; | ||
if ( !elem.style ) { | ||
continue; | ||
} | ||
values[ index ] = 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({ | ||
@@ -262,3 +225,4 @@ | ||
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); | ||
name = jQuery.cssProps[ origName ] || | ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); | ||
@@ -273,4 +237,4 @@ // Gets hook for the prefixed version, then unprefixed version | ||
// Convert "+=" or "-=" to relative numbers (#7345) | ||
if ( type === "string" && (ret = rrelNum.exec( value )) ) { | ||
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); | ||
if ( type === "string" && (ret = rcssNum.exec( value )) && ret[ 1 ] ) { | ||
value = adjustCSS( elem, name, ret ); | ||
// Fixes bug #9237 | ||
@@ -285,5 +249,5 @@ type = "number"; | ||
// If a number, add 'px' to the (except for certain CSS properties) | ||
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { | ||
value += "px"; | ||
// If a number was passed in, add the unit (except for certain CSS properties) | ||
if ( type === "number" ) { | ||
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); | ||
} | ||
@@ -298,3 +262,5 @@ | ||
// 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) || | ||
(value = hooks.set( elem, value, extra )) !== undefined ) { | ||
style[ name ] = value; | ||
@@ -305,3 +271,5 @@ } | ||
// 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; | ||
@@ -320,3 +288,4 @@ } | ||
// Make sure that we're working with the right name | ||
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); | ||
name = jQuery.cssProps[ origName ] || | ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); | ||
@@ -357,7 +326,14 @@ // Try prefixed name followed by the unprefixed name | ||
// but it must have a current display style that would benefit | ||
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? | ||
jQuery.swap( elem, cssShow, function() { | ||
return getWidthOrHeight( elem, name, extra ); | ||
}) : | ||
getWidthOrHeight( elem, name, extra ); | ||
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && | ||
// Support: Safari 8+ | ||
// Table columns in Safari have non-zero offsetWidth & zero | ||
// getBoundingClientRect().width unless display is changed. | ||
// Support: IE <= 11 only | ||
// Running getBoundingClientRect on a disconnected node | ||
// in IE throws an error. | ||
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? | ||
swap( elem, cssShow, function() { | ||
return getWidthOrHeight( elem, name, extra ); | ||
}) : | ||
getWidthOrHeight( elem, name, extra ); | ||
} | ||
@@ -385,3 +361,3 @@ }, | ||
if ( computed ) { | ||
return jQuery.swap( elem, { "display": "inline-block" }, | ||
return swap( elem, { "display": "inline-block" }, | ||
curCSS, [ elem, "marginRight" ] ); | ||
@@ -388,0 +364,0 @@ } |
@@ -6,4 +6,5 @@ define([ | ||
"./var/getStyles", | ||
"./support", | ||
"../selector" // contains | ||
], function( jQuery, rnumnonpx, rmargin, getStyles ) { | ||
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) { | ||
@@ -20,6 +21,3 @@ function curCSS( elem, name, computed ) { | ||
ret = computed.getPropertyValue( name ) || computed[ name ]; | ||
} | ||
if ( computed ) { | ||
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { | ||
@@ -29,7 +27,8 @@ ret = jQuery.style( elem, name ); | ||
// Support: iOS < 6 | ||
// 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 | ||
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values | ||
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { | ||
// Android Browser returns percentage for some values, | ||
// but width seems to be reliably pixels. | ||
// This is against the CSSOM draft spec: | ||
// http://dev.w3.org/csswg/cssom/#resolved-values | ||
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { | ||
@@ -53,3 +52,3 @@ // Remember the original values | ||
return ret !== undefined ? | ||
// Support: IE | ||
// Support: IE9-11+ | ||
// IE returns zIndex value as an integer. | ||
@@ -56,0 +55,0 @@ ret + "" : |
@@ -7,10 +7,8 @@ define([ |
jQuery.expr.filters.hidden = function( elem ) { |
// Support: Opera <= 12.12 |
// Opera reports offsetWidths and offsetHeights less than zero on some elements |
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; |
return !jQuery.expr.filters.visible( elem ); |
}; |
jQuery.expr.filters.visible = function( elem ) { |
return !jQuery.expr.filters.hidden( elem ); |
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); |
}; |
}); |
define([ | ||
"../core", | ||
"../var/document", | ||
"../var/documentElement", | ||
"../var/support" | ||
], function( jQuery, support ) { | ||
], function( jQuery, document, documentElement, support ) { | ||
(function() { | ||
var pixelPositionVal, boxSizingReliableVal, | ||
docElem = document.documentElement, | ||
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, | ||
container = document.createElement( "div" ), | ||
div = document.createElement( "div" ); | ||
// Finish early in limited (non-browser) environments | ||
if ( !div.style ) { | ||
@@ -22,4 +24,4 @@ return; | ||
container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" + | ||
"position:absolute"; | ||
container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + | ||
"padding:0;margin-top:1px;position:absolute"; | ||
container.appendChild( div ); | ||
@@ -29,66 +31,73 @@ | ||
// so they're executed at the same time to save the second computation. | ||
function computePixelPositionAndBoxSizingReliable() { | ||
function computeStyleTests() { | ||
div.style.cssText = | ||
// Support: Firefox<29, Android 2.3 | ||
// Support: Android 2.3 | ||
// Vendor-prefix box-sizing | ||
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + | ||
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" + | ||
"border:1px;padding:1px;width:4px;position:absolute"; | ||
"-webkit-box-sizing:border-box;box-sizing:border-box;" + | ||
"display:block;position:absolute;" + | ||
"margin:0;margin-top:1%;margin-right:50%;" + | ||
"border:1px;padding:1px;" + | ||
"top:1%;width:50%;height:4px"; | ||
div.innerHTML = ""; | ||
docElem.appendChild( container ); | ||
documentElement.appendChild( container ); | ||
var divStyle = window.getComputedStyle( div, null ); | ||
var divStyle = window.getComputedStyle( div ); | ||
pixelPositionVal = divStyle.top !== "1%"; | ||
boxSizingReliableVal = divStyle.width === "4px"; | ||
boxSizingReliableVal = divStyle.height === "4px"; | ||
pixelMarginRightVal = divStyle.marginRight === "4px"; | ||
docElem.removeChild( container ); | ||
documentElement.removeChild( container ); | ||
} | ||
// Support: node.js jsdom | ||
// Don't assume that getComputedStyle is a property of the global object | ||
if ( window.getComputedStyle ) { | ||
jQuery.extend( support, { | ||
pixelPosition: function() { | ||
jQuery.extend( support, { | ||
pixelPosition: function() { | ||
// This test is executed only once but we still do memoizing | ||
// since we can use the boxSizingReliable pre-computing. | ||
// No need to check if the test was already performed, though. | ||
computeStyleTests(); | ||
return pixelPositionVal; | ||
}, | ||
boxSizingReliable: function() { | ||
if ( boxSizingReliableVal == null ) { | ||
computeStyleTests(); | ||
} | ||
return boxSizingReliableVal; | ||
}, | ||
pixelMarginRight: function() { | ||
// Support: Android 4.0-4.3 | ||
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal | ||
// since that compresses better and they're computed together anyway. | ||
if ( boxSizingReliableVal == null ) { | ||
computeStyleTests(); | ||
} | ||
return pixelMarginRightVal; | ||
}, | ||
reliableMarginRight: function() { | ||
// This test is executed only once but we still do memoizing | ||
// since we can use the boxSizingReliable pre-computing. | ||
// No need to check if the test was already performed, though. | ||
computePixelPositionAndBoxSizingReliable(); | ||
return pixelPositionVal; | ||
}, | ||
boxSizingReliable: function() { | ||
if ( boxSizingReliableVal == null ) { | ||
computePixelPositionAndBoxSizingReliable(); | ||
} | ||
return boxSizingReliableVal; | ||
}, | ||
reliableMarginRight: function() { | ||
// Support: Android 2.3 | ||
// Check if div with explicit width and no margin-right incorrectly | ||
// gets computed margin-right based on width of container. (#3333) | ||
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | ||
// This support function is only executed once so no memoizing is needed. | ||
var ret, | ||
marginDiv = div.appendChild( document.createElement( "div" ) ); | ||
// Reset CSS: box-sizing; display; margin; border; padding | ||
marginDiv.style.cssText = div.style.cssText = | ||
// Support: Android 2.3 | ||
// Check if div with explicit width and no margin-right incorrectly | ||
// gets computed margin-right based on width of container. (#3333) | ||
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right | ||
// This support function is only executed once so no memoizing is needed. | ||
var ret, | ||
marginDiv = div.appendChild( document.createElement( "div" ) ); | ||
// Vendor-prefix box-sizing | ||
"-webkit-box-sizing:content-box;box-sizing:content-box;" + | ||
"display:block;margin:0;border:0;padding:0"; | ||
marginDiv.style.marginRight = marginDiv.style.width = "0"; | ||
div.style.width = "1px"; | ||
documentElement.appendChild( container ); | ||
// Reset CSS: box-sizing; display; margin; border; padding | ||
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 ).marginRight ); | ||
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); | ||
documentElement.removeChild( container ); | ||
div.removeChild( marginDiv ); | ||
docElem.removeChild( container ); | ||
div.removeChild( marginDiv ); | ||
return ret; | ||
} | ||
}); | ||
} | ||
return ret; | ||
} | ||
}); | ||
})(); | ||
@@ -95,0 +104,0 @@ |
define(function() { | ||
return function( elem ) { | ||
// Support: IE<=11+, Firefox<=30+ (#15098, #14150) | ||
// IE throws on elements created in popups | ||
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle" | ||
if ( elem.ownerDocument.defaultView.opener ) { | ||
return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); | ||
var view = elem.ownerDocument.defaultView; | ||
if ( !view.opener ) { | ||
view = window; | ||
} | ||
return window.getComputedStyle( elem, null ); | ||
return view.getComputedStyle( elem ); | ||
}; | ||
}); |
@@ -11,4 +11,5 @@ define([ | ||
elem = el || elem; | ||
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); | ||
return jQuery.css( elem, "display" ) === "none" || | ||
!jQuery.contains( elem.ownerDocument, elem ); | ||
}; | ||
}); |
define([ | ||
"./core", | ||
"./var/rnotwhite", | ||
"./core/access", | ||
"./data/var/data_priv", | ||
"./data/var/data_user" | ||
], function( jQuery, rnotwhite, access, data_priv, data_user ) { | ||
"./data/var/dataPriv", | ||
"./data/var/dataUser" | ||
], function( jQuery, access, dataPriv, dataUser ) { | ||
@@ -20,3 +19,3 @@ // Implementation Summary | ||
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, | ||
rmultiDash = /([A-Z])/g; | ||
rmultiDash = /[A-Z]/g; | ||
@@ -29,3 +28,3 @@ function dataAttr( elem, key, data ) { | ||
if ( data === undefined && elem.nodeType === 1 ) { | ||
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); | ||
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); | ||
data = elem.getAttribute( name ); | ||
@@ -42,6 +41,6 @@ | ||
data; | ||
} catch( e ) {} | ||
} catch ( e ) {} | ||
// Make sure we set the data so it isn't changed later | ||
data_user.set( elem, key, data ); | ||
dataUser.set( elem, key, data ); | ||
} else { | ||
@@ -56,21 +55,21 @@ data = undefined; | ||
hasData: function( elem ) { | ||
return data_user.hasData( elem ) || data_priv.hasData( elem ); | ||
return dataUser.hasData( elem ) || dataPriv.hasData( elem ); | ||
}, | ||
data: function( elem, name, data ) { | ||
return data_user.access( elem, name, data ); | ||
return dataUser.access( elem, name, data ); | ||
}, | ||
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 | ||
// 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 ) { | ||
return data_priv.access( elem, name, data ); | ||
return dataPriv.access( elem, name, data ); | ||
}, | ||
_removeData: function( elem, name ) { | ||
data_priv.remove( elem, name ); | ||
dataPriv.remove( elem, name ); | ||
} | ||
@@ -88,5 +87,5 @@ }); | ||
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; | ||
@@ -105,3 +104,3 @@ while ( i-- ) { | ||
} | ||
data_priv.set( elem, "hasDataAttrs", true ); | ||
dataPriv.set( elem, "hasDataAttrs", true ); | ||
} | ||
@@ -116,3 +115,3 @@ } | ||
return this.each(function() { | ||
data_user.set( this, key ); | ||
dataUser.set( this, key ); | ||
}); | ||
@@ -122,4 +121,3 @@ } | ||
return access( this, function( value ) { | ||
var data, | ||
camelKey = jQuery.camelCase( key ); | ||
var data; | ||
@@ -132,12 +130,6 @@ // The calling jQuery object (element matches) is not empty | ||
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 | ||
// with the key camelized | ||
data = data_user.get( elem, camelKey ); | ||
// The key will always be camelCased in Data | ||
data = dataUser.get( elem, key ); | ||
if ( data !== undefined ) { | ||
@@ -149,3 +141,3 @@ return data; | ||
// HTML5 custom data-* attrs | ||
data = dataAttr( elem, camelKey, undefined ); | ||
data = dataAttr( elem, key ); | ||
if ( data !== undefined ) { | ||
@@ -161,17 +153,5 @@ return data; | ||
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 | ||
// store property names with dashes in a camelCase form. | ||
// 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 ); | ||
} | ||
// We always store the camelCased key | ||
dataUser.set( this, key, value ); | ||
}); | ||
@@ -183,3 +163,3 @@ }, null, value, arguments.length > 1, null, true ); | ||
return this.each(function() { | ||
data_user.remove( this, key ); | ||
dataUser.remove( this, key ); | ||
}); | ||
@@ -186,0 +166,0 @@ } |
@@ -8,11 +8,2 @@ define([ | ||
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++; | ||
@@ -25,60 +16,58 @@ } | ||
Data.prototype = { | ||
key: function( owner ) { | ||
register: function( owner ) { | ||
var value = {}; | ||
// If it is a node unlikely to be stringify-ed or looped over | ||
// use plain assignment | ||
if ( owner.nodeType ) { | ||
owner[ this.expando ] = value; | ||
// Otherwise secure it in a non-enumerable, non-writable property | ||
// configurability must be true to allow the property to be | ||
// deleted with the delete operator | ||
} else { | ||
Object.defineProperty( owner, this.expando, { | ||
value: value, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
return owner[ this.expando ]; | ||
}, | ||
cache: function( owner ) { | ||
// 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. | ||
// Always return an empty object. | ||
if ( !Data.accepts( owner ) ) { | ||
return 0; | ||
return {}; | ||
} | ||
var descriptor = {}, | ||
// Check if the owner object already has a cache key | ||
unlock = owner[ this.expando ]; | ||
// Check if the owner object already has a cache | ||
var cache = owner[ this.expando ]; | ||
// If not, create one | ||
if ( !unlock ) { | ||
unlock = Data.uid++; | ||
// Secure it in a non-enumerable, non-writable property | ||
try { | ||
descriptor[ this.expando ] = { value: unlock }; | ||
Object.defineProperties( owner, descriptor ); | ||
// Support: Android<4 | ||
// Fallback to a less secure definition | ||
} catch ( e ) { | ||
descriptor[ this.expando ] = unlock; | ||
jQuery.extend( owner, descriptor ); | ||
} | ||
// If so, return it | ||
if ( cache ) { | ||
return cache; | ||
} | ||
// Ensure the cache object | ||
if ( !this.cache[ unlock ] ) { | ||
this.cache[ unlock ] = {}; | ||
} | ||
return unlock; | ||
// If not, register one | ||
return this.register( owner ); | ||
}, | ||
set: function( owner, data, value ) { | ||
var prop, | ||
// There may be an unlock assigned to this node, | ||
// 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 ]; | ||
cache = this.cache( owner ); | ||
// Handle: [ owner, key, value ] args | ||
// Always use camelCase key (gh-2257) | ||
if ( typeof data === "string" ) { | ||
cache[ data ] = value; | ||
cache[ jQuery.camelCase( data ) ] = value; | ||
// Handle: [ owner, { properties } ] args | ||
} else { | ||
// Fresh assignments by object are shallow copied | ||
if ( jQuery.isEmptyObject( cache ) ) { | ||
jQuery.extend( this.cache[ unlock ], data ); | ||
// Otherwise, copy the properties one-by-one to the cache object | ||
} else { | ||
for ( prop in data ) { | ||
cache[ prop ] = data[ prop ]; | ||
} | ||
// Copy the properties one-by-one to the cache object | ||
for ( prop in data ) { | ||
cache[ jQuery.camelCase( prop ) ] = data[ prop ]; | ||
} | ||
@@ -89,13 +78,12 @@ } | ||
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 ) ]; | ||
var cache = this.cache( owner ); | ||
return key === undefined ? | ||
cache : cache[ key ]; | ||
cache : | ||
// Always use camelCase key (gh-2257) | ||
cache[ jQuery.camelCase( key ) ]; | ||
}, | ||
access: function( owner, key, value ) { | ||
var stored; | ||
// In cases where either: | ||
@@ -113,8 +101,5 @@ // | ||
if ( key === undefined || | ||
((key && typeof key === "string") && value === undefined) ) { | ||
( ( key && typeof key === "string" ) && value === undefined ) ) { | ||
stored = this.get( owner, key ); | ||
return stored !== undefined ? | ||
stored : this.get( owner, jQuery.camelCase(key) ); | ||
return this.get( owner, key ); | ||
} | ||
@@ -135,48 +120,42 @@ | ||
remove: function( owner, key ) { | ||
var i, name, camel, | ||
unlock = this.key( owner ), | ||
cache = this.cache[ unlock ]; | ||
var i, | ||
cache = owner[ this.expando ]; | ||
if ( key === undefined ) { | ||
this.cache[ unlock ] = {}; | ||
if ( cache === undefined ) { | ||
return; | ||
} | ||
} else { | ||
if ( key !== undefined ) { | ||
// Support array or space separated string of keys | ||
if ( jQuery.isArray( key ) ) { | ||
// If "name" is an array of keys... | ||
// When data is initially created, via ("key", "val") signature, | ||
// keys will be converted to camelCase. | ||
// Since there is no way to tell _how_ a key was added, remove | ||
// both plain key and camelCase key. #12786 | ||
// This will only penalize the array argument path. | ||
name = key.concat( key.map( jQuery.camelCase ) ); | ||
// If key is an array of keys... | ||
// We always set camelCase keys, so remove that. | ||
key = key.map( jQuery.camelCase ); | ||
} else { | ||
camel = jQuery.camelCase( key ); | ||
// Try the string as a key before any manipulation | ||
if ( key in cache ) { | ||
name = [ key, camel ]; | ||
} else { | ||
// If a key with the spaces exists, use it. | ||
// Otherwise, create an array by matching non-whitespace | ||
name = camel; | ||
name = name in cache ? | ||
[ name ] : ( name.match( rnotwhite ) || [] ); | ||
} | ||
key = jQuery.camelCase( key ); | ||
// If a key with the spaces exists, use it. | ||
// Otherwise, create an array by matching non-whitespace | ||
key = key in cache ? | ||
[ key ] : | ||
( key.match( rnotwhite ) || [] ); | ||
} | ||
i = name.length; | ||
i = key.length; | ||
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 ) ) { | ||
delete owner[ this.expando ]; | ||
} | ||
}, | ||
hasData: function( owner ) { | ||
return !jQuery.isEmptyObject( | ||
this.cache[ owner[ this.expando ] ] || {} | ||
); | ||
}, | ||
discard: function( owner ) { | ||
if ( owner[ this.expando ] ) { | ||
delete this.cache[ owner[ this.expando ] ]; | ||
} | ||
var cache = owner[ this.expando ]; | ||
return cache !== undefined && !jQuery.isEmptyObject( cache ); | ||
} | ||
@@ -183,0 +162,0 @@ }; |
@@ -7,2 +7,9 @@ define([ | ||
function Identity( v ) { | ||
return v; | ||
} | ||
function Thrower( ex ) { | ||
throw ex; | ||
} | ||
jQuery.extend({ | ||
@@ -12,6 +19,10 @@ | ||
var tuples = [ | ||
// action, add listener, listener list, final state | ||
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], | ||
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], | ||
[ "notify", "progress", jQuery.Callbacks("memory") ] | ||
// action, add listener, callbacks, | ||
// ... .then handlers, argument index, [final state] | ||
[ "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" ] | ||
], | ||
@@ -27,8 +38,17 @@ state = "pending", | ||
}, | ||
then: function( /* fnDone, fnFail, fnProgress */ ) { | ||
"catch": function( fn ) { | ||
return promise.then( null, fn ); | ||
}, | ||
// Keep pipe for back-compat | ||
pipe: function( /* fnDone, fnFail, fnProgress */ ) { | ||
var fns = arguments; | ||
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 | ||
// Map tuples (progress, done, fail) to arguments (done, fail, progress) | ||
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; | ||
// deferred.progress(function() { bind to newDefer or newDefer.notify }) | ||
// deferred.done(function() { bind to newDefer or newDefer.resolve }) | ||
// deferred.fail(function() { bind to newDefer or newDefer.reject }) | ||
deferred[ tuple[1] ](function() { | ||
@@ -38,7 +58,10 @@ var returned = fn && fn.apply( this, arguments ); | ||
returned.promise() | ||
.progress( newDefer.notify ) | ||
.done( newDefer.resolve ) | ||
.fail( newDefer.reject ) | ||
.progress( newDefer.notify ); | ||
.fail( newDefer.reject ); | ||
} else { | ||
newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); | ||
newDefer[ tuple[ 0 ] + "With" ]( | ||
this === promise ? newDefer.promise() : this, | ||
fn ? [ returned ] : arguments | ||
); | ||
} | ||
@@ -50,2 +73,153 @@ }); | ||
}, | ||
then: function( onFulfilled, onRejected, onProgress ) { | ||
var maxDepth = 0; | ||
function resolve( depth, deferred, handler, special ) { | ||
return function() { | ||
var that = this === promise ? undefined : this, | ||
args = arguments, | ||
mightThrow = function() { | ||
var returned, then; | ||
// Support: Promises/A+ section 2.3.3.3.3 | ||
// https://promisesaplus.com/#point-59 | ||
// Ignore double-resolution attempts | ||
if ( depth < maxDepth ) { | ||
return; | ||
} | ||
returned = handler.apply( that, args ); | ||
// Support: Promises/A+ section 2.3.1 | ||
// https://promisesaplus.com/#point-48 | ||
if ( returned === deferred.promise() ) { | ||
throw new TypeError( "Thenable self-resolution" ); | ||
} | ||
// Support: Promises/A+ sections 2.3.3.1, 3.5 | ||
// https://promisesaplus.com/#point-54 | ||
// https://promisesaplus.com/#point-75 | ||
// Retrieve `then` only once | ||
then = returned && | ||
// Support: Promises/A+ section 2.3.4 | ||
// https://promisesaplus.com/#point-64 | ||
// Only check objects and functions for thenability | ||
( typeof returned === "object" || | ||
typeof returned === "function" ) && | ||
returned.then; | ||
// Handle a returned thenable | ||
if ( jQuery.isFunction( then ) ) { | ||
// Special processors (notify) just wait for resolution | ||
if ( special ) { | ||
then.call( | ||
returned, | ||
resolve( maxDepth, deferred, Identity, special ), | ||
resolve( maxDepth, deferred, Thrower, special ) | ||
); | ||
// Normal processors (resolve) also hook into progress | ||
} else { | ||
// ...and disregard older resolution values | ||
maxDepth++; | ||
then.call( | ||
returned, | ||
resolve( maxDepth, deferred, Identity, special ), | ||
resolve( maxDepth, deferred, Thrower, special ), | ||
resolve( maxDepth, deferred, Identity, | ||
deferred.notify ) | ||
); | ||
} | ||
// Handle all other returned values | ||
} else { | ||
// Only substitue handlers pass on context | ||
// and multiple values (non-spec behavior) | ||
if ( handler !== Identity ) { | ||
that = undefined; | ||
args = [ returned ]; | ||
} | ||
// Process the value(s) | ||
// Default process is resolve | ||
( special || deferred.resolveWith )( | ||
that || deferred.promise(), args ); | ||
} | ||
}, | ||
// Only normal processors (resolve) catch and reject exceptions | ||
process = special ? | ||
mightThrow : | ||
function() { | ||
try { | ||
mightThrow(); | ||
} catch ( e ) { | ||
// Support: Promises/A+ section 2.3.3.3.4.1 | ||
// https://promisesaplus.com/#point-61 | ||
// Ignore post-resolution exceptions | ||
if ( depth + 1 >= maxDepth ) { | ||
// Only substitue handlers pass on context | ||
// and multiple values (non-spec behavior) | ||
if ( handler !== Thrower ) { | ||
that = undefined; | ||
args = [ e ]; | ||
} | ||
deferred.rejectWith( that || deferred.promise(), | ||
args ); | ||
} | ||
} | ||
}; | ||
// Support: Promises/A+ section 2.3.3.3.1 | ||
// https://promisesaplus.com/#point-57 | ||
// Re-resolve promises immediately to dodge false rejection from | ||
// subsequent errors | ||
if ( depth ) { | ||
process(); | ||
} else { | ||
window.setTimeout( process ); | ||
} | ||
}; | ||
} | ||
return jQuery.Deferred(function( newDefer ) { | ||
// progress_handlers.add( ... ) | ||
tuples[ 0 ][ 3 ].add( | ||
resolve( | ||
0, | ||
newDefer, | ||
jQuery.isFunction( onProgress ) ? | ||
onProgress : | ||
Identity, | ||
newDefer.notifyWith | ||
) | ||
); | ||
// fulfilled_handlers.add( ... ) | ||
tuples[ 1 ][ 3 ].add( | ||
resolve( | ||
0, | ||
newDefer, | ||
jQuery.isFunction( onFulfilled ) ? | ||
onFulfilled : | ||
Identity | ||
) | ||
); | ||
// rejected_handlers.add( ... ) | ||
tuples[ 2 ][ 3 ].add( | ||
resolve( | ||
0, | ||
newDefer, | ||
jQuery.isFunction( onRejected ) ? | ||
onRejected : | ||
Thrower | ||
) | ||
); | ||
}).promise(); | ||
}, | ||
// Get a promise for this deferred | ||
@@ -59,11 +233,10 @@ // If obj is provided, the promise aspect is added to the object | ||
// Keep pipe for back-compat | ||
promise.pipe = promise.then; | ||
// Add list-specific methods | ||
jQuery.each( tuples, function( i, tuple ) { | ||
var list = tuple[ 2 ], | ||
stateString = tuple[ 3 ]; | ||
stateString = tuple[ 5 ]; | ||
// promise[ done | fail | progress ] = list.add | ||
// promise.progress = list.add | ||
// promise.done = list.add | ||
// promise.fail = list.add | ||
promise[ tuple[1] ] = list.add; | ||
@@ -73,11 +246,26 @@ | ||
if ( stateString ) { | ||
list.add(function() { | ||
// state = [ resolved | rejected ] | ||
state = stateString; | ||
list.add( | ||
function() { | ||
// state = "resolved" (i.e., fulfilled) | ||
// state = "rejected" | ||
state = stateString; | ||
}, | ||
// [ reject_list | resolve_list ].disable; progress_list.lock | ||
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); | ||
// rejected_callbacks.disable | ||
// fulfilled_callbacks.disable | ||
tuples[ 3 - i ][ 2 ].disable, | ||
// progress_callbacks.lock | ||
tuples[ 0 ][ 2 ].lock | ||
); | ||
} | ||
// deferred[ resolve | reject | notify ] | ||
// progress_handlers.fire | ||
// fulfilled_handlers.fire | ||
// rejected_handlers.fire | ||
list.add( tuple[ 3 ].fire ); | ||
// deferred.notify = function() { deferred.notifyWith(...) } | ||
// deferred.resolve = function() { deferred.resolveWith(...) } | ||
// deferred.reject = function() { deferred.rejectWith(...) } | ||
deferred[ tuple[0] ] = function() { | ||
@@ -87,2 +275,6 @@ deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); | ||
}; | ||
// deferred.notifyWith = list.fireWith | ||
// deferred.resolveWith = list.fireWith | ||
// deferred.rejectWith = list.fireWith | ||
deferred[ tuple[0] + "With" ] = list.fireWith; | ||
@@ -105,3 +297,4 @@ }); | ||
when: function( subordinate /* , ..., subordinateN */ ) { | ||
var i = 0, | ||
var method, | ||
i = 0, | ||
resolveValues = slice.call( arguments ), | ||
@@ -111,6 +304,8 @@ length = resolveValues.length, | ||
// the count of uncompleted subordinates | ||
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, | ||
remaining = length !== 1 || | ||
( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, | ||
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. | ||
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), | ||
// the master Deferred. | ||
// If resolveValues consist of only a single Deferred, just use that. | ||
master = remaining === 1 ? subordinate : jQuery.Deferred(), | ||
@@ -123,9 +318,8 @@ // Update function for both resolve and progress values | ||
if ( values === progressValues ) { | ||
deferred.notifyWith( contexts, values ); | ||
master.notifyWith( contexts, values ); | ||
} else if ( !( --remaining ) ) { | ||
deferred.resolveWith( contexts, values ); | ||
master.resolveWith( contexts, values ); | ||
} | ||
}; | ||
}, | ||
progressValues, progressContexts, resolveContexts; | ||
@@ -139,7 +333,18 @@ | ||
for ( ; i < length; i++ ) { | ||
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { | ||
resolveValues[ i ].promise() | ||
if ( resolveValues[ i ] && | ||
jQuery.isFunction( (method = resolveValues[ i ].promise) ) ) { | ||
method.call( resolveValues[ i ] ) | ||
.progress( updateFunc( i, progressContexts, progressValues ) ) | ||
.done( updateFunc( i, resolveContexts, resolveValues ) ) | ||
.fail( deferred.reject ) | ||
.progress( updateFunc( i, progressContexts, progressValues ) ); | ||
.fail( master.reject ); | ||
} else if ( resolveValues[ i ] && | ||
jQuery.isFunction( (method = resolveValues[ i ].then) ) ) { | ||
method.call( | ||
resolveValues[ i ], | ||
updateFunc( i, resolveContexts, resolveValues ), | ||
master.reject, | ||
updateFunc( i, progressContexts, progressValues ) | ||
); | ||
} else { | ||
@@ -153,6 +358,6 @@ --remaining; | ||
if ( !remaining ) { | ||
deferred.resolveWith( resolveContexts, resolveValues ); | ||
master.resolveWith( resolveContexts, resolveValues ); | ||
} | ||
return deferred.promise(); | ||
return master.promise(); | ||
} | ||
@@ -159,0 +364,0 @@ }); |
@@ -1,13 +0,2 @@ | ||
define([ | ||
"./core", | ||
"./traversing" | ||
], function( jQuery ) { | ||
// The number of elements contained in the matched element set | ||
jQuery.fn.size = function() { | ||
return this.length; | ||
}; | ||
jQuery.fn.andSelf = jQuery.fn.addBack; | ||
define(function() { | ||
}); |
@@ -9,3 +9,5 @@ define([ | ||
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 | ||
@@ -12,0 +14,0 @@ jQuery.fn[ funcName ] = function( margin, value ) { |
define([ | ||
"./core", | ||
"./var/pnum", | ||
"./var/document", | ||
"./var/rcssNum", | ||
"./var/rnotwhite", | ||
"./css/var/cssExpand", | ||
"./css/var/isHidden", | ||
"./css/defaultDisplay", | ||
"./data/var/data_priv", | ||
"./css/var/swap", | ||
"./css/adjustCSS", | ||
"./data/var/dataPriv", | ||
"./css/showHide", | ||
"./core/init", | ||
"./effects/Tween", | ||
"./queue", | ||
"./deferred", | ||
"./traversing", | ||
"./manipulation", | ||
"./css", | ||
"./deferred", | ||
"./traversing" | ||
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) { | ||
"./effects/Tween" | ||
], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap, | ||
adjustCSS, dataPriv, showHide ) { | ||
@@ -20,59 +26,14 @@ var | ||
rfxtypes = /^(?:toggle|show|hide)$/, | ||
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), | ||
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" ), | ||
rrun = /queueHooks$/; | ||
// Starting value computation is required for potential unit mismatches | ||
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && | ||
rfxnum.exec( jQuery.css( tween.elem, prop ) ), | ||
scale = 1, | ||
maxIterations = 20; | ||
function raf() { | ||
if ( timerId ) { | ||
window.requestAnimationFrame( raf ); | ||
jQuery.fx.tick(); | ||
} | ||
} | ||
if ( start && start[ 3 ] !== unit ) { | ||
// 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 | ||
function createFxNow() { | ||
setTimeout(function() { | ||
window.setTimeout(function() { | ||
fxNow = undefined; | ||
@@ -106,3 +67,3 @@ }); | ||
var tween, | ||
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), | ||
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), | ||
index = 0, | ||
@@ -121,3 +82,4 @@ length = collection.length; | ||
/* jshint validthis: true */ | ||
var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, | ||
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, | ||
isBox = "width" in props || "height" in props, | ||
anim = this, | ||
@@ -127,5 +89,5 @@ orig = {}, | ||
hidden = elem.nodeType && isHidden( 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 ) { | ||
@@ -155,20 +117,65 @@ hooks = jQuery._queueHooks( elem, "fx" ); | ||
// Height/width overflow pass | ||
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { | ||
// Make sure that nothing sneaks out | ||
// Record all 3 overflow attributes because IE9-10 do not | ||
// change the overflow attribute when overflowX and | ||
// overflowY are set to the same value | ||
// Detect show/hide animations | ||
for ( prop in props ) { | ||
value = props[ prop ]; | ||
if ( rfxtypes.test( value ) ) { | ||
delete props[ prop ]; | ||
toggle = toggle || value === "toggle"; | ||
if ( value === ( hidden ? "hide" : "show" ) ) { | ||
// Pretend to be hidden if this is a "show" and | ||
// there is still data from a stopped show/hide | ||
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { | ||
hidden = true; | ||
// Ignore all other no-op show/hide data | ||
} else { | ||
continue; | ||
} | ||
} | ||
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); | ||
} | ||
} | ||
// Bail out if this is a no-op like .hide().hide() | ||
propTween = !jQuery.isEmptyObject( props ); | ||
if ( !propTween && jQuery.isEmptyObject( orig ) ) { | ||
return; | ||
} | ||
// Restrict "overflow" and "display" styles during box animations | ||
if ( isBox && elem.nodeType === 1 ) { | ||
// Support: IE 9 - 11 | ||
// Record all 3 overflow attributes because IE does not infer the shorthand | ||
// from identically-valued overflowX and overflowY | ||
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; | ||
// Set display property to inline-block for height/width | ||
// animations on inline elements that are having width/height animated | ||
// 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" ) { | ||
display = restoreDisplay || swap( elem, { "display": "" }, function() { | ||
return jQuery.css( elem, "display" ); | ||
} ); | ||
} | ||
// Test default display if display is currently "none" | ||
checkDisplay = display === "none" ? | ||
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; | ||
// Animate inline elements as inline-block | ||
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { | ||
if ( jQuery.css( elem, "float" ) === "none" ) { | ||
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { | ||
style.display = "inline-block"; | ||
// Restore the original display value at the end of pure show/hide animations | ||
if ( !propTween ) { | ||
anim.done(function() { | ||
style.display = restoreDisplay; | ||
}); | ||
if ( restoreDisplay == null ) { | ||
display = style.display; | ||
restoreDisplay = display === "none" ? "" : display; | ||
} | ||
} | ||
style.display = "inline-block"; | ||
} | ||
} | ||
@@ -186,68 +193,48 @@ } | ||
// show/hide pass | ||
for ( prop in props ) { | ||
value = props[ prop ]; | ||
if ( rfxtypes.exec( value ) ) { | ||
delete props[ prop ]; | ||
toggle = toggle || value === "toggle"; | ||
if ( value === ( hidden ? "hide" : "show" ) ) { | ||
// Implement show/hide animations | ||
propTween = false; | ||
for ( prop in orig ) { | ||
// 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 | ||
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { | ||
hidden = true; | ||
} else { | ||
continue; | ||
// 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 } ); | ||
} | ||
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); | ||
// Any non-fx value stops us from restoring the original display value | ||
} else { | ||
display = undefined; | ||
} | ||
} | ||
// Store hidden/visible for toggle so `.stop().toggle()` "reverses" | ||
if ( toggle ) { | ||
dataShow.hidden = !hidden; | ||
} | ||
if ( !jQuery.isEmptyObject( orig ) ) { | ||
if ( dataShow ) { | ||
if ( "hidden" in dataShow ) { | ||
hidden = dataShow.hidden; | ||
// Show elements before animating them | ||
if ( hidden ) { | ||
showHide( [ elem ], true ); | ||
} | ||
} else { | ||
dataShow = data_priv.access( elem, "fxshow", {} ); | ||
} | ||
// Store state if its toggle - enables .stop().toggle() to "reverse" | ||
if ( toggle ) { | ||
dataShow.hidden = !hidden; | ||
} | ||
if ( hidden ) { | ||
jQuery( elem ).show(); | ||
} else { | ||
/* jshint -W083 */ | ||
anim.done(function() { | ||
jQuery( elem ).hide(); | ||
// The final step of a "hide" animation is actually hiding the element | ||
if ( !hidden ) { | ||
showHide( [ elem ] ); | ||
} | ||
dataPriv.remove( elem, "fxshow" ); | ||
for ( prop in orig ) { | ||
jQuery.style( elem, prop, orig[ prop ] ); | ||
} | ||
}); | ||
} | ||
anim.done(function() { | ||
var prop; | ||
data_priv.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 = prop === "width" || prop === "height" ? 1 : 0; | ||
} | ||
}); | ||
for ( prop in orig ) { | ||
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); | ||
if ( !( prop in dataShow ) ) { | ||
dataShow[ prop ] = tween.start; | ||
if ( hidden ) { | ||
tween.end = tween.start; | ||
tween.start = prop === "width" || prop === "height" ? 1 : 0; | ||
} | ||
} | ||
} | ||
// If this is a noop like .hide().hide(), restore an overwritten display value | ||
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { | ||
style.display = display; | ||
} | ||
@@ -297,3 +284,3 @@ } | ||
index = 0, | ||
length = animationPrefilters.length, | ||
length = Animation.prefilters.length, | ||
deferred = jQuery.Deferred().always( function() { | ||
@@ -332,3 +319,6 @@ // Don't match elem in the :animated selector | ||
props: jQuery.extend( {}, properties ), | ||
opts: jQuery.extend( true, { specialEasing: {} }, options ), | ||
opts: jQuery.extend( true, { | ||
specialEasing: {}, | ||
easing: jQuery.easing._default | ||
}, options ), | ||
originalProperties: properties, | ||
@@ -372,4 +362,8 @@ originalOptions: options, | ||
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 ( jQuery.isFunction( result.stop ) ) { | ||
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = | ||
jQuery.proxy( result.stop, result ); | ||
} | ||
return result; | ||
@@ -402,2 +396,10 @@ } | ||
tweeners: { | ||
"*": [ function( prop, value ) { | ||
var tween = this.createTween( prop, value ); | ||
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); | ||
return tween; | ||
} ] | ||
}, | ||
tweener: function( props, callback ) { | ||
@@ -408,3 +410,3 @@ if ( jQuery.isFunction( props ) ) { | ||
} else { | ||
props = props.split(" "); | ||
props = props.match( rnotwhite ); | ||
} | ||
@@ -418,12 +420,14 @@ | ||
prop = props[ index ]; | ||
tweeners[ prop ] = tweeners[ prop ] || []; | ||
tweeners[ prop ].unshift( callback ); | ||
Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; | ||
Animation.tweeners[ prop ].unshift( callback ); | ||
} | ||
}, | ||
prefilters: [ defaultPrefilter ], | ||
prefilter: function( callback, prepend ) { | ||
if ( prepend ) { | ||
animationPrefilters.unshift( callback ); | ||
Animation.prefilters.unshift( callback ); | ||
} else { | ||
animationPrefilters.push( callback ); | ||
Animation.prefilters.push( callback ); | ||
} | ||
@@ -441,5 +445,12 @@ } | ||
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : | ||
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; | ||
// Go to the end state if fx are off or if document is hidden | ||
if ( jQuery.fx.off || document.hidden ) { | ||
opt.duration = 0; | ||
} else { | ||
opt.duration = typeof opt.duration === "number" ? | ||
opt.duration : opt.duration in jQuery.fx.speeds ? | ||
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; | ||
} | ||
// Normalize opt.queue - true/undefined/null -> "fx" | ||
@@ -483,3 +494,3 @@ if ( opt.queue == null || opt.queue === true ) { | ||
// Empty animations, or finishing resolves immediately | ||
if ( empty || data_priv.get( this, "finish" ) ) { | ||
if ( empty || dataPriv.get( this, "finish" ) ) { | ||
anim.stop( true ); | ||
@@ -514,3 +525,3 @@ } | ||
timers = jQuery.timers, | ||
data = data_priv.get( this ); | ||
data = dataPriv.get( this ); | ||
@@ -530,3 +541,5 @@ if ( 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 ); | ||
@@ -552,3 +565,3 @@ dequeue = false; | ||
var index, | ||
data = data_priv.get( this ), | ||
data = dataPriv.get( this ), | ||
queue = data[ type + "queue" ], | ||
@@ -645,6 +658,7 @@ hooks = data[ type + "queueHooks" ], | ||
jQuery.fx.interval = 13; | ||
jQuery.fx.start = function() { | ||
if ( !timerId ) { | ||
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); | ||
timerId = window.requestAnimationFrame ? | ||
window.requestAnimationFrame( raf ) : | ||
window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); | ||
} | ||
@@ -654,3 +668,8 @@ }; | ||
jQuery.fx.stop = function() { | ||
clearInterval( timerId ); | ||
if ( window.cancelAnimationFrame ) { | ||
window.cancelAnimationFrame( timerId ); | ||
} else { | ||
window.clearInterval( timerId ); | ||
} | ||
timerId = null; | ||
@@ -657,0 +676,0 @@ }; |
@@ -16,3 +16,3 @@ define([ | ||
this.prop = prop; | ||
this.easing = easing || "swing"; | ||
this.easing = easing || jQuery.easing._default; | ||
this.options = options; | ||
@@ -63,4 +63,6 @@ this.start = this.now = this.cur(); | ||
if ( tween.elem[ tween.prop ] != null && | ||
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { | ||
// Use a property on the element directly when it is not a DOM element, | ||
// 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 ]; | ||
@@ -83,3 +85,5 @@ } | ||
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 && | ||
( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || | ||
jQuery.cssHooks[ tween.prop ] ) ) { | ||
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); | ||
@@ -109,3 +113,4 @@ } else { | ||
return 0.5 - Math.cos( p * Math.PI ) / 2; | ||
} | ||
}, | ||
_default: "swing" | ||
}; | ||
@@ -112,0 +117,0 @@ |
270
src/event.js
define([ | ||
"./core", | ||
"./var/strundefined", | ||
"./var/document", | ||
"./var/rnotwhite", | ||
@@ -8,3 +8,3 @@ "./var/hasOwn", | ||
"./event/support", | ||
"./data/var/data_priv", | ||
"./data/var/dataPriv", | ||
@@ -14,9 +14,9 @@ "./core/init", | ||
"./selector" | ||
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) { | ||
], function( jQuery, document, rnotwhite, hasOwn, slice, support, dataPriv ) { | ||
var | ||
rkeyEvent = /^key/, | ||
rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, | ||
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, | ||
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, | ||
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; | ||
rtypenamespace = /^([^.]*)(?:\.(.+)|)/; | ||
@@ -31,2 +31,4 @@ function returnTrue() { | ||
// Support: IE9 | ||
// See #13393 for more info | ||
function safeActiveElement() { | ||
@@ -38,2 +40,54 @@ try { | ||
function on( elem, types, selector, data, fn, one ) { | ||
var origFn, type; | ||
// Types can be a map of types/handlers | ||
if ( typeof types === "object" ) { | ||
// ( types-Object, selector, data ) | ||
if ( typeof selector !== "string" ) { | ||
// ( types-Object, data ) | ||
data = data || selector; | ||
selector = undefined; | ||
} | ||
for ( type in types ) { | ||
on( elem, type, selector, data, types[ type ], one ); | ||
} | ||
return elem; | ||
} | ||
if ( data == null && fn == null ) { | ||
// ( types, fn ) | ||
fn = selector; | ||
data = selector = undefined; | ||
} else if ( fn == null ) { | ||
if ( typeof selector === "string" ) { | ||
// ( types, selector, fn ) | ||
fn = data; | ||
data = undefined; | ||
} else { | ||
// ( types, data, fn ) | ||
fn = data; | ||
data = selector; | ||
selector = undefined; | ||
} | ||
} | ||
if ( fn === false ) { | ||
fn = returnFalse; | ||
} | ||
if ( one === 1 ) { | ||
origFn = fn; | ||
fn = function( event ) { | ||
// Can use an empty set, since event contains the info | ||
jQuery().off( event ); | ||
return origFn.apply( this, arguments ); | ||
}; | ||
// Use same guid so caller can remove using origFn | ||
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); | ||
} | ||
return elem.each( function() { | ||
jQuery.event.add( this, types, fn, data, selector ); | ||
}); | ||
} | ||
/* | ||
@@ -52,3 +106,3 @@ * Helper functions for managing events -- not part of the public interface. | ||
special, handlers, type, namespaces, origType, | ||
elemData = data_priv.get( elem ); | ||
elemData = dataPriv.get( elem ); | ||
@@ -80,3 +134,3 @@ // Don't attach events to noData or text/comment nodes (but allow plain objects) | ||
// when an event is called after a page has unloaded | ||
return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? | ||
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? | ||
jQuery.event.dispatch.apply( elem, arguments ) : undefined; | ||
@@ -126,5 +180,7 @@ }; | ||
// Only use addEventListener if the special events handler returns false | ||
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { | ||
if ( !special.setup || | ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) { | ||
if ( elem.addEventListener ) { | ||
elem.addEventListener( type, eventHandle, false ); | ||
elem.addEventListener( type, eventHandle ); | ||
} | ||
@@ -161,3 +217,3 @@ } | ||
special, handlers, type, namespaces, origType, | ||
elemData = data_priv.hasData( elem ) && data_priv.get( elem ); | ||
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); | ||
@@ -197,3 +253,4 @@ if ( !elemData || !(events = elemData.events) ) { | ||
( !tmp || tmp.test( handleObj.namespace ) ) && | ||
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { | ||
( !selector || selector === handleObj.selector || | ||
selector === "**" && handleObj.selector ) ) { | ||
handlers.splice( j, 1 ); | ||
@@ -213,3 +270,5 @@ | ||
if ( origCount && !handlers.length ) { | ||
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { | ||
if ( !special.teardown || | ||
special.teardown.call( elem, namespaces, elemData.handle ) === false ) { | ||
jQuery.removeEvent( elem, type, elemData.handle ); | ||
@@ -222,6 +281,5 @@ } | ||
// Remove the expando if it's no longer used | ||
// Remove data and the expando if it's no longer used | ||
if ( jQuery.isEmptyObject( events ) ) { | ||
delete elemData.handle; | ||
data_priv.remove( elem, "events" ); | ||
dataPriv.remove( elem, "handle events" ); | ||
} | ||
@@ -249,3 +307,3 @@ }, | ||
if ( type.indexOf(".") >= 0 ) { | ||
if ( type.indexOf(".") > -1 ) { | ||
// Namespaced trigger; create a regexp to match event type in handle() | ||
@@ -266,3 +324,3 @@ namespaces = type.split("."); | ||
event.namespace = namespaces.join("."); | ||
event.namespace_re = event.namespace ? | ||
event.rnamespace = event.namespace ? | ||
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : | ||
@@ -316,3 +374,4 @@ null; | ||
// jQuery handler | ||
handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); | ||
handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && | ||
dataPriv.get( cur, "handle" ); | ||
if ( handle ) { | ||
@@ -373,3 +432,3 @@ handle.apply( cur, data ); | ||
args = slice.call( arguments ), | ||
handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], | ||
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], | ||
special = jQuery.event.special[ event.type ] || {}; | ||
@@ -395,7 +454,8 @@ | ||
j = 0; | ||
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { | ||
while ( (handleObj = matched.handlers[ j++ ]) && | ||
!event.isImmediatePropagationStopped() ) { | ||
// Triggered event must either 1) have no namespace, or 2) have namespace(s) | ||
// a subset or equal to those in the bound event (both can have no namespace). | ||
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { | ||
if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { | ||
@@ -405,4 +465,4 @@ event.handleObj = handleObj; | ||
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) | ||
.apply( matched.elem, args ); | ||
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || | ||
handleObj.handler ).apply( matched.elem, args ); | ||
@@ -433,4 +493,7 @@ if ( ret !== undefined ) { | ||
// Support (at least): Chrome, IE9 | ||
// Find delegate handlers | ||
// Black-hole SVG <use> instance trees (#13180) | ||
// | ||
// Support: Firefox | ||
// Avoid non-left-click bubbling in Firefox (#3861) | ||
@@ -452,3 +515,3 @@ if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { | ||
matches[ sel ] = handleObj.needsContext ? | ||
jQuery( sel, this ).index( cur ) >= 0 : | ||
jQuery( sel, this ).index( cur ) > -1 : | ||
jQuery.find( sel, this, null, [ cur ] ).length; | ||
@@ -476,3 +539,4 @@ } | ||
// Includes some event props shared by KeyEvent and MouseEvent | ||
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), | ||
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + | ||
"metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "), | ||
@@ -495,3 +559,4 @@ fixHooks: {}, | ||
mouseHooks: { | ||
props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), | ||
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + | ||
"screenX screenY toElement" ).split(" "), | ||
filter: function( event, original ) { | ||
@@ -507,4 +572,8 @@ var eventDoc, doc, body, | ||
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); | ||
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); | ||
event.pageX = original.clientX + | ||
( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - | ||
( doc && doc.clientLeft || body && body.clientLeft || 0 ); | ||
event.pageY = original.clientY + | ||
( doc && doc.scrollTop || body && body.scrollTop || 0 ) - | ||
( doc && doc.clientTop || body && body.clientTop || 0 ); | ||
} | ||
@@ -549,9 +618,3 @@ | ||
// Support: Cordova 2.5 (WebKit) (#13255) | ||
// All events should have a target; Cordova deviceready doesn't | ||
if ( !event.target ) { | ||
event.target = document; | ||
} | ||
// Support: Safari 6.0+, Chrome<28 | ||
// Support: Safari 6.0+ | ||
// Target should not be a text node (#504, #13143) | ||
@@ -616,6 +679,4 @@ if ( event.target.nodeType === 3 ) { | ||
simulate: function( type, elem, event, bubble ) { | ||
// Piggyback on a donor event to simulate a different one. | ||
// Fake originalEvent to avoid donor's stopPropagation, but if the | ||
// simulated event prevents default then we do the same on the donor. | ||
// Piggyback on a donor event to simulate a different one | ||
simulate: function( type, elem, event ) { | ||
var e = jQuery.extend( | ||
@@ -626,11 +687,20 @@ new jQuery.Event(), | ||
type: type, | ||
isSimulated: true, | ||
originalEvent: {} | ||
isSimulated: true | ||
// Previously, `originalEvent: {}` was set here, so stopPropagation call | ||
// would not be triggered on donor event, since in our own | ||
// jQuery.event.stopPropagation function we had a check for existence of | ||
// originalEvent.stopPropagation method, so, consequently it would be a noop. | ||
// | ||
// But now, this "simulate" function is used only for events | ||
// for which stopPropagation() is noop, so there is no need for that anymore. | ||
// | ||
// For the compat branch though, guard for "click" and "submit" | ||
// events is still used, but was moved to jQuery.event.stopPropagation function | ||
// because `originalEvent` should point to the original event for the constancy | ||
// with other events and for more focused logic | ||
} | ||
); | ||
if ( bubble ) { | ||
jQuery.event.trigger( e, null, elem ); | ||
} else { | ||
jQuery.event.dispatch.call( elem, e ); | ||
} | ||
jQuery.event.trigger( e, null, elem ); | ||
if ( e.isDefaultPrevented() ) { | ||
@@ -643,4 +713,6 @@ event.preventDefault(); | ||
jQuery.removeEvent = function( elem, type, handle ) { | ||
// This "if" is needed for plain objects | ||
if ( elem.removeEventListener ) { | ||
elem.removeEventListener( type, handle, false ); | ||
elem.removeEventListener( type, handle ); | ||
} | ||
@@ -689,2 +761,3 @@ }; | ||
jQuery.Event.prototype = { | ||
constructor: jQuery.Event, | ||
isDefaultPrevented: returnFalse, | ||
@@ -699,3 +772,3 @@ isPropagationStopped: returnFalse, | ||
if ( e && e.preventDefault ) { | ||
if ( e ) { | ||
e.preventDefault(); | ||
@@ -709,3 +782,3 @@ } | ||
if ( e && e.stopPropagation ) { | ||
if ( e ) { | ||
e.stopPropagation(); | ||
@@ -719,3 +792,3 @@ } | ||
if ( e && e.stopImmediatePropagation ) { | ||
if ( e ) { | ||
e.stopImmediatePropagation(); | ||
@@ -729,3 +802,12 @@ } | ||
// Create mouseenter/leave events using mouseover/out and event-time checks | ||
// Support: Chrome 15+ | ||
// so that event delegation works in jQuery. | ||
// Do the same for pointerenter/pointerleave and pointerover/pointerout | ||
// | ||
// Support: Safari<7.0 | ||
// Safari doesn't support mouseenter/mouseleave at all. | ||
// | ||
// Support: Chrome 34+ | ||
// Mouseenter doesn't perform while left mouse button is pressed | ||
// (and initiated outside the observed element) | ||
// https://code.google.com/p/chromium/issues/detail?id=333868 | ||
jQuery.each({ | ||
@@ -759,5 +841,11 @@ mouseenter: "mouseover", | ||
// Support: Firefox, Chrome, Safari | ||
// Create "bubbling" focus and blur events | ||
if ( !support.focusinBubbles ) { | ||
// Support: Firefox | ||
// Firefox doesn't have focus(in | out) events | ||
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 | ||
// | ||
// Support: Chrome, Safari | ||
// focus(in | out) events fire after focus & blur events, | ||
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order | ||
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 | ||
if ( !support.focusin ) { | ||
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { | ||
@@ -767,4 +855,4 @@ | ||
var handler = function( event ) { | ||
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); | ||
}; | ||
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); | ||
}; | ||
@@ -774,3 +862,3 @@ jQuery.event.special[ fix ] = { | ||
var doc = this.ownerDocument || this, | ||
attaches = data_priv.access( doc, fix ); | ||
attaches = dataPriv.access( doc, fix ); | ||
@@ -780,14 +868,14 @@ if ( !attaches ) { | ||
} | ||
data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); | ||
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); | ||
}, | ||
teardown: function() { | ||
var doc = this.ownerDocument || this, | ||
attaches = data_priv.access( doc, fix ) - 1; | ||
attaches = dataPriv.access( doc, fix ) - 1; | ||
if ( !attaches ) { | ||
doc.removeEventListener( orig, handler, true ); | ||
data_priv.remove( doc, fix ); | ||
dataPriv.remove( doc, fix ); | ||
} else { | ||
data_priv.access( doc, fix, attaches ); | ||
dataPriv.access( doc, fix, attaches ); | ||
} | ||
@@ -801,57 +889,7 @@ } | ||
on: function( types, selector, data, fn, /*INTERNAL*/ one ) { | ||
var origFn, type; | ||
// Types can be a map of types/handlers | ||
if ( typeof types === "object" ) { | ||
// ( types-Object, selector, data ) | ||
if ( typeof selector !== "string" ) { | ||
// ( types-Object, data ) | ||
data = data || selector; | ||
selector = undefined; | ||
} | ||
for ( type in types ) { | ||
this.on( type, selector, data, types[ type ], one ); | ||
} | ||
return this; | ||
} | ||
if ( data == null && fn == null ) { | ||
// ( types, fn ) | ||
fn = selector; | ||
data = selector = undefined; | ||
} else if ( fn == null ) { | ||
if ( typeof selector === "string" ) { | ||
// ( types, selector, fn ) | ||
fn = data; | ||
data = undefined; | ||
} else { | ||
// ( types, data, fn ) | ||
fn = data; | ||
data = selector; | ||
selector = undefined; | ||
} | ||
} | ||
if ( fn === false ) { | ||
fn = returnFalse; | ||
} else if ( !fn ) { | ||
return this; | ||
} | ||
if ( one === 1 ) { | ||
origFn = fn; | ||
fn = function( event ) { | ||
// Can use an empty set, since event contains the info | ||
jQuery().off( event ); | ||
return origFn.apply( this, arguments ); | ||
}; | ||
// Use same guid so caller can remove using origFn | ||
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); | ||
} | ||
return this.each( function() { | ||
jQuery.event.add( this, types, fn, data, selector ); | ||
}); | ||
on: function( types, selector, data, fn ) { | ||
return on( this, types, selector, data, fn ); | ||
}, | ||
one: function( types, selector, data, fn ) { | ||
return this.on( types, selector, data, fn, 1 ); | ||
return on( this, types, selector, data, fn, 1 ); | ||
}, | ||
@@ -864,3 +902,5 @@ off: function( types, selector, fn ) { | ||
jQuery( types.delegateTarget ).off( | ||
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, | ||
handleObj.namespace ? | ||
handleObj.origType + "." + handleObj.namespace : | ||
handleObj.origType, | ||
handleObj.selector, | ||
@@ -867,0 +907,0 @@ handleObj.handler |
@@ -7,3 +7,10 @@ define([ | ||
// Attach a bunch of functions for handling common AJAX events | ||
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) { | ||
jQuery.each([ | ||
"ajaxStart", | ||
"ajaxStop", | ||
"ajaxComplete", | ||
"ajaxError", | ||
"ajaxSuccess", | ||
"ajaxSend" | ||
], function( i, type ) { | ||
jQuery.fn[ type ] = function( fn ) { | ||
@@ -10,0 +17,0 @@ return this.on( type, fn ); |
@@ -6,5 +6,6 @@ define([ | ||
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + | ||
jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " + | ||
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + | ||
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { | ||
"change select submit keydown keypress keyup contextmenu").split(" "), | ||
function( i, name ) { | ||
@@ -36,3 +37,5 @@ // Handle event binding | ||
// ( namespace ) or ( selector, types [, fn] ) | ||
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); | ||
return arguments.length === 1 ? | ||
this.off( selector, "**" ) : | ||
this.off( types, selector || "**", fn ); | ||
} | ||
@@ -39,0 +42,0 @@ }); |
@@ -5,3 +5,3 @@ define([ | ||
support.focusinBubbles = "onfocusin" in window; | ||
support.focusin = "onfocusin" in window; | ||
@@ -8,0 +8,0 @@ return support; |
@@ -1,6 +0,1 @@ | ||
define([ | ||
"../core", | ||
"../var/strundefined" | ||
], function( jQuery, strundefined ) { | ||
var | ||
@@ -28,6 +23,4 @@ // Map over jQuery in case of overwrite | ||
// and CommonJS for browser emulators (#13566) | ||
if ( typeof noGlobal === strundefined ) { | ||
if ( !noGlobal ) { | ||
window.jQuery = window.$ = jQuery; | ||
} | ||
}); |
@@ -8,3 +8,3 @@ /*! | ||
* | ||
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors | ||
* Copyright jQuery Foundation and other contributors | ||
* Released under the MIT license | ||
@@ -11,0 +11,0 @@ * http://jquery.org/license |
@@ -31,8 +31,7 @@ define([ | ||
"./deprecated", | ||
"./exports/amd", | ||
"./exports/global" | ||
"./exports/amd" | ||
], function( jQuery ) { | ||
return jQuery; | ||
return (window.jQuery = window.$ = jQuery); | ||
}); |
@@ -7,6 +7,13 @@ define([ | ||
"./manipulation/var/rcheckableType", | ||
"./manipulation/var/rtagName", | ||
"./manipulation/var/rscriptType", | ||
"./manipulation/wrapMap", | ||
"./manipulation/getAll", | ||
"./manipulation/setGlobalEval", | ||
"./manipulation/buildFragment", | ||
"./manipulation/support", | ||
"./data/var/data_priv", | ||
"./data/var/data_user", | ||
"./data/var/dataPriv", | ||
"./data/var/dataUser", | ||
"./core/init", | ||
@@ -17,44 +24,23 @@ "./data/accepts", | ||
"./event" | ||
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) { | ||
], function( jQuery, concat, push, access, | ||
rcheckableType, rtagName, rscriptType, | ||
wrapMap, getAll, setGlobalEval, buildFragment, support, | ||
dataPriv, dataUser ) { | ||
var | ||
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, | ||
rtagName = /<([\w:]+)/, | ||
rhtml = /<|&#?\w+;/, | ||
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, | ||
rnoInnerhtml = /<(?:script|style|link)/i, | ||
// checked="checked" or checked | ||
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, | ||
rscriptType = /^$|\/(?:java|ecma)script/i, | ||
rscriptTypeMasked = /^true\/(.*)/, | ||
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, | ||
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; | ||
// We have to close these tags to support XHTML (#13200) | ||
wrapMap = { | ||
function manipulationTarget( elem, content ) { | ||
if ( jQuery.nodeName( elem, "table" ) && | ||
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { | ||
// Support: IE9 | ||
option: [ 1, "<select multiple='multiple'>", "</select>" ], | ||
return elem.getElementsByTagName( "tbody" )[ 0 ] || elem; | ||
} | ||
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 ) { | ||
return jQuery.nodeName( elem, "table" ) && | ||
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? | ||
elem.getElementsByTagName("tbody")[0] || | ||
elem.appendChild( elem.ownerDocument.createElement("tbody") ) : | ||
elem; | ||
return elem; | ||
} | ||
@@ -79,14 +65,2 @@ | ||
// 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 ) { | ||
@@ -100,5 +74,5 @@ var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; | ||
// 1. Copy private data: events, handlers, etc. | ||
if ( data_priv.hasData( src ) ) { | ||
pdataOld = data_priv.access( src ); | ||
pdataCur = data_priv.set( dest, pdataOld ); | ||
if ( dataPriv.hasData( src ) ) { | ||
pdataOld = dataPriv.access( src ); | ||
pdataCur = dataPriv.set( dest, pdataOld ); | ||
events = pdataOld.events; | ||
@@ -119,20 +93,10 @@ | ||
// 2. Copy user data | ||
if ( data_user.hasData( src ) ) { | ||
udataOld = data_user.access( src ); | ||
if ( dataUser.hasData( src ) ) { | ||
udataOld = dataUser.access( src ); | ||
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 | ||
@@ -152,3 +116,116 @@ function fixInput( src, dest ) { | ||
function domManip( collection, args, callback, ignored ) { | ||
// Flatten any nested arrays | ||
args = concat.apply( [], args ); | ||
var fragment, first, scripts, hasScripts, node, doc, | ||
i = 0, | ||
l = collection.length, | ||
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 collection.each(function( index ) { | ||
var self = collection.eq( index ); | ||
if ( isFunction ) { | ||
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 (#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.1, PhantomJS<2 | ||
// 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; | ||
// 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 || "" ) && | ||
!dataPriv.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 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 && jQuery.contains( node.ownerDocument, node ) ) { | ||
setGlobalEval( getAll( node, "script" ) ); | ||
} | ||
node.parentNode.removeChild( node ); | ||
} | ||
} | ||
return elem; | ||
} | ||
jQuery.extend({ | ||
htmlPrefilter: function( html ) { | ||
return html.replace( rxhtmlTag, "<$1></$2>" ); | ||
}, | ||
clone: function( elem, dataAndEvents, deepDataAndEvents ) { | ||
@@ -196,90 +273,4 @@ var i, l, srcElements, destElements, | ||
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 ) { | ||
var data, elem, type, key, | ||
var data, elem, type, | ||
special = jQuery.event.special, | ||
@@ -289,25 +280,16 @@ i = 0; | ||
for ( ; (elem = elems[ i ]) !== undefined; i++ ) { | ||
if ( jQuery.acceptData( elem ) ) { | ||
key = elem[ data_priv.expando ]; | ||
if ( jQuery.acceptData( elem ) && (data = elem[ dataPriv.expando ])) { | ||
if ( data.events ) { | ||
for ( type in data.events ) { | ||
if ( special[ type ] ) { | ||
jQuery.event.remove( elem, type ); | ||
if ( key && (data = data_priv.cache[ key ]) ) { | ||
if ( data.events ) { | ||
for ( type in data.events ) { | ||
if ( special[ type ] ) { | ||
jQuery.event.remove( elem, type ); | ||
// This is a shortcut to avoid jQuery.event.remove's overhead | ||
} else { | ||
jQuery.removeEvent( elem, type, data.handle ); | ||
} | ||
// This is a shortcut to avoid jQuery.event.remove's overhead | ||
} else { | ||
jQuery.removeEvent( elem, type, data.handle ); | ||
} | ||
} | ||
if ( data_priv.cache[ key ] ) { | ||
// Discard any remaining `private` data | ||
delete data_priv.cache[ key ]; | ||
} | ||
} | ||
delete elem[ dataPriv.expando ]; | ||
} | ||
// Discard any remaining `user` data | ||
delete data_user.cache[ elem[ data_user.expando ] ]; | ||
} | ||
@@ -318,2 +300,10 @@ } | ||
jQuery.fn.extend({ | ||
detach: function( selector ) { | ||
return remove( this, selector, true ); | ||
}, | ||
remove: function( selector ) { | ||
return remove( this, selector ); | ||
}, | ||
text: function( value ) { | ||
@@ -332,3 +322,3 @@ return access( this, function( value ) { | ||
append: function() { | ||
return this.domManip( arguments, function( elem ) { | ||
return domManip( this, arguments, function( elem ) { | ||
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | ||
@@ -342,3 +332,3 @@ var target = manipulationTarget( this, elem ); | ||
prepend: function() { | ||
return this.domManip( arguments, function( elem ) { | ||
return domManip( this, arguments, function( elem ) { | ||
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { | ||
@@ -352,3 +342,3 @@ var target = manipulationTarget( this, elem ); | ||
before: function() { | ||
return this.domManip( arguments, function( elem ) { | ||
return domManip( this, arguments, function( elem ) { | ||
if ( this.parentNode ) { | ||
@@ -361,3 +351,3 @@ this.parentNode.insertBefore( elem, this ); | ||
after: function() { | ||
return this.domManip( arguments, function( elem ) { | ||
return domManip( this, arguments, function( elem ) { | ||
if ( this.parentNode ) { | ||
@@ -369,23 +359,2 @@ 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() { | ||
@@ -432,3 +401,3 @@ var elem, | ||
value = value.replace( rxhtmlTag, "<$1></$2>" ); | ||
value = jQuery.htmlPrefilter( value ); | ||
@@ -449,3 +418,3 @@ try { | ||
// If using innerHTML throws an exception, use the fallback method | ||
} catch( e ) {} | ||
} catch ( e ) {} | ||
} | ||
@@ -460,107 +429,17 @@ | ||
replaceWith: function() { | ||
var arg = arguments[ 0 ]; | ||
var ignored = []; | ||
// Make the changes, replacing each context element with the new content | ||
this.domManip( arguments, function( elem ) { | ||
arg = this.parentNode; | ||
// Make the changes, replacing each non-ignored context element with the new content | ||
return domManip( this, arguments, function( elem ) { | ||
var parent = this.parentNode; | ||
jQuery.cleanData( getAll( this ) ); | ||
if ( arg ) { | ||
arg.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() ); | ||
if ( jQuery.inArray( this, ignored ) < 0 ) { | ||
jQuery.cleanData( getAll( this ) ); | ||
if ( parent ) { | ||
parent.replaceChild( elem, this ); | ||
} | ||
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 ); | ||
} | ||
@@ -587,4 +466,4 @@ }); | ||
// Support: QtWebKit | ||
// .get() because push.apply(_, arraylike) throws | ||
// Support: Android<4.1, PhantomJS<2 | ||
// .get() because push.apply(_, arraylike) throws on ancient WebKit | ||
push.apply( ret, elems.get() ); | ||
@@ -591,0 +470,0 @@ } |
@@ -8,4 +8,7 @@ define([ | ||
url: url, | ||
// Make this explicit, since user can override this through ajaxSetup (#11264) | ||
type: "GET", | ||
dataType: "script", | ||
cache: true, | ||
async: false, | ||
@@ -12,0 +15,0 @@ global: false, |
define([ | ||
"../var/document", | ||
"../var/support" | ||
], function( support ) { | ||
], function( document, support ) { | ||
@@ -10,3 +11,3 @@ (function() { | ||
// Support: Safari<=5.1 | ||
// Support: Android 4.0-4.3 | ||
// Check state lost if the name is set (#11217) | ||
@@ -21,3 +22,3 @@ // Support: Windows Web Apps (WWA) | ||
// Support: Safari<=5.1, Android<4.2 | ||
// Support: Android<4.2 | ||
// Older WebKit doesn't clone checked state correctly in fragments | ||
@@ -24,0 +25,0 @@ support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
define([ | ||
"./core", | ||
"./var/strundefined", | ||
"./core/access", | ||
"./var/document", | ||
"./var/documentElement", | ||
"./css/var/rnumnonpx", | ||
@@ -13,6 +14,4 @@ "./css/curCSS", | ||
"./selector" // contains | ||
], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) { | ||
], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) { | ||
var docElem = window.document.documentElement; | ||
/** | ||
@@ -56,3 +55,5 @@ * Gets a window from an element | ||
if ( jQuery.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 ) ); | ||
} | ||
@@ -78,2 +79,3 @@ | ||
offset: function( options ) { | ||
// Preserve chaining for setter | ||
if ( arguments.length ) { | ||
@@ -87,28 +89,32 @@ return options === undefined ? | ||
var docElem, win, | ||
elem = this[ 0 ], | ||
box = { top: 0, left: 0 }, | ||
doc = elem && elem.ownerDocument; | ||
var docElem, win, rect, doc, | ||
elem = this[ 0 ]; | ||
if ( !doc ) { | ||
if ( !elem ) { | ||
return; | ||
} | ||
docElem = doc.documentElement; | ||
// Support: IE<=11+ | ||
// Running getBoundingClientRect on a | ||
// disconnected node in IE throws an error | ||
if ( !elem.getClientRects().length ) { | ||
return { top: 0, left: 0 }; | ||
} | ||
// Make sure it's not a disconnected DOM node | ||
if ( !jQuery.contains( docElem, elem ) ) { | ||
return box; | ||
rect = elem.getBoundingClientRect(); | ||
// Make sure element is not hidden (display: none) | ||
if ( rect.width || rect.height ) { | ||
doc = elem.ownerDocument; | ||
win = getWindow( doc ); | ||
docElem = doc.documentElement; | ||
return { | ||
top: rect.top + win.pageYOffset - docElem.clientTop, | ||
left: rect.left + win.pageXOffset - docElem.clientLeft | ||
}; | ||
} | ||
// Support: BlackBerry 5, iOS 3 (original iPhone) | ||
// If we don't have gBCR, just use 0,0 rather than error | ||
if ( typeof elem.getBoundingClientRect !== strundefined ) { | ||
box = elem.getBoundingClientRect(); | ||
} | ||
win = getWindow( doc ); | ||
return { | ||
top: box.top + win.pageYOffset - docElem.clientTop, | ||
left: box.left + win.pageXOffset - docElem.clientLeft | ||
}; | ||
// Return zeros for disconnected and hidden elements (gh-2310) | ||
return rect; | ||
}, | ||
@@ -125,3 +131,4 @@ | ||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent | ||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, | ||
// because it is its only offset parent | ||
if ( jQuery.css( elem, "position" ) === "fixed" ) { | ||
@@ -142,4 +149,7 @@ // Assume getBoundingClientRect is there when computed position is fixed | ||
// Add offsetParent borders | ||
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); | ||
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); | ||
// Subtract offsetParent scroll positions | ||
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) - | ||
offsetParent.scrollTop(); | ||
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) - | ||
offsetParent.scrollLeft(); | ||
} | ||
@@ -154,11 +164,21 @@ | ||
// 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() { | ||
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; | ||
} | ||
return offsetParent || docElem; | ||
return offsetParent || documentElement; | ||
}); | ||
@@ -182,4 +202,4 @@ } | ||
win.scrollTo( | ||
!top ? val : window.pageXOffset, | ||
top ? val : window.pageYOffset | ||
!top ? val : win.pageXOffset, | ||
top ? val : win.pageYOffset | ||
); | ||
@@ -186,0 +206,0 @@ |
@@ -0,1 +1,2 @@ | ||
return jQuery; | ||
})); |
define([ | ||
"./core", | ||
"./data/var/data_priv", | ||
"./data/var/dataPriv", | ||
"./deferred", | ||
"./callbacks" | ||
], function( jQuery, data_priv ) { | ||
], function( jQuery, dataPriv ) { | ||
@@ -14,3 +14,3 @@ jQuery.extend({ | ||
type = ( type || "fx" ) + "queue"; | ||
queue = data_priv.get( elem, type ); | ||
queue = dataPriv.get( elem, type ); | ||
@@ -20,3 +20,3 @@ // Speed up dequeue by getting out quickly if this is just a lookup | ||
if ( !queue || jQuery.isArray( data ) ) { | ||
queue = data_priv.access( elem, type, jQuery.makeArray(data) ); | ||
queue = dataPriv.access( elem, type, jQuery.makeArray(data) ); | ||
} else { | ||
@@ -68,5 +68,5 @@ queue.push( data ); | ||
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() { | ||
data_priv.remove( elem, [ type + "queue", key ] ); | ||
dataPriv.remove( elem, [ type + "queue", key ] ); | ||
}) | ||
@@ -133,3 +133,3 @@ }); | ||
while ( i-- ) { | ||
tmp = data_priv.get( elements[ i ], type + "queueHooks" ); | ||
tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); | ||
if ( tmp && tmp.empty ) { | ||
@@ -136,0 +136,0 @@ count++; |
@@ -8,3 +8,3 @@ define([ | ||
// Based off of the plugin by Clint Helfers, with permission. | ||
// http://blindsignals.com/index.php/2009/07/jquery-delay/ | ||
// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ | ||
jQuery.fn.delay = function( time, type ) { | ||
@@ -15,5 +15,5 @@ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; | ||
return this.queue( type, function( next, hooks ) { | ||
var timeout = setTimeout( next, time ); | ||
var timeout = window.setTimeout( next, time ); | ||
hooks.stop = function() { | ||
clearTimeout( timeout ); | ||
window.clearTimeout( timeout ); | ||
}; | ||
@@ -20,0 +20,0 @@ }); |
define([ | ||
"./core" | ||
], function( jQuery ) { | ||
"./core", | ||
"./var/document", | ||
"./var/documentElement" | ||
], function( jQuery, document, documentElement ) { | ||
@@ -30,17 +32,18 @@ /* | ||
var docElem = window.document.documentElement, | ||
selector_hasDuplicate, | ||
matches = docElem.matches || | ||
docElem.webkitMatchesSelector || | ||
docElem.mozMatchesSelector || | ||
docElem.oMatchesSelector || | ||
docElem.msMatchesSelector, | ||
selector_sortOrder = function( a, b ) { | ||
var hasDuplicate, | ||
matches = documentElement.matches || | ||
documentElement.webkitMatchesSelector || | ||
documentElement.mozMatchesSelector || | ||
documentElement.oMatchesSelector || | ||
documentElement.msMatchesSelector, | ||
sortOrder = function( a, b ) { | ||
// Flag for duplicate removal | ||
if ( a === b ) { | ||
selector_hasDuplicate = true; | ||
hasDuplicate = true; | ||
return 0; | ||
} | ||
var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); | ||
var compare = b.compareDocumentPosition && | ||
a.compareDocumentPosition && | ||
a.compareDocumentPosition( b ); | ||
@@ -106,6 +109,6 @@ if ( compare ) { | ||
selector_hasDuplicate = false; | ||
results.sort( selector_sortOrder ); | ||
hasDuplicate = false; | ||
results.sort( sortOrder ); | ||
if ( selector_hasDuplicate ) { | ||
if ( hasDuplicate ) { | ||
while ( (elem = results[i++]) ) { | ||
@@ -156,3 +159,4 @@ if ( elem === results[ i ] ) { | ||
match: { | ||
bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i, | ||
bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" + | ||
"|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ), | ||
needsContext: /^[\x20\t\r\n\f]*[>+~]/ | ||
@@ -159,0 +163,0 @@ } |
@@ -9,3 +9,3 @@ define([ | ||
jQuery.expr[":"] = jQuery.expr.pseudos; | ||
jQuery.unique = Sizzle.uniqueSort; | ||
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; | ||
jQuery.text = Sizzle.getText; | ||
@@ -12,0 +12,0 @@ jQuery.isXMLDoc = Sizzle.isXML; |
@@ -1,1 +0,1 @@ | ||
define([ "./selector-sizzle" ]); | ||
define([ "./selector-sizzle" ], function() {}); |
@@ -27,3 +27,8 @@ define([ | ||
// Item is non-scalar (array or object), encode its numeric index. | ||
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); | ||
buildParams( | ||
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", | ||
v, | ||
traditional, | ||
add | ||
); | ||
} | ||
@@ -30,0 +35,0 @@ }); |
@@ -88,3 +88,3 @@ define([ | ||
return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); | ||
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); | ||
}, | ||
@@ -115,3 +115,3 @@ | ||
return this.pushStack( | ||
jQuery.unique( | ||
jQuery.uniqueSort( | ||
jQuery.merge( this.get(), jQuery( selector, context ) ) | ||
@@ -187,3 +187,3 @@ ) | ||
if ( !guaranteedUnique[ name ] ) { | ||
jQuery.unique( matched ); | ||
jQuery.uniqueSort( matched ); | ||
} | ||
@@ -190,0 +190,0 @@ |
@@ -36,3 +36,3 @@ define([ | ||
return jQuery.grep( elements, function( elem ) { | ||
return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; | ||
return ( indexOf.call( qualifier, elem ) > -1 ) !== not; | ||
}); | ||
@@ -76,6 +76,3 @@ } | ||
// Needed because $( selector, context ) becomes $( context ).find( selector ) | ||
ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); | ||
ret.selector = this.selector ? this.selector + " " + selector : selector; | ||
return ret; | ||
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret ); | ||
}, | ||
@@ -82,0 +79,0 @@ filter: function( selector ) { |
@@ -12,9 +12,6 @@ define([ | ||
if ( jQuery.isFunction( html ) ) { | ||
return this.each(function( i ) { | ||
jQuery( this ).wrapAll( html.call(this, i) ); | ||
}); | ||
} | ||
if ( this[ 0 ] ) { | ||
if ( jQuery.isFunction( html ) ) { | ||
html = html.call( this[ 0 ] ); | ||
} | ||
@@ -70,8 +67,7 @@ // The elements to wrap the target around | ||
unwrap: function() { | ||
return this.parent().each(function() { | ||
if ( !jQuery.nodeName( this, "body" ) ) { | ||
jQuery( this ).replaceWith( this.childNodes ); | ||
} | ||
}).end(); | ||
unwrap: function( selector ) { | ||
this.parent( selector ).not( "body" ).each(function() { | ||
jQuery( this ).replaceWith( this.childNodes ); | ||
}); | ||
return this; | ||
} | ||
@@ -78,0 +74,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
691048
24
101
1
15186
1
6