├── .gitattributes
├── .gitignore
├── .gitmodules
├── GPL-LICENSE.txt
├── MIT-LICENSE.txt
├── Makefile
├── README.md
├── build
├── freq.js
├── jslint-check.js
├── lib
│ ├── jslint.js
│ ├── parse-js.js
│ ├── process.js
│ └── squeeze-more.js
├── post-compile.js
├── release-notes.js
├── release-notes.txt
├── release.js
├── sizer.js
└── uglify.js
├── speed
├── benchmark.js
├── benchmarker.css
├── benchmarker.js
├── closest.html
├── css.html
├── event.html
├── filter.html
├── find.html
├── index.html
├── jquery-basis.js
└── slice.vs.concat.html
├── src
├── ajax.js
├── ajax
│ ├── jsonp.js
│ ├── script.js
│ └── xhr.js
├── attributes.js
├── callbacks.js
├── core.js
├── css.js
├── data.js
├── deferred.js
├── dimensions.js
├── effects.js
├── event.js
├── intro.js
├── manipulation.js
├── offset.js
├── outro.js
├── queue.js
├── sizzle-jquery.js
├── support.js
└── traversing.js
├── test
├── csp.php
├── data
│ ├── atom+xml.php
│ ├── badjson.js
│ ├── dashboard.xml
│ ├── echoData.php
│ ├── echoQuery.php
│ ├── errorWithText.php
│ ├── etag.php
│ ├── headers.php
│ ├── if_modified_since.php
│ ├── iframe.html
│ ├── json.php
│ ├── json_obj.js
│ ├── jsonp.php
│ ├── name.html
│ ├── name.php
│ ├── offset
│ │ ├── absolute.html
│ │ ├── body.html
│ │ ├── fixed.html
│ │ ├── relative.html
│ │ ├── scroll.html
│ │ ├── static.html
│ │ └── table.html
│ ├── params_html.php
│ ├── readywaitasset.js
│ ├── readywaitloader.js
│ ├── script.php
│ ├── selector.html
│ ├── statusText.php
│ ├── support
│ │ ├── bodyBackground.html
│ │ ├── boxModelIE.html
│ │ ├── hiddenIFrameFF.html
│ │ └── testElementCrash.html
│ ├── test.html
│ ├── test.js
│ ├── test.php
│ ├── test2.html
│ ├── test3.html
│ ├── testinit.js
│ ├── testrunner.js
│ ├── testsuite.css
│ ├── text.php
│ ├── ua.txt
│ ├── versioncheck.js
│ ├── with_fries.xml
│ └── with_fries_over_jsonp.php
├── delegatetest.html
├── hovertest.html
├── index.html
├── localfile.html
├── networkerror.html
├── polluted.php
├── readywait.html
├── unit
│ ├── ajax.js
│ ├── attributes.js
│ ├── callbacks.js
│ ├── core.js
│ ├── css.js
│ ├── data.js
│ ├── deferred.js
│ ├── dimensions.js
│ ├── effects.js
│ ├── event.js
│ ├── manipulation.js
│ ├── offset.js
│ ├── queue.js
│ ├── selector.js
│ ├── support.js
│ └── traversing.js
└── xhtml.php
└── version.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | * eol=lf
2 | *.jar binary
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | src/selector.js
2 | dist
3 | .project
4 | .settings
5 | *~
6 | *.diff
7 | *.patch
8 | /*.html
9 | .DS_Store
10 | build/.sizecache.json
11 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "src/sizzle"]
2 | path = src/sizzle
3 | url = git://github.com/jquery/sizzle.git
4 | [submodule "test/qunit"]
5 | path = test/qunit
6 | url = git://github.com/jquery/qunit.git
7 |
--------------------------------------------------------------------------------
/MIT-LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 John Resig, http://jquery.com/
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SRC_DIR = src
2 | TEST_DIR = test
3 | BUILD_DIR = build
4 |
5 | PREFIX = .
6 | DIST_DIR = ${PREFIX}/dist
7 |
8 | JS_ENGINE ?= `which node nodejs`
9 | COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
10 | POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
11 |
12 | BASE_FILES = ${SRC_DIR}/core.js\
13 | ${SRC_DIR}/callbacks.js\
14 | ${SRC_DIR}/deferred.js\
15 | ${SRC_DIR}/support.js\
16 | ${SRC_DIR}/data.js\
17 | ${SRC_DIR}/queue.js\
18 | ${SRC_DIR}/attributes.js\
19 | ${SRC_DIR}/event.js\
20 | ${SRC_DIR}/selector.js\
21 | ${SRC_DIR}/traversing.js\
22 | ${SRC_DIR}/manipulation.js\
23 | ${SRC_DIR}/css.js\
24 | ${SRC_DIR}/ajax.js\
25 | ${SRC_DIR}/ajax/jsonp.js\
26 | ${SRC_DIR}/ajax/script.js\
27 | ${SRC_DIR}/ajax/xhr.js\
28 | ${SRC_DIR}/effects.js\
29 | ${SRC_DIR}/offset.js\
30 | ${SRC_DIR}/dimensions.js
31 |
32 | MODULES = ${SRC_DIR}/intro.js\
33 | ${BASE_FILES}\
34 | ${SRC_DIR}/outro.js
35 |
36 | JQ = ${DIST_DIR}/jquery.js
37 | JQ_MIN = ${DIST_DIR}/jquery.min.js
38 |
39 | SIZZLE_DIR = ${SRC_DIR}/sizzle
40 |
41 | JQ_VER = $(shell cat version.txt)
42 | VER = sed "s/@VERSION/${JQ_VER}/"
43 |
44 | DATE=$(shell git log -1 --pretty=format:%ad)
45 |
46 | all: update_submodules core
47 |
48 | core: jquery min lint size
49 | @@echo "jQuery build complete."
50 |
51 | ${DIST_DIR}:
52 | @@mkdir -p ${DIST_DIR}
53 |
54 | jquery: ${JQ}
55 |
56 | ${JQ}: ${MODULES} | ${DIST_DIR}
57 | @@echo "Building" ${JQ}
58 |
59 | @@cat ${MODULES} | \
60 | sed 's/.function..jQuery...{//' | \
61 | sed 's/}...jQuery..;//' | \
62 | sed 's/@DATE/'"${DATE}"'/' | \
63 | ${VER} > ${JQ};
64 |
65 | ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
66 | @@echo "Building selector code from Sizzle"
67 | @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
68 |
69 | lint: jquery
70 | @@if test ! -z ${JS_ENGINE}; then \
71 | echo "Checking jQuery against JSLint..."; \
72 | ${JS_ENGINE} build/jslint-check.js; \
73 | else \
74 | echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
75 | fi
76 |
77 | size: jquery min
78 | @@if test ! -z ${JS_ENGINE}; then \
79 | gzip -c ${JQ_MIN} > ${JQ_MIN}.gz; \
80 | wc -c ${JQ} ${JQ_MIN} ${JQ_MIN}.gz | ${JS_ENGINE} ${BUILD_DIR}/sizer.js; \
81 | rm ${JQ_MIN}.gz; \
82 | else \
83 | echo "You must have NodeJS installed in order to size jQuery."; \
84 | fi
85 |
86 | freq: jquery min
87 | @@if test ! -z ${JS_ENGINE}; then \
88 | ${JS_ENGINE} ${BUILD_DIR}/freq.js; \
89 | else \
90 | echo "You must have NodeJS installed to report the character frequency of minified jQuery."; \
91 | fi
92 |
93 | min: jquery ${JQ_MIN}
94 |
95 | ${JQ_MIN}: ${JQ}
96 | @@if test ! -z ${JS_ENGINE}; then \
97 | echo "Minifying jQuery" ${JQ_MIN}; \
98 | ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
99 | ${POST_COMPILER} ${JQ_MIN}.tmp > ${JQ_MIN}; \
100 | rm -f ${JQ_MIN}.tmp; \
101 | else \
102 | echo "You must have NodeJS installed in order to minify jQuery."; \
103 | fi
104 |
105 | clean:
106 | @@echo "Removing Distribution directory:" ${DIST_DIR}
107 | @@rm -rf ${DIST_DIR}
108 |
109 | @@echo "Removing built copy of Sizzle"
110 | @@rm -f src/selector.js
111 |
112 | distclean: clean
113 | @@echo "Removing submodules"
114 | @@rm -rf test/qunit src/sizzle
115 |
116 | # change pointers for submodules and update them to what is specified in jQuery
117 | # --merge doesn't work when doing an initial clone, thus test if we have non-existing
118 | # submodules, then do an real update
119 | update_submodules:
120 | @@if [ -d .git ]; then \
121 | if git submodule status | grep -q -E '^-'; then \
122 | git submodule update --init --recursive; \
123 | else \
124 | git submodule update --init --recursive --merge; \
125 | fi; \
126 | fi;
127 |
128 | # update the submodules to the latest at the most logical branch
129 | pull_submodules:
130 | @@git submodule foreach "git pull \$$(git config remote.origin.url)"
131 | @@git submodule summary
132 |
133 | pull: pull_submodules
134 | @@git pull ${REMOTE} ${BRANCH}
135 |
136 | .PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core
137 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [jQuery](http://jquery.com/) - New Wave JavaScript
2 | ==================================================
3 |
4 | What you need to build your own jQuery
5 | --------------------------------------
6 |
7 | In order to build jQuery, you need to have GNU make 3.8 or later, Node.js 0.2 or later, and git 1.7 or later.
8 | (Earlier versions might work OK, but are not tested.)
9 |
10 | Windows users have two options:
11 |
12 | 1. Install [msysgit](https://code.google.com/p/msysgit/) (Full installer for official Git),
13 | [GNU make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm), and a
14 | [binary version of Node.js](http://node-js.prcn.co.cc/). Make sure all three packages are installed to the same
15 | location (by default, this is C:\Program Files\Git).
16 | 2. Install [Cygwin](http://cygwin.com/) (make sure you install the git, make, and which packages), then either follow
17 | the [Node.js build instructions](https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29) or install
18 | the [binary version of Node.js](http://node-js.prcn.co.cc/).
19 |
20 | Mac OS users should install Xcode (comes on your Mac OS install DVD, or downloadable from
21 | [Apple's Xcode site](http://developer.apple.com/technologies/xcode.html)) and
22 | [http://mxcl.github.com/homebrew/](Homebrew). Once Homebrew is installed, run `brew install git` to install git,
23 | and `brew install node` to install Node.js.
24 |
25 | Linux/BSD users should use their appropriate package managers to install make, git, and node, or build from source
26 | if you swing that way. Easy-peasy.
27 |
28 |
29 | How to build your own jQuery
30 | ----------------------------
31 |
32 | First, clone a copy of the main jQuery git repo by running `git clone git://github.com/jquery/jquery.git`.
33 |
34 | Then, to get a complete, minified, jslinted version of jQuery, simply `cd` to the `jquery` directory and type
35 | `make`. If you don't have Node installed and/or want to make a basic, uncompressed, unlinted version of jQuery, use
36 | `make jquery` instead of `make`.
37 |
38 | The built version of jQuery will be put in the `dist/` subdirectory.
39 |
40 | To remove all built files, run `make clean`.
41 |
42 |
43 | Building to a different directory
44 | ---------------------------------
45 |
46 | If you want to build jQuery to a directory that is different from the default location, you can specify the PREFIX
47 | directory: `make PREFIX=/home/jquery/test/ [command]`
48 |
49 | With this example, the output files would end up in `/home/jquery/test/dist/`.
50 |
51 |
52 | Troubleshooting
53 | ---------------
54 |
55 | Sometimes, the various git repositories get into an inconsistent state where builds don't complete properly
56 | (usually this results in the jquery.js or jquery.min.js being 0 bytes). If this happens, run `make clean`, then
57 | run `make` again.
58 |
59 | Git for dummies
60 | ---------------
61 |
62 | As the source code is handled by the version control system Git, it's useful to know some features used.
63 |
64 | ### Submodules ###
65 |
66 | The repository uses submodules, which normally are handled directly by the Makefile, but sometimes you want to
67 | be able to work with them manually.
68 |
69 | Following are the steps to manually get the submodules:
70 |
71 | 1. `git clone https://github.com/jquery/jquery.git`
72 | 2. `git submodule init`
73 | 3. `git submodule update`
74 |
75 | Or:
76 |
77 | 1. `git clone https://github.com/jquery/jquery.git`
78 | 2. `git submodule update --init`
79 |
80 | Or:
81 |
82 | 1. `git clone --recursive https://github.com/jquery/jquery.git`
83 |
84 | If you want to work inside a submodule, it is possible, but first you need to checkout a branch:
85 |
86 | 1. `cd src/sizzle`
87 | 2. `git checkout master`
88 |
89 | After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
90 | but remember to push the submodule changes before pushing the new jquery commit:
91 |
92 | 1. `cd src/sizzle`
93 | 2. `git push origin master`
94 | 3. `cd ..`
95 | 4. `git add src/sizzle`
96 | 5. `git commit`
97 |
98 | The makefile has some targets to simplify submodule handling:
99 |
100 | #### `make update_submodules` ####
101 |
102 | checks out the commit pointed to by jquery, but merges your local changes, if any. This target is executed
103 | when you are doing a normal `make`.
104 |
105 | #### `make pull_submodules` ####
106 |
107 | updates the content of the submodules to what is probably the latest upstream code.
108 |
109 | #### `make pull` ####
110 |
111 | make a `make pull_submodules` and after that a `git pull`. if you have no remote tracking in your master branch, you can
112 | execute this command as `make pull REMOTE=origin BRANCH=master` instead.
113 |
114 | ### cleaning ###
115 |
116 | 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):
117 |
118 | 1. `git reset --hard upstream/master`
119 | 2. `git clean -fdx`
120 |
121 | ### rebasing ###
122 |
123 | For feature/topic branches, you should always used 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:
124 |
125 | * `git config branch.autosetuprebase local` (see `man git-config` for more information)
126 |
127 | ### handling merge conflicts ###
128 |
129 | If you're getting merge conflicts when merging, instead of editing the conflicted files manually, you can use the feature
130 | `git mergetool`. Even though the default tool `xxdiff` looks awful/old, it's rather useful.
131 |
132 | Following are some commands that can be used there:
133 |
134 | * `Ctrl + Alt + M` - automerge as much as possible
135 | * `b` - jump to next merge conflict
136 | * `s` - change the order of the conflicted lines
137 | * `u` - undo an merge
138 | * `left mouse button` - mark a block to be the winner
139 | * `middle mouse button` - mark a line to be the winner
140 | * `Ctrl + S` - save
141 | * `Ctrl + Q` - quit
142 |
143 | Questions?
144 | ----------
145 |
146 | If you have any questions, please feel free to ask on the
147 | [Developing jQuery Core forum](http://forum.jquery.com/developing-jquery-core) or in #jquery on irc.freenode.net.
148 |
--------------------------------------------------------------------------------
/build/freq.js:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env node
2 |
3 | var fs = require( "fs" );
4 |
5 | function isEmptyObject( obj ) {
6 | for ( var name in obj ) {
7 | return false;
8 | }
9 | return true;
10 | }
11 | function extend( obj ) {
12 | var dest = obj,
13 | src = [].slice.call( arguments, 1 );
14 |
15 | Object.keys( src ).forEach(function( key ) {
16 | var copy = src[ key ];
17 |
18 | for ( var prop in copy ) {
19 | dest[ prop ] = copy[ prop ];
20 | }
21 | });
22 |
23 | return dest;
24 | };
25 |
26 | function charSort( obj, callback ) {
27 |
28 | var ordered = [],
29 | table = {},
30 | copied;
31 |
32 | copied = extend({}, obj );
33 |
34 | (function order() {
35 |
36 | var largest = 0,
37 | c;
38 |
39 | for ( var i in obj ) {
40 | if ( obj[ i ] >= largest ) {
41 | largest = obj[ i ];
42 | c = i;
43 | }
44 | }
45 |
46 | ordered.push( c );
47 | delete obj[ c ];
48 |
49 | if ( !isEmptyObject( obj ) ) {
50 | order();
51 | } else {
52 | ordered.forEach(function( val ) {
53 | table[ val ] = copied[ val ];
54 | });
55 |
56 | callback( table );
57 | }
58 |
59 | })();
60 | }
61 | function charFrequency( src, callback ) {
62 | var obj = {};
63 |
64 | src.replace(/[^\w]|\d/gi, "").split("").forEach(function( c ) {
65 | obj[ c ] ? ++obj[ c ] : ( obj[ c ] = 1 );
66 | });
67 |
68 | return charSort( obj, callback );
69 | }
70 |
71 |
72 | charFrequency( fs.readFileSync( "dist/jquery.min.js", "utf8" ), function( obj ) {
73 | var chr;
74 |
75 | for ( chr in obj ) {
76 | console.log( " " + chr + " " + obj[ chr ] );
77 | }
78 | });
79 |
80 |
--------------------------------------------------------------------------------
/build/jslint-check.js:
--------------------------------------------------------------------------------
1 | var JSLINT = require("./lib/jslint").JSLINT,
2 | print = require("sys").print,
3 | src = require("fs").readFileSync("dist/jquery.js", "utf8");
4 |
5 | JSLINT(src, { evil: true, forin: true, maxerr: 100 });
6 |
7 | // All of the following are known issues that we think are 'ok'
8 | // (in contradiction with JSLint) more information here:
9 | // http://docs.jquery.com/JQuery_Core_Style_Guidelines
10 | var ok = {
11 | "Expected an identifier and instead saw 'undefined' (a reserved word).": true,
12 | "Use '===' to compare with 'null'.": true,
13 | "Use '!==' to compare with 'null'.": true,
14 | "Expected an assignment or function call and instead saw an expression.": true,
15 | "Expected a 'break' statement before 'case'.": true,
16 | "'e' is already defined.": true
17 | };
18 |
19 | var e = JSLINT.errors, found = 0, w;
20 |
21 | for ( var i = 0; i < e.length; i++ ) {
22 | w = e[i];
23 |
24 | if ( !ok[ w.reason ] ) {
25 | found++;
26 | print( "\n" + w.evidence + "\n" );
27 | print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
28 | }
29 | }
30 |
31 | if ( found > 0 ) {
32 | print( "\n" + found + " Error(s) found.\n" );
33 |
34 | } else {
35 | print( "JSLint check passed.\n" );
36 | }
37 |
--------------------------------------------------------------------------------
/build/lib/squeeze-more.js:
--------------------------------------------------------------------------------
1 | var jsp = require("./parse-js"),
2 | pro = require("./process"),
3 | slice = jsp.slice,
4 | member = jsp.member,
5 | PRECEDENCE = jsp.PRECEDENCE,
6 | OPERATORS = jsp.OPERATORS;
7 |
8 | function ast_squeeze_more(ast) {
9 | var w = pro.ast_walker(), walk = w.walk;
10 | return w.with_walkers({
11 | "call": function(expr, args) {
12 | if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
13 | // foo.toString() ==> foo+""
14 | return [ "binary", "+", expr[1], [ "string", "" ]];
15 | }
16 | }
17 | }, function() {
18 | return walk(ast);
19 | });
20 | };
21 |
22 | exports.ast_squeeze_more = ast_squeeze_more;
23 |
--------------------------------------------------------------------------------
/build/post-compile.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var print = require( "sys" ).print,
4 | fs = require( "fs" ),
5 | src = fs.readFileSync( process.argv[2], "utf8" ),
6 | version = fs.readFileSync( "version.txt", "utf8" ),
7 | // License Template
8 | license = "/*! jQuery v@VERSION http://jquery.com/ | http://jquery.org/license */";
9 |
10 |
11 | // Previously done in sed but reimplemented here due to portability issues
12 | src = src.replace( /^(\s*\*\/)(.+)/m, "$1\n$2" ) + ";";
13 |
14 | // Set minimal license block var
15 | license = license.replace( "@VERSION", version );
16 |
17 | // Replace license block with minimal license
18 | src = src.replace( /\/\/.*?\/?\*.+?(?=\n|\r|$)|\/\*[\s\S]*?\/\/[\s\S]*?\*\//, license );
19 |
20 | print( src );
21 |
--------------------------------------------------------------------------------
/build/release-notes.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * jQuery Release Note Generator
4 | */
5 |
6 | var fs = require("fs"),
7 | http = require("http"),
8 | tmpl = require("mustache"),
9 | extract = /(.*?)<[^"]+"component">\s*(\S+)/g;
10 |
11 | var opts = {
12 | version: "1.6.3 RC 1",
13 | short_version: "1.6.3rc1",
14 | final_version: "1.6.3",
15 | categories: []
16 | };
17 |
18 | http.request({
19 | host: "bugs.jquery.com",
20 | port: 80,
21 | method: "GET",
22 | path: "/query?status=closed&resolution=fixed&component=!web&order=component&milestone=" + opts.final_version
23 | }, function (res) {
24 | var data = [];
25 |
26 | res.on( "data", function( chunk ) {
27 | data.push( chunk );
28 | });
29 |
30 | res.on( "end", function() {
31 | var match,
32 | file = data.join(""),
33 | cur;
34 |
35 | while ( (match = extract.exec( file )) ) {
36 | if ( "#" + match[1] !== match[2] ) {
37 | var cat = match[3];
38 |
39 | if ( !cur || cur.name !== cat ) {
40 | cur = { name: match[3], niceName: match[3].replace(/^./, function(a){ return a.toUpperCase(); }), bugs: [] };
41 | opts.categories.push( cur );
42 | }
43 |
44 | cur.bugs.push({ ticket: match[1], title: match[2] });
45 | }
46 | }
47 |
48 | buildNotes();
49 | });
50 | }).end();
51 |
52 | function buildNotes() {
53 | console.log( tmpl.to_html( fs.readFileSync("release-notes.txt", "utf8"), opts ) );
54 | }
55 |
--------------------------------------------------------------------------------
/build/release-notes.txt:
--------------------------------------------------------------------------------
1 | jQuery {{version}} Released
2 |
3 | This is a preview release of jQuery. We're releasing it so that everyone can start testing the code in their applications, making sure that there are no major problems.
4 |
5 | You can get the code from the jQuery CDN:
6 |
7 |
10 |
11 | You can help us by dropping that code into your existing application and letting us know that if anything no longer works. Please file a bug and be sure to mention that you're testing against jQuery {{version}}.
12 |
13 | We want to encourage everyone from the community to try and get involved in contributing back to jQuery core. We've set up a full page of information dedicated towards becoming more involved with the team. The team is here and ready to help you help us!
14 |
15 | jQuery {{version}} Change Log
16 |
17 | The current change log of the {{version}} release.
18 |
19 | {{#categories}}
20 | {{niceName}}
21 |
22 |
23 | {{#bugs}}
24 | #{{ticket}} : {{title}}
25 | {{/bugs}}
26 |
27 | {{/categories}}
28 |
--------------------------------------------------------------------------------
/build/release.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | /*
3 | * jQuery Release Management
4 | */
5 |
6 | var fs = require("fs"),
7 | child = require("child_process"),
8 | debug = false;
9 |
10 | var scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/",
11 | cdnURL = "http://code.origin.jquery.com/",
12 |
13 | version = /^[\d.]+(?:(?:a|b|rc)\d+|pre)?$/,
14 | versionFile = "version.txt",
15 |
16 | file = "dist/jquery.js",
17 | minFile = "dist/jquery.min.js",
18 |
19 | files = {
20 | "jquery-VER.js": file,
21 | "jquery-VER.min.js": minFile
22 | },
23 |
24 | finalFiles = {
25 | "jquery.js": file,
26 | "jquery-latest.js": file,
27 | "jquery.min.js": minFile,
28 | "jquery-latest.min.js": minFile
29 | };
30 |
31 | exec( "git pull && git status", function( error, stdout, stderr ) {
32 | if ( /Changes to be committed/i.test( stdout ) ) {
33 | exit( "Please commit changed files before attemping to push a release." );
34 |
35 | } else if ( /Changes not staged for commit/i.test( stdout ) ) {
36 | exit( "Please stash files before attempting to push a release." );
37 |
38 | } else {
39 | setVersion();
40 | }
41 | });
42 |
43 | function setVersion() {
44 | var oldVersion = fs.readFileSync( versionFile, "utf8" );
45 |
46 | prompt( "New Version (was " + oldVersion + "): ", function( data ) {
47 | if ( data && version.test( data ) ) {
48 | fs.writeFileSync( versionFile, data );
49 |
50 | exec( "git commit -a -m 'Tagging the " + data + " release.' && git push && " +
51 | "git tag " + data + " && git push origin " + data, function() {
52 | make( data );
53 | });
54 |
55 | } else {
56 | console.error( "Malformed version number, please try again." );
57 | setVersion();
58 | }
59 | });
60 | }
61 |
62 | function make( newVersion ) {
63 | exec( "make clean && make", function( error, stdout, stderr ) {
64 | // TODO: Verify JSLint
65 |
66 | Object.keys( files ).forEach(function( oldName ) {
67 | var value = files[ oldName ], name = oldName.replace( /VER/g, newVersion );
68 |
69 | copy( value, name );
70 |
71 | delete files[ oldName ];
72 | files[ name ] = value;
73 | });
74 |
75 | exec( "scp " + Object.keys( files ).join( " " ) + " " + scpURL, function() {
76 | setNextVersion( newVersion );
77 | });
78 | });
79 | }
80 |
81 | function setNextVersion( newVersion ) {
82 | var isFinal = false;
83 |
84 | if ( /(?:a|b|rc)\d+$/.test( newVersion ) ) {
85 | newVersion = newVersion.replace( /(?:a|b|rc)\d+$/, "pre" );
86 |
87 | } else if ( /^\d+\.\d+\.?(\d*)$/.test( newVersion ) ) {
88 | newVersion = newVersion.replace( /^(\d+\.\d+\.?)(\d*)$/, function( all, pre, num ) {
89 | return pre + (pre.charAt( pre.length - 1 ) !== "." ? "." : "") + (num ? parseFloat( num ) + 1 : 1) + "pre";
90 | });
91 |
92 | isFinal = true;
93 | }
94 |
95 | prompt( "Next Version [" + newVersion + "]: ", function( data ) {
96 | if ( !data ) {
97 | data = newVersion;
98 | }
99 |
100 | if ( version.test( data ) ) {
101 | fs.writeFileSync( versionFile, data );
102 |
103 | exec( "git commit -a -m 'Updating the source version to " + data + "' && git push", function() {
104 | if ( isFinal ) {
105 | makeFinal( newVersion );
106 | }
107 | });
108 |
109 | } else {
110 | console.error( "Malformed version number, please try again." );
111 | setNextVersion( newVersion );
112 | }
113 | });
114 | }
115 |
116 | function makeFinal( newVersion ) {
117 | var all = Object.keys( finalFiles );
118 |
119 | // Copy all the files
120 | all.forEach(function( name ) {
121 | copy( finalFiles[ name ], name );
122 | });
123 |
124 | // Upload files to CDN
125 | exec( "scp " + all.join( " " ) + " " + scpURL, function() {
126 | exec( "curl '" + cdnURL + "{" + all.join( "," ) + "}?reload'", function() {
127 | console.log( "Done." );
128 | });
129 | });
130 | }
131 |
132 | function copy( oldFile, newFile ) {
133 | if ( debug ) {
134 | console.log( "Copying " + oldFile + " to " + newFile );
135 |
136 | } else {
137 | fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
138 | }
139 | }
140 |
141 | function prompt( msg, callback ) {
142 | process.stdout.write( msg );
143 |
144 | process.stdin.resume();
145 | process.stdin.setEncoding( "utf8" );
146 |
147 | process.stdin.once( "data", function( chunk ) {
148 | process.stdin.pause();
149 | callback( chunk.replace( /\n*$/g, "" ) );
150 | });
151 | }
152 |
153 | function exec( cmd, fn ) {
154 | if ( debug ) {
155 | console.log( cmd );
156 | fn();
157 |
158 | } else {
159 | child.exec( cmd, fn );
160 | }
161 | }
162 |
163 | function exit( msg ) {
164 | if ( msg ) {
165 | console.error( "\nError: " + msg );
166 | }
167 |
168 | process.exit( 1 );
169 | }
170 |
--------------------------------------------------------------------------------
/build/sizer.js:
--------------------------------------------------------------------------------
1 | var fs = require( "fs" ),
2 | stdin = process.openStdin(),
3 | rsize = /(\d+).*?(jquery\S+)/g,
4 | oldsizes = {},
5 | sizes = {};
6 |
7 | try {
8 | oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) );
9 | } catch(e) {
10 | oldsizes = {};
11 | };
12 |
13 | stdin.on( "data" , function( chunk ) {
14 | var match;
15 |
16 | while ( match = rsize.exec( chunk ) ) {
17 | sizes[ match[2] ] = parseInt( match[1], 10 );
18 | }
19 | });
20 |
21 | function lpad( str, len, chr ) {
22 | return ( Array(len+1).join( chr || " ") + str ).substr( -len );
23 | }
24 |
25 | stdin.on( "end", function() {
26 | console.log( "jQuery Size - compared to last make" );
27 | fs.writeFileSync( __dirname + "/.sizecache.json", JSON.stringify( sizes, true ), "utf8" );
28 | for ( var key in sizes ) {
29 | var diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
30 | if ( diff > 0 ) {
31 | diff = "+" + diff;
32 | }
33 | console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( diff ? "(" + diff + ")" : "(-)", 8 ), key );
34 | }
35 | process.exit();
36 | });
--------------------------------------------------------------------------------
/speed/benchmark.js:
--------------------------------------------------------------------------------
1 | // Runs a function many times without the function call overhead
2 | function benchmark(fn, times, name){
3 | fn = fn.toString();
4 | var s = fn.indexOf('{')+1,
5 | e = fn.lastIndexOf('}');
6 | fn = fn.substring(s,e);
7 |
8 | return benchmarkString(fn, times, name);
9 | }
10 |
11 | function benchmarkString(fn, times, name) {
12 | var fn = new Function("i", "var t=new Date; while(i--) {" + fn + "}; return new Date - t")(times)
13 | fn.displayName = name || "benchmarked";
14 | return fn;
15 | }
16 |
--------------------------------------------------------------------------------
/speed/benchmarker.css:
--------------------------------------------------------------------------------
1 |
2 | .dialog {
3 | margin-bottom: 1em;
4 | }
5 | a.expand {
6 | background: #e3e3e3;
7 | }
8 |
9 | div#time-test {
10 | font-family: Arial, Helvetica, sans-serif;
11 | font-size: 62.5%;
12 | }
13 |
14 | td.test button {
15 | float: right;
16 | }
17 |
18 | table {
19 | border: 1px solid #000;
20 | }
21 |
22 | table td, table th {
23 | border: 1px solid #000;
24 | padding: 10px;
25 | }
26 |
27 | td.winner {
28 | background-color: #cfc;
29 | }
30 |
31 | td.tie {
32 | background-color: #ffc;
33 | }
34 |
35 | td.fail {
36 | background-color: #f99;
37 | font-weight: bold;
38 | text-align: center;
39 | }
40 |
41 | tfoot td {
42 | text-align: center;
43 | }
44 |
45 | #time-test {
46 | margin: 1em 0;
47 | padding: .5em;
48 | background: #e3e3e3;
49 | }
50 | #time-taken {
51 | font-weight: bold;
52 | }
53 |
54 | span.wins {
55 | color: #330;
56 | }
57 |
58 | span.fails {
59 | color: #900;
60 | }
61 |
62 | div.buttons {
63 | margin-top: 10px;
64 | margin-bottom: 10px;
65 | }
--------------------------------------------------------------------------------
/speed/benchmarker.js:
--------------------------------------------------------------------------------
1 | jQuery.benchmarker.tests = [
2 | // Selectors from:
3 | // http://ejohn.org/blog/selectors-that-people-actually-use/
4 | /*
5 | // For Amazon.com
6 | "#navAmazonLogo", "#navSwmSkedPop",
7 | ".navbar", ".navGreeting",
8 | "div", "table",
9 | "img.navCrossshopTabCap", "span.navGreeting",
10 | "#navbar table", "#navidWelcomeMsg span",
11 | "div#navbar", "ul#navAmazonLogo",
12 | "#navAmazonLogo .navAmazonLogoGatewayPanel", "#navidWelcomeMsg .navGreeting",
13 | ".navbar .navAmazonLogoGatewayPanel", ".navbar .navGreeting",
14 | "*",
15 | "#navAmazonLogo li.navAmazonLogoGatewayPanel", "#navidWelcomeMsg span.navGreeting",
16 | "a[name=top]", "form[name=site-search]",
17 | ".navbar li", ".navbar span",
18 | "[name=top]", "[name=site-search]",
19 | "ul li", "a img",
20 | "#navbar #navidWelcomeMsg", "#navbar #navSwmDWPop",
21 | "#navbar ul li", "#navbar a img"
22 | */
23 | // For Yahoo.com
24 | "#page", "#masthead", "#mastheadhd",
25 | ".mastheadbd", ".first", ".on",
26 | "div", "li", "a",
27 | "div.mastheadbd", "li.first", "li.on",
28 | "#page div", "#dtba span",
29 | "div#page", "div#masthead",
30 | "#page .mastheadbd", "#page .first",
31 | ".outer_search_container .search_container", ".searchbox_container .inputtext",
32 | "*",
33 | "#page div.mastheadbd", "#page li.first",
34 | "input[name=p]", "a[name=marketplace]",
35 | ".outer_search_container div", ".searchbox_container span",
36 | "[name=p]", "[name=marketplace]",
37 | "ul li", "form input",
38 | "#page #e2econtent", "#page #e2e"
39 | ];
40 |
41 | jQuery.fn.benchmark = function() {
42 | this.each(function() {
43 | try {
44 | jQuery(this).parent().children("*:gt(1)").remove();
45 | } catch(e) { }
46 | })
47 | // set # times to run the test in index.html
48 | var times = parseInt(jQuery("#times").val());
49 | jQuery.benchmarker.startingList = this.get();
50 | benchmark(this.get(), times, jQuery.benchmarker.libraries);
51 | }
52 |
53 | jQuery(function() {
54 | for(i = 0; i < jQuery.benchmarker.tests.length; i++) {
55 | jQuery("tbody").append("" + jQuery.benchmarker.tests[i] + " ");
56 | }
57 | jQuery("tbody tr:first-child").remove();
58 | jQuery("td.test").before("
");
59 | jQuery("button.runTests").bind("click", function() {
60 | jQuery('td:has(input:checked) + td.test').benchmark();
61 | });
62 |
63 | jQuery("button.retryTies").bind("click", function() { jQuery("tr:has(td.tie) td.test").benchmark() })
64 |
65 | jQuery("button.selectAll").bind("click", function() { jQuery("input[type=checkbox]").each(function() { this.checked = true }) })
66 | jQuery("button.deselectAll").bind("click", function() { jQuery("input[type=checkbox]").each(function() { this.checked = false }) })
67 |
68 | jQuery("#addTest").bind("click", function() {
69 | jQuery("table").append("Add ");
70 | jQuery("div#time-test > button").each(function() { this.disabled = true; })
71 | jQuery("tbody tr:last button").bind("click", function() {
72 | var td = jQuery(this).parent();
73 | td.html("- " + jQuery(this).prev().val()).addClass("test");
74 | jQuery("div#time-test > button").each(function() { this.disabled = false; })
75 | jQuery("button", td).bind("click", function() { jQuery(this).parents("tr").remove(); })
76 | })
77 | })
78 |
79 | var headers = jQuery.map(jQuery.benchmarker.libraries, function(i,n) {
80 | var extra = n == 0 ? "basis - " : "";
81 | return "" + extra + i + " "
82 | }).join("");
83 |
84 | jQuery("thead tr").append(headers);
85 |
86 | var footers = "";
87 | for(i = 0; i < jQuery.benchmarker.libraries.length; i++)
88 | footers += " "
89 |
90 | var wlfooters = "";
91 | for(i = 0; i < jQuery.benchmarker.libraries.length; i++)
92 | wlfooters += "W / F "
93 |
94 | jQuery("tfoot tr:first").append(footers);
95 | jQuery("tfoot tr:last").append(wlfooters);
96 |
97 | });
98 |
99 | benchmark = function(list, times, libraries) {
100 | if(list[0]) {
101 | var times = times || 50;
102 | var el = list[0];
103 | var code = jQuery(el).text().replace(/^-/, "");
104 | var timeArr = []
105 | for(i = 0; i < times + 2; i++) {
106 | var time = new Date()
107 | try {
108 | window[libraries[0]](code);
109 | } catch(e) { }
110 | timeArr.push(new Date() - time);
111 | }
112 | var diff = Math.sum(timeArr) - Math.max.apply( Math, timeArr )
113 | - Math.min.apply( Math, timeArr );
114 | try {
115 | var libRes = window[libraries[0]](code);
116 | var jqRes = jQuery(code);
117 | if(((jqRes.length == 0) && (libRes.length != 0)) ||
118 | (libRes.length > 0 && (jqRes.length == libRes.length)) ||
119 | ((libraries[0] == "cssQuery" || libraries[0] == "jQuery") && code.match(/nth\-child/) && (libRes.length > 0)) ||
120 | ((libraries[0] == "jQold") && jqRes.length > 0)) {
121 | jQuery(el).parent().append("" + Math.round(diff / times * 100) / 100 + "ms ");
122 | } else {
123 | jQuery(el).parent().append("FAIL ");
124 | }
125 | } catch(e) {
126 | jQuery(el).parent().append("FAIL ");
127 | }
128 | setTimeout(benchmarkList(list, times, libraries), 100);
129 | } else if(libraries[1]) {
130 | benchmark(jQuery.benchmarker.startingList, times, libraries.slice(1));
131 | } else {
132 | jQuery("tbody tr").each(function() {
133 | var winners = jQuery("td:gt(1)", this).min(2);
134 | if(winners.length == 1) winners.addClass("winner");
135 | else winners.addClass("tie");
136 | });
137 | setTimeout(count, 100);
138 | }
139 | }
140 |
141 | function benchmarkList(list, times, libraries) {
142 | return function() {
143 | benchmark(list.slice(1), times, libraries);
144 | }
145 | }
146 |
147 | function count() {
148 | for(i = 3; i <= jQuery.benchmarker.libraries.length + 2 ; i++) {
149 | var fails = jQuery("td:nth-child(" + i + ").fail").length;
150 | var wins = jQuery("td:nth-child(" + i + ").winner").length;
151 | jQuery("tfoot tr:first th:eq(" + (i - 1) + ")")
152 | .html("" + wins + " / " + fails + " ");
153 | }
154 | }
155 |
156 |
157 | jQuery.fn.maxmin = function(tolerance, maxmin, percentage) {
158 | tolerance = tolerance || 0;
159 | var target = Math[maxmin].apply(Math, jQuery.map(this, function(i) {
160 | var parsedNum = parseFloat(i.innerHTML.replace(/[^\.\d]/g, ""));
161 | if(parsedNum || (parsedNum == 0)) return parsedNum;
162 | }));
163 | return this.filter(function() {
164 | if( withinTolerance(parseFloat(this.innerHTML.replace(/[^\.\d]/g, "")), target, tolerance, percentage) ) return true;
165 | })
166 | }
167 |
168 | jQuery.fn.max = function(tolerance, percentage) { return this.maxmin(tolerance, "max", percentage) }
169 | jQuery.fn.min = function(tolerance, percentage) { return this.maxmin(tolerance, "min", percentage) }
170 |
171 | function withinTolerance(number, target, tolerance, percentage) {
172 | if(percentage) { var high = target + ((tolerance / 100) * target); var low = target - ((tolerance / 100) * target); }
173 | else { var high = target + tolerance; var low = target - tolerance; }
174 | if(number >= low && number <= high) return true;
175 | }
176 |
177 | Math.sum = function(arr) {
178 | var sum = 0;
179 | for(i = 0; i < arr.length; i++) sum += arr[i];
180 | return sum;
181 | }
182 |
--------------------------------------------------------------------------------
/speed/closest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test .closest() Performance
5 |
6 |
7 |
8 |
9 |
25 |
26 |
27 |
28 |
Hello
29 |
30 |
31 |
lorem ipsum
32 |
dolor sit amet
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/speed/css.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test Event Handling Performance
5 |
6 |
7 |
8 |
9 |
76 |
77 |
78 |
79 | Getting Values: Loading...
80 | Setting Values: Loading...
81 |
82 |
83 |
--------------------------------------------------------------------------------
/speed/event.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test Event Handling Performance
5 |
6 |
7 |
8 |
9 |
53 |
54 |
55 | Move the mouse, please!
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/speed/filter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test .filter() Performance
5 |
6 |
7 |
8 |
9 |
28 |
29 |
30 |
31 |
Hello
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/speed/find.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Test .find() Performance
5 |
6 |
7 |
8 |
9 |
24 |
25 |
26 |
27 |
Hello
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/speed/slice.vs.concat.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/ajax/jsonp.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var jsc = jQuery.now(),
4 | jsre = /(\=)\?(&|$)|\?\?/i;
5 |
6 | // Default jsonp settings
7 | jQuery.ajaxSetup({
8 | jsonp: "callback",
9 | jsonpCallback: function() {
10 | return jQuery.expando + "_" + ( jsc++ );
11 | }
12 | });
13 |
14 | // Detect, normalize options and install callbacks for jsonp requests
15 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
16 |
17 | var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
18 | ( typeof s.data === "string" );
19 |
20 | if ( s.dataTypes[ 0 ] === "jsonp" ||
21 | s.jsonp !== false && ( jsre.test( s.url ) ||
22 | inspectData && jsre.test( s.data ) ) ) {
23 |
24 | var responseContainer,
25 | jsonpCallback = s.jsonpCallback =
26 | jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
27 | previous = window[ jsonpCallback ],
28 | url = s.url,
29 | data = s.data,
30 | replace = "$1" + jsonpCallback + "$2";
31 |
32 | if ( s.jsonp !== false ) {
33 | url = url.replace( jsre, replace );
34 | if ( s.url === url ) {
35 | if ( inspectData ) {
36 | data = data.replace( jsre, replace );
37 | }
38 | if ( s.data === data ) {
39 | // Add callback manually
40 | url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
41 | }
42 | }
43 | }
44 |
45 | s.url = url;
46 | s.data = data;
47 |
48 | // Install callback
49 | window[ jsonpCallback ] = function( response ) {
50 | responseContainer = [ response ];
51 | };
52 |
53 | // Clean-up function
54 | jqXHR.always(function() {
55 | // Set callback back to previous value
56 | window[ jsonpCallback ] = previous;
57 | // Call if it was a function and we have a response
58 | if ( responseContainer && jQuery.isFunction( previous ) ) {
59 | window[ jsonpCallback ]( responseContainer[ 0 ] );
60 | }
61 | });
62 |
63 | // Use data converter to retrieve json after script execution
64 | s.converters["script json"] = function() {
65 | if ( !responseContainer ) {
66 | jQuery.error( jsonpCallback + " was not called" );
67 | }
68 | return responseContainer[ 0 ];
69 | };
70 |
71 | // force json dataType
72 | s.dataTypes[ 0 ] = "json";
73 |
74 | // Delegate to script
75 | return "script";
76 | }
77 | });
78 |
79 | })( jQuery );
80 |
--------------------------------------------------------------------------------
/src/ajax/script.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | // Install script dataType
4 | jQuery.ajaxSetup({
5 | accepts: {
6 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7 | },
8 | contents: {
9 | script: /javascript|ecmascript/
10 | },
11 | converters: {
12 | "text script": function( text ) {
13 | jQuery.globalEval( text );
14 | return text;
15 | }
16 | }
17 | });
18 |
19 | // Handle cache's special case and global
20 | jQuery.ajaxPrefilter( "script", function( s ) {
21 | if ( s.cache === undefined ) {
22 | s.cache = false;
23 | }
24 | if ( s.crossDomain ) {
25 | s.type = "GET";
26 | s.global = false;
27 | }
28 | });
29 |
30 | // Bind script tag hack transport
31 | jQuery.ajaxTransport( "script", function(s) {
32 |
33 | // This transport only deals with cross domain requests
34 | if ( s.crossDomain ) {
35 |
36 | var script,
37 | head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
38 |
39 | return {
40 |
41 | send: function( _, callback ) {
42 |
43 | script = document.createElement( "script" );
44 |
45 | script.async = "async";
46 |
47 | if ( s.scriptCharset ) {
48 | script.charset = s.scriptCharset;
49 | }
50 |
51 | script.src = s.url;
52 |
53 | // Attach handlers for all browsers
54 | script.onload = script.onreadystatechange = function( _, isAbort ) {
55 |
56 | if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
57 |
58 | // Handle memory leak in IE
59 | script.onload = script.onreadystatechange = null;
60 |
61 | // Remove the script
62 | if ( head && script.parentNode ) {
63 | head.removeChild( script );
64 | }
65 |
66 | // Dereference the script
67 | script = undefined;
68 |
69 | // Callback if not abort
70 | if ( !isAbort ) {
71 | callback( 200, "success" );
72 | }
73 | }
74 | };
75 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
76 | // This arises when a base node is used (#2709 and #4378).
77 | head.insertBefore( script, head.firstChild );
78 | },
79 |
80 | abort: function() {
81 | if ( script ) {
82 | script.onload( 0, 1 );
83 | }
84 | }
85 | };
86 | }
87 | });
88 |
89 | })( jQuery );
90 |
--------------------------------------------------------------------------------
/src/ajax/xhr.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
4 | xhrOnUnloadAbort = window.ActiveXObject ? function() {
5 | // Abort all pending requests
6 | for ( var key in xhrCallbacks ) {
7 | xhrCallbacks[ key ]( 0, 1 );
8 | }
9 | } : false,
10 | xhrId = 0,
11 | xhrCallbacks;
12 |
13 | // Functions to create xhrs
14 | function createStandardXHR() {
15 | try {
16 | return new window.XMLHttpRequest();
17 | } catch( e ) {}
18 | }
19 |
20 | function createActiveXHR() {
21 | try {
22 | return new window.ActiveXObject( "Microsoft.XMLHTTP" );
23 | } catch( e ) {}
24 | }
25 |
26 | // Create the request object
27 | // (This is still attached to ajaxSettings for backward compatibility)
28 | jQuery.ajaxSettings.xhr = window.ActiveXObject ?
29 | /* Microsoft failed to properly
30 | * implement the XMLHttpRequest in IE7 (can't request local files),
31 | * so we use the ActiveXObject when it is available
32 | * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
33 | * we need a fallback.
34 | */
35 | function() {
36 | return !this.isLocal && createStandardXHR() || createActiveXHR();
37 | } :
38 | // For all other browsers, use the standard XMLHttpRequest object
39 | createStandardXHR;
40 |
41 | // Determine support properties
42 | (function( xhr ) {
43 | jQuery.extend( jQuery.support, {
44 | ajax: !!xhr,
45 | cors: !!xhr && ( "withCredentials" in xhr )
46 | });
47 | })( jQuery.ajaxSettings.xhr() );
48 |
49 | // Create transport if the browser can provide an xhr
50 | if ( jQuery.support.ajax ) {
51 |
52 | jQuery.ajaxTransport(function( s ) {
53 | // Cross domain only allowed if supported through XMLHttpRequest
54 | if ( !s.crossDomain || jQuery.support.cors ) {
55 |
56 | var callback;
57 |
58 | return {
59 | send: function( headers, complete ) {
60 |
61 | // Get a new xhr
62 | var xhr = s.xhr(),
63 | handle,
64 | i;
65 |
66 | // Open the socket
67 | // Passing null username, generates a login popup on Opera (#2865)
68 | if ( s.username ) {
69 | xhr.open( s.type, s.url, s.async, s.username, s.password );
70 | } else {
71 | xhr.open( s.type, s.url, s.async );
72 | }
73 |
74 | // Apply custom fields if provided
75 | if ( s.xhrFields ) {
76 | for ( i in s.xhrFields ) {
77 | xhr[ i ] = s.xhrFields[ i ];
78 | }
79 | }
80 |
81 | // Override mime type if needed
82 | if ( s.mimeType && xhr.overrideMimeType ) {
83 | xhr.overrideMimeType( s.mimeType );
84 | }
85 |
86 | // X-Requested-With header
87 | // For cross-domain requests, seeing as conditions for a preflight are
88 | // akin to a jigsaw puzzle, we simply never set it to be sure.
89 | // (it can always be set on a per-request basis or even using ajaxSetup)
90 | // For same-domain requests, won't change header if already provided.
91 | if ( !s.crossDomain && !headers["X-Requested-With"] ) {
92 | headers[ "X-Requested-With" ] = "XMLHttpRequest";
93 | }
94 |
95 | // Need an extra try/catch for cross domain requests in Firefox 3
96 | try {
97 | for ( i in headers ) {
98 | xhr.setRequestHeader( i, headers[ i ] );
99 | }
100 | } catch( _ ) {}
101 |
102 | // Do send the request
103 | // This may raise an exception which is actually
104 | // handled in jQuery.ajax (so no try/catch here)
105 | xhr.send( ( s.hasContent && s.data ) || null );
106 |
107 | // Listener
108 | callback = function( _, isAbort ) {
109 |
110 | var status,
111 | statusText,
112 | responseHeaders,
113 | responses,
114 | xml;
115 |
116 | // Firefox throws exceptions when accessing properties
117 | // of an xhr when a network error occured
118 | // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
119 | try {
120 |
121 | // Was never called and is aborted or complete
122 | if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
123 |
124 | // Only called once
125 | callback = undefined;
126 |
127 | // Do not keep as active anymore
128 | if ( handle ) {
129 | xhr.onreadystatechange = jQuery.noop;
130 | if ( xhrOnUnloadAbort ) {
131 | delete xhrCallbacks[ handle ];
132 | }
133 | }
134 |
135 | // If it's an abort
136 | if ( isAbort ) {
137 | // Abort it manually if needed
138 | if ( xhr.readyState !== 4 ) {
139 | xhr.abort();
140 | }
141 | } else {
142 | status = xhr.status;
143 | responseHeaders = xhr.getAllResponseHeaders();
144 | responses = {};
145 | xml = xhr.responseXML;
146 |
147 | // Construct response list
148 | if ( xml && xml.documentElement /* #4958 */ ) {
149 | responses.xml = xml;
150 | }
151 | responses.text = xhr.responseText;
152 |
153 | // Firefox throws an exception when accessing
154 | // statusText for faulty cross-domain requests
155 | try {
156 | statusText = xhr.statusText;
157 | } catch( e ) {
158 | // We normalize with Webkit giving an empty statusText
159 | statusText = "";
160 | }
161 |
162 | // Filter status for non standard behaviors
163 |
164 | // If the request is local and we have data: assume a success
165 | // (success with no data won't get notified, that's the best we
166 | // can do given current implementations)
167 | if ( !status && s.isLocal && !s.crossDomain ) {
168 | status = responses.text ? 200 : 404;
169 | // IE - #1450: sometimes returns 1223 when it should be 204
170 | } else if ( status === 1223 ) {
171 | status = 204;
172 | }
173 | }
174 | }
175 | } catch( firefoxAccessException ) {
176 | if ( !isAbort ) {
177 | complete( -1, firefoxAccessException );
178 | }
179 | }
180 |
181 | // Call complete if needed
182 | if ( responses ) {
183 | complete( status, statusText, responses, responseHeaders );
184 | }
185 | };
186 |
187 | // if we're in sync mode or it's in cache
188 | // and has been retrieved directly (IE6 & IE7)
189 | // we need to manually fire the callback
190 | if ( !s.async || xhr.readyState === 4 ) {
191 | callback();
192 | } else {
193 | handle = ++xhrId;
194 | if ( xhrOnUnloadAbort ) {
195 | // Create the active xhrs callbacks list if needed
196 | // and attach the unload handler
197 | if ( !xhrCallbacks ) {
198 | xhrCallbacks = {};
199 | jQuery( window ).unload( xhrOnUnloadAbort );
200 | }
201 | // Add to list of active xhrs callbacks
202 | xhrCallbacks[ handle ] = callback;
203 | }
204 | xhr.onreadystatechange = callback;
205 | }
206 | },
207 |
208 | abort: function() {
209 | if ( callback ) {
210 | callback(0,1);
211 | }
212 | }
213 | };
214 | }
215 | });
216 | }
217 |
218 | })( jQuery );
219 |
--------------------------------------------------------------------------------
/src/callbacks.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | // String to Object flags format cache
4 | var flagsCache = {};
5 |
6 | // Convert String-formatted flags into Object-formatted ones and store in cache
7 | function createFlags( flags ) {
8 | var object = flagsCache[ flags ] = {},
9 | i, length;
10 | flags = flags.split( /\s+/ );
11 | for ( i = 0, length = flags.length; i < length; i++ ) {
12 | object[ flags[i] ] = true;
13 | }
14 | return object;
15 | }
16 |
17 | /*
18 | * Create a callback list using the following parameters:
19 | *
20 | * flags: an optional list of space-separated flags that will change how
21 | * the callback list behaves
22 | *
23 | * By default a callback list will act like an event callback list and can be
24 | * "fired" multiple times.
25 | *
26 | * Possible flags:
27 | *
28 | * once: will ensure the callback list can only be fired once (like a Deferred)
29 | *
30 | * memory: will keep track of previous values and will call any callback added
31 | * after the list has been fired right away with the latest "memorized"
32 | * values (like a Deferred)
33 | *
34 | * unique: will ensure a callback can only be added once (no duplicate in the list)
35 | *
36 | * stopOnFalse: interrupt callings when a callback returns false
37 | *
38 | */
39 | jQuery.Callbacks = function( flags ) {
40 |
41 | // Convert flags from String-formatted to Object-formatted
42 | // (we check in cache first)
43 | flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
44 |
45 | var // Actual callback list
46 | list = [],
47 | // Stack of fire calls for repeatable lists
48 | stack = [],
49 | // Last fire value (for non-forgettable lists)
50 | memory,
51 | // Flag to know if list is currently firing
52 | firing,
53 | // First callback to fire (used internally by add and fireWith)
54 | firingStart,
55 | // End of the loop when firing
56 | firingLength,
57 | // Index of currently firing callback (modified by remove if needed)
58 | firingIndex,
59 | // Add one or several callbacks to the list
60 | add = function( args ) {
61 | var i,
62 | length,
63 | elem,
64 | type,
65 | actual;
66 | for ( i = 0, length = args.length; i < length; i++ ) {
67 | elem = args[ i ];
68 | type = jQuery.type( elem );
69 | if ( type === "array" ) {
70 | // Inspect recursively
71 | add( elem );
72 | } else if ( type === "function" ) {
73 | // Add if not in unique mode and callback is not in
74 | if ( !flags.unique || !self.has( elem ) ) {
75 | list.push( elem );
76 | }
77 | }
78 | }
79 | },
80 | // Fire callbacks
81 | fire = function( context, args ) {
82 | args = args || [];
83 | memory = !flags.memory || [ context, args ];
84 | firing = true;
85 | firingIndex = firingStart || 0;
86 | firingStart = 0;
87 | firingLength = list.length;
88 | for ( ; list && firingIndex < firingLength; firingIndex++ ) {
89 | if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
90 | memory = true; // Mark as halted
91 | break;
92 | }
93 | }
94 | firing = false;
95 | if ( list ) {
96 | if ( !flags.once ) {
97 | if ( stack && stack.length ) {
98 | memory = stack.shift();
99 | self.fireWith( memory[ 0 ], memory[ 1 ] );
100 | }
101 | } else if ( memory === true ) {
102 | self.disable();
103 | } else {
104 | list = [];
105 | }
106 | }
107 | },
108 | // Actual Callbacks object
109 | self = {
110 | // Add a callback or a collection of callbacks to the list
111 | add: function() {
112 | if ( list ) {
113 | var length = list.length;
114 | add( arguments );
115 | // Do we need to add the callbacks to the
116 | // current firing batch?
117 | if ( firing ) {
118 | firingLength = list.length;
119 | // With memory, if we're not firing then
120 | // we should call right away, unless previous
121 | // firing was halted (stopOnFalse)
122 | } else if ( memory && memory !== true ) {
123 | firingStart = length;
124 | fire( memory[ 0 ], memory[ 1 ] );
125 | }
126 | }
127 | return this;
128 | },
129 | // Remove a callback from the list
130 | remove: function() {
131 | if ( list ) {
132 | var args = arguments,
133 | argIndex = 0,
134 | argLength = args.length;
135 | for ( ; argIndex < argLength ; argIndex++ ) {
136 | for ( var i = 0; i < list.length; i++ ) {
137 | if ( args[ argIndex ] === list[ i ] ) {
138 | // Handle firingIndex and firingLength
139 | if ( firing ) {
140 | if ( i <= firingLength ) {
141 | firingLength--;
142 | if ( i <= firingIndex ) {
143 | firingIndex--;
144 | }
145 | }
146 | }
147 | // Remove the element
148 | list.splice( i--, 1 );
149 | // If we have some unicity property then
150 | // we only need to do this once
151 | if ( flags.unique ) {
152 | break;
153 | }
154 | }
155 | }
156 | }
157 | }
158 | return this;
159 | },
160 | // Control if a given callback is in the list
161 | has: function( fn ) {
162 | if ( list ) {
163 | var i = 0,
164 | length = list.length;
165 | for ( ; i < length; i++ ) {
166 | if ( fn === list[ i ] ) {
167 | return true;
168 | }
169 | }
170 | }
171 | return false;
172 | },
173 | // Remove all callbacks from the list
174 | empty: function() {
175 | list = [];
176 | return this;
177 | },
178 | // Have the list do nothing anymore
179 | disable: function() {
180 | list = stack = memory = undefined;
181 | return this;
182 | },
183 | // Is it disabled?
184 | disabled: function() {
185 | return !list;
186 | },
187 | // Lock the list in its current state
188 | lock: function() {
189 | stack = undefined;
190 | if ( !memory || memory === true ) {
191 | self.disable();
192 | }
193 | return this;
194 | },
195 | // Is it locked?
196 | locked: function() {
197 | return !stack;
198 | },
199 | // Call all callbacks with the given context and arguments
200 | fireWith: function( context, args ) {
201 | if ( stack ) {
202 | if ( firing ) {
203 | if ( !flags.once ) {
204 | stack.push( [ context, args ] );
205 | }
206 | } else if ( !( flags.once && memory ) ) {
207 | fire( context, args );
208 | }
209 | }
210 | return this;
211 | },
212 | // Call all the callbacks with the given arguments
213 | fire: function() {
214 | self.fireWith( this, arguments );
215 | return this;
216 | },
217 | // To know if the callbacks have already been called at least once
218 | fired: function() {
219 | return !!memory;
220 | }
221 | };
222 |
223 | return self;
224 | };
225 |
226 | })( jQuery );
227 |
--------------------------------------------------------------------------------
/src/data.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var rbrace = /^(?:\{.*\}|\[.*\])$/,
4 | rmultiDash = /([A-Z])/g;
5 |
6 | jQuery.extend({
7 | cache: {},
8 |
9 | // Please use with caution
10 | uuid: 0,
11 |
12 | // Unique for each copy of jQuery on the page
13 | // Non-digits removed to match rinlinejQuery
14 | expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
15 |
16 | // The following elements throw uncatchable exceptions if you
17 | // attempt to add expando properties to them.
18 | noData: {
19 | "embed": true,
20 | // Ban all objects except for Flash (which handle expandos)
21 | "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
22 | "applet": true
23 | },
24 |
25 | hasData: function( elem ) {
26 | elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
27 | return !!elem && !isEmptyDataObject( elem );
28 | },
29 |
30 | data: function( elem, name, data, pvt /* Internal Use Only */ ) {
31 | if ( !jQuery.acceptData( elem ) ) {
32 | return;
33 | }
34 |
35 | var thisCache, ret,
36 | internalKey = jQuery.expando,
37 | getByName = typeof name === "string",
38 |
39 | // We have to handle DOM nodes and JS objects differently because IE6-7
40 | // can't GC object references properly across the DOM-JS boundary
41 | isNode = elem.nodeType,
42 |
43 | // Only DOM nodes need the global jQuery cache; JS object data is
44 | // attached directly to the object so GC can occur automatically
45 | cache = isNode ? jQuery.cache : elem,
46 |
47 | // Only defining an ID for JS objects if its cache already exists allows
48 | // the code to shortcut on the same path as a DOM node with no cache
49 | id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
50 |
51 | // Avoid doing any more work than we need to when trying to get data on an
52 | // object that has no data at all
53 | if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
54 | return;
55 | }
56 |
57 | if ( !id ) {
58 | // Only DOM nodes need a new unique ID for each element since their data
59 | // ends up in the global cache
60 | if ( isNode ) {
61 | elem[ jQuery.expando ] = id = ++jQuery.uuid;
62 | } else {
63 | id = jQuery.expando;
64 | }
65 | }
66 |
67 | if ( !cache[ id ] ) {
68 | cache[ id ] = {};
69 |
70 | // Avoids exposing jQuery metadata on plain JS objects when the object
71 | // is serialized using JSON.stringify
72 | if ( !isNode ) {
73 | cache[ id ].toJSON = jQuery.noop;
74 | }
75 | }
76 |
77 | // An object can be passed to jQuery.data instead of a key/value pair; this gets
78 | // shallow copied over onto the existing cache
79 | if ( typeof name === "object" || typeof name === "function" ) {
80 | if ( pvt ) {
81 | cache[ id ] = jQuery.extend( cache[ id ], name );
82 | } else {
83 | cache[ id ].data = jQuery.extend( cache[ id ].data, name );
84 | }
85 | }
86 |
87 | thisCache = cache[ id ];
88 |
89 | // jQuery data() is stored in a separate object inside the object's internal data
90 | // cache in order to avoid key collisions between internal data and user-defined
91 | // data.
92 | if ( !pvt ) {
93 | if ( !thisCache.data ) {
94 | thisCache.data = {};
95 | }
96 |
97 | thisCache = thisCache.data;
98 | }
99 |
100 | if ( data !== undefined ) {
101 | thisCache[ jQuery.camelCase( name ) ] = data;
102 | }
103 |
104 | // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
105 | // not attempt to inspect the internal events object using jQuery.data, as this
106 | // internal data object is undocumented and subject to change.
107 | if ( name === "events" && !thisCache[name] ) {
108 | return thisCache[ internalKey ] && thisCache[ internalKey ].events;
109 | }
110 |
111 | // Check for both converted-to-camel and non-converted data property names
112 | // If a data property was specified
113 | if ( getByName ) {
114 |
115 | // First Try to find as-is property data
116 | ret = thisCache[ name ];
117 |
118 | // Test for null|undefined property data
119 | if ( ret == null ) {
120 |
121 | // Try to find the camelCased property
122 | ret = thisCache[ jQuery.camelCase( name ) ];
123 | }
124 | } else {
125 | ret = thisCache;
126 | }
127 |
128 | return ret;
129 | },
130 |
131 | removeData: function( elem, name, pvt /* Internal Use Only */ ) {
132 | if ( !jQuery.acceptData( elem ) ) {
133 | return;
134 | }
135 |
136 | var thisCache, i, l,
137 |
138 | // Reference to internal data cache key
139 | internalKey = jQuery.expando,
140 |
141 | isNode = elem.nodeType,
142 |
143 | // See jQuery.data for more information
144 | cache = isNode ? jQuery.cache : elem,
145 |
146 | // See jQuery.data for more information
147 | id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
148 |
149 | // If there is already no cache entry for this object, there is no
150 | // purpose in continuing
151 | if ( !cache[ id ] ) {
152 | return;
153 | }
154 |
155 | if ( name ) {
156 |
157 | thisCache = pvt ? cache[ id ] : cache[ id ].data;
158 |
159 | if ( thisCache ) {
160 |
161 | // Support space separated names
162 | if ( jQuery.isArray( name ) ) {
163 | name = name;
164 | } else if ( name in thisCache ) {
165 | name = [ name ];
166 | } else {
167 |
168 | // split the camel cased version by spaces
169 | name = jQuery.camelCase( name );
170 | if ( name in thisCache ) {
171 | name = [ name ];
172 | } else {
173 | name = name.split( " " );
174 | }
175 | }
176 |
177 | for ( i = 0, l = name.length; i < l; i++ ) {
178 | delete thisCache[ name[i] ];
179 | }
180 |
181 | // If there is no data left in the cache, we want to continue
182 | // and let the cache object itself get destroyed
183 | if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
184 | return;
185 | }
186 | }
187 | }
188 |
189 | // See jQuery.data for more information
190 | if ( !pvt ) {
191 | delete cache[ id ].data;
192 |
193 | // Don't destroy the parent cache unless the internal data object
194 | // had been the only thing left in it
195 | if ( !isEmptyDataObject(cache[ id ]) ) {
196 | return;
197 | }
198 | }
199 |
200 | // Browsers that fail expando deletion also refuse to delete expandos on
201 | // the window, but it will allow it on all other JS objects; other browsers
202 | // don't care
203 | // Ensure that `cache` is not a window object #10080
204 | if ( jQuery.support.deleteExpando || !cache.setInterval ) {
205 | delete cache[ id ];
206 | } else {
207 | cache[ id ] = null;
208 | }
209 |
210 | // We destroyed the cache and need to eliminate the expando on the node to avoid
211 | // false lookups in the cache for entries that no longer exist
212 | if ( isNode ) {
213 | // IE does not allow us to delete expando properties from nodes,
214 | // nor does it have a removeAttribute function on Document nodes;
215 | // we must handle all of these cases
216 | if ( jQuery.support.deleteExpando ) {
217 | delete elem[ jQuery.expando ];
218 | } else if ( elem.removeAttribute ) {
219 | elem.removeAttribute( jQuery.expando );
220 | } else {
221 | elem[ jQuery.expando ] = null;
222 | }
223 | }
224 | },
225 |
226 | // For internal use only.
227 | _data: function( elem, name, data ) {
228 | return jQuery.data( elem, name, data, true );
229 | },
230 |
231 | // A method for determining if a DOM node can handle the data expando
232 | acceptData: function( elem ) {
233 | if ( elem.nodeName ) {
234 | var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
235 |
236 | if ( match ) {
237 | return !(match === true || elem.getAttribute("classid") !== match);
238 | }
239 | }
240 |
241 | return true;
242 | }
243 | });
244 |
245 | jQuery.fn.extend({
246 | data: function( key, value ) {
247 | var parts, attr, name,
248 | data = null;
249 |
250 | if ( typeof key === "undefined" ) {
251 | if ( this.length ) {
252 | data = jQuery.data( this[0] );
253 |
254 | if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
255 | attr = this[0].attributes;
256 | for ( var i = 0, l = attr.length; i < l; i++ ) {
257 | name = attr[i].name;
258 |
259 | if ( name.indexOf( "data-" ) === 0 ) {
260 | name = jQuery.camelCase( name.substring(5) );
261 |
262 | dataAttr( this[0], name, data[ name ] );
263 | }
264 | }
265 | jQuery._data( this[0], "parsedAttrs", true );
266 | }
267 | }
268 |
269 | return data;
270 |
271 | } else if ( typeof key === "object" ) {
272 | return this.each(function() {
273 | jQuery.data( this, key );
274 | });
275 | }
276 |
277 | parts = key.split(".");
278 | parts[1] = parts[1] ? "." + parts[1] : "";
279 |
280 | if ( value === undefined ) {
281 | data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
282 |
283 | // Try to fetch any internally stored data first
284 | if ( data === undefined && this.length ) {
285 | data = jQuery.data( this[0], key );
286 | data = dataAttr( this[0], key, data );
287 | }
288 |
289 | return data === undefined && parts[1] ?
290 | this.data( parts[0] ) :
291 | data;
292 |
293 | } else {
294 | return this.each(function() {
295 | var $this = jQuery( this ),
296 | args = [ parts[0], value ];
297 |
298 | $this.triggerHandler( "setData" + parts[1] + "!", args );
299 | jQuery.data( this, key, value );
300 | $this.triggerHandler( "changeData" + parts[1] + "!", args );
301 | });
302 | }
303 | },
304 |
305 | removeData: function( key ) {
306 | return this.each(function() {
307 | jQuery.removeData( this, key );
308 | });
309 | }
310 | });
311 |
312 | function dataAttr( elem, key, data ) {
313 | // If nothing was found internally, try to fetch any
314 | // data from the HTML5 data-* attribute
315 | if ( data === undefined && elem.nodeType === 1 ) {
316 |
317 | var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
318 |
319 | data = elem.getAttribute( name );
320 |
321 | if ( typeof data === "string" ) {
322 | try {
323 | data = data === "true" ? true :
324 | data === "false" ? false :
325 | data === "null" ? null :
326 | !jQuery.isNaN( data ) ? parseFloat( data ) :
327 | rbrace.test( data ) ? jQuery.parseJSON( data ) :
328 | data;
329 | } catch( e ) {}
330 |
331 | // Make sure we set the data so it isn't changed later
332 | jQuery.data( elem, key, data );
333 |
334 | } else {
335 | data = undefined;
336 | }
337 | }
338 |
339 | return data;
340 | }
341 |
342 | // checks a cache object for emptiness
343 | function isEmptyDataObject( obj ) {
344 | for ( var name in obj ) {
345 |
346 | // if the public data object is empty, the private is still empty
347 | if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
348 | continue;
349 | }
350 | if ( name !== "toJSON" ) {
351 | return false;
352 | }
353 | }
354 |
355 | return true;
356 | }
357 |
358 | })( jQuery );
359 |
--------------------------------------------------------------------------------
/src/deferred.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var // Static reference to slice
4 | sliceDeferred = [].slice;
5 |
6 | jQuery.extend({
7 |
8 | Deferred: function( func ) {
9 | var doneList = jQuery.Callbacks( "once memory" ),
10 | failList = jQuery.Callbacks( "once memory" ),
11 | progressList = jQuery.Callbacks( "memory" ),
12 | lists = {
13 | resolve: doneList,
14 | reject: failList,
15 | notify: progressList
16 | },
17 | promise = {
18 | done: doneList.add,
19 | fail: failList.add,
20 | progress: progressList.add,
21 |
22 | isResolved: doneList.fired,
23 | isRejected: failList.fired,
24 | isPending: function() {
25 | return !progressList.locked();
26 | },
27 |
28 | then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
29 | deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
30 | return this;
31 | },
32 | always: function() {
33 | return deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
34 | },
35 | pipe: function( fnDone, fnFail, fnProgress ) {
36 | return jQuery.Deferred(function( newDefer ) {
37 | jQuery.each( {
38 | done: [ fnDone, "resolve" ],
39 | fail: [ fnFail, "reject" ],
40 | progress: [ fnProgress, "notify" ]
41 | }, function( handler, data ) {
42 | var fn = data[ 0 ],
43 | action = data[ 1 ],
44 | returned;
45 | if ( jQuery.isFunction( fn ) ) {
46 | deferred[ handler ](function() {
47 | returned = fn.apply( this, arguments );
48 | if ( returned && jQuery.isFunction( returned.promise ) ) {
49 | returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
50 | } else {
51 | newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
52 | }
53 | });
54 | } else {
55 | deferred[ handler ]( newDefer[ action ] );
56 | }
57 | });
58 | }).promise();
59 | },
60 | // Get a promise for this deferred
61 | // If obj is provided, the promise aspect is added to the object
62 | promise: function( obj ) {
63 | if ( obj == null ) {
64 | obj = promise;
65 | } else {
66 | for( var key in promise ) {
67 | obj[ key ] = promise[ key ];
68 | }
69 | }
70 | return obj;
71 | }
72 | },
73 | deferred = promise.promise({}),
74 | key;
75 |
76 | for ( key in lists ) {
77 | deferred[ key ] = lists[ key ].fire;
78 | deferred[ key + "With" ] = lists[ key ].fireWith;
79 | }
80 |
81 | // Handle lists exclusiveness
82 | deferred.done( failList.disable, progressList.lock )
83 | .fail( doneList.disable, progressList.lock );
84 |
85 | // Call given func if any
86 | if ( func ) {
87 | func.call( deferred, deferred );
88 | }
89 |
90 | // All done!
91 | return deferred;
92 | },
93 |
94 | // Deferred helper
95 | when: function( firstParam ) {
96 | var args = sliceDeferred.call( arguments, 0 ),
97 | i = 0,
98 | length = args.length,
99 | pValues = new Array( length ),
100 | count = length,
101 | pCount = length,
102 | deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
103 | firstParam :
104 | jQuery.Deferred(),
105 | promise = deferred.promise();
106 | function resolveFunc( i ) {
107 | return function( value ) {
108 | args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
109 | if ( !( --count ) ) {
110 | deferred.resolveWith( deferred, args );
111 | }
112 | };
113 | }
114 | function progressFunc( i ) {
115 | return function( value ) {
116 | pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
117 | deferred.notifyWith( promise, pValues );
118 | };
119 | }
120 | if ( length > 1 ) {
121 | for( ; i < length; i++ ) {
122 | if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
123 | args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
124 | } else {
125 | --count;
126 | }
127 | }
128 | if ( !count ) {
129 | deferred.resolveWith( deferred, args );
130 | }
131 | } else if ( deferred !== firstParam ) {
132 | deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
133 | }
134 | return promise;
135 | }
136 | });
137 |
138 | })( jQuery );
139 |
--------------------------------------------------------------------------------
/src/dimensions.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
4 | jQuery.each([ "Height", "Width" ], function( i, name ) {
5 |
6 | var type = name.toLowerCase();
7 |
8 | // innerHeight and innerWidth
9 | jQuery.fn[ "inner" + name ] = function() {
10 | var elem = this[0];
11 | return elem ?
12 | elem.style ?
13 | parseFloat( jQuery.css( elem, type, "padding" ) ) :
14 | this[ type ]() :
15 | null;
16 | };
17 |
18 | // outerHeight and outerWidth
19 | jQuery.fn[ "outer" + name ] = function( margin ) {
20 | var elem = this[0];
21 | return elem ?
22 | elem.style ?
23 | parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
24 | this[ type ]() :
25 | null;
26 | };
27 |
28 | jQuery.fn[ type ] = function( size ) {
29 | // Get window width or height
30 | var elem = this[0];
31 | if ( !elem ) {
32 | return size == null ? null : this;
33 | }
34 |
35 | if ( jQuery.isFunction( size ) ) {
36 | return this.each(function( i ) {
37 | var self = jQuery( this );
38 | self[ type ]( size.call( this, i, self[ type ]() ) );
39 | });
40 | }
41 |
42 | if ( jQuery.isWindow( elem ) ) {
43 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
44 | // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
45 | var docElemProp = elem.document.documentElement[ "client" + name ],
46 | body = elem.document.body;
47 | return elem.document.compatMode === "CSS1Compat" && docElemProp ||
48 | body && body[ "client" + name ] || docElemProp;
49 |
50 | // Get document width or height
51 | } else if ( elem.nodeType === 9 ) {
52 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
53 | return Math.max(
54 | elem.documentElement["client" + name],
55 | elem.body["scroll" + name], elem.documentElement["scroll" + name],
56 | elem.body["offset" + name], elem.documentElement["offset" + name]
57 | );
58 |
59 | // Get or set width or height on the element
60 | } else if ( size === undefined ) {
61 | var orig = jQuery.css( elem, type ),
62 | ret = parseFloat( orig );
63 |
64 | return jQuery.isNaN( ret ) ? orig : ret;
65 |
66 | // Set the width or height on the element (default to pixels if value is unitless)
67 | } else {
68 | return this.css( type, typeof size === "string" ? size : size + "px" );
69 | }
70 | };
71 |
72 | });
73 |
74 | })( jQuery );
75 |
--------------------------------------------------------------------------------
/src/intro.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * jQuery JavaScript Library v@VERSION
3 | * http://jquery.com/
4 | *
5 | * Copyright 2011, John Resig
6 | * Dual licensed under the MIT or GPL Version 2 licenses.
7 | * http://jquery.org/license
8 | *
9 | * Includes Sizzle.js
10 | * http://sizzlejs.com/
11 | * Copyright 2011, The Dojo Foundation
12 | * Released under the MIT, BSD, and GPL Licenses.
13 | *
14 | * Date: @DATE
15 | */
16 | (function( window, undefined ) {
17 |
18 | // Use the correct document accordingly with window argument (sandbox)
19 | var document = window.document,
20 | navigator = window.navigator,
21 | location = window.location;
22 |
--------------------------------------------------------------------------------
/src/offset.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var rtable = /^t(?:able|d|h)$/i,
4 | rroot = /^(?:body|html)$/i;
5 |
6 | if ( "getBoundingClientRect" in document.documentElement ) {
7 | jQuery.fn.offset = function( options ) {
8 | var elem = this[0], box;
9 |
10 | if ( options ) {
11 | return this.each(function( i ) {
12 | jQuery.offset.setOffset( this, options, i );
13 | });
14 | }
15 |
16 | if ( !elem || !elem.ownerDocument ) {
17 | return null;
18 | }
19 |
20 | if ( elem === elem.ownerDocument.body ) {
21 | return jQuery.offset.bodyOffset( elem );
22 | }
23 |
24 | try {
25 | box = elem.getBoundingClientRect();
26 | } catch(e) {}
27 |
28 | var doc = elem.ownerDocument,
29 | docElem = doc.documentElement;
30 |
31 | // Make sure we're not dealing with a disconnected DOM node
32 | if ( !box || !jQuery.contains( docElem, elem ) ) {
33 | return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
34 | }
35 |
36 | var body = doc.body,
37 | win = getWindow(doc),
38 | clientTop = docElem.clientTop || body.clientTop || 0,
39 | clientLeft = docElem.clientLeft || body.clientLeft || 0,
40 | scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
41 | scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
42 | top = box.top + scrollTop - clientTop,
43 | left = box.left + scrollLeft - clientLeft;
44 |
45 | return { top: top, left: left };
46 | };
47 |
48 | } else {
49 | jQuery.fn.offset = function( options ) {
50 | var elem = this[0];
51 |
52 | if ( options ) {
53 | return this.each(function( i ) {
54 | jQuery.offset.setOffset( this, options, i );
55 | });
56 | }
57 |
58 | if ( !elem || !elem.ownerDocument ) {
59 | return null;
60 | }
61 |
62 | if ( elem === elem.ownerDocument.body ) {
63 | return jQuery.offset.bodyOffset( elem );
64 | }
65 |
66 | var computedStyle,
67 | offsetParent = elem.offsetParent,
68 | prevOffsetParent = elem,
69 | doc = elem.ownerDocument,
70 | docElem = doc.documentElement,
71 | body = doc.body,
72 | defaultView = doc.defaultView,
73 | prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
74 | top = elem.offsetTop,
75 | left = elem.offsetLeft;
76 |
77 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
78 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
79 | break;
80 | }
81 |
82 | computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
83 | top -= elem.scrollTop;
84 | left -= elem.scrollLeft;
85 |
86 | if ( elem === offsetParent ) {
87 | top += elem.offsetTop;
88 | left += elem.offsetLeft;
89 |
90 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
91 | top += parseFloat( computedStyle.borderTopWidth ) || 0;
92 | left += parseFloat( computedStyle.borderLeftWidth ) || 0;
93 | }
94 |
95 | prevOffsetParent = offsetParent;
96 | offsetParent = elem.offsetParent;
97 | }
98 |
99 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
100 | top += parseFloat( computedStyle.borderTopWidth ) || 0;
101 | left += parseFloat( computedStyle.borderLeftWidth ) || 0;
102 | }
103 |
104 | prevComputedStyle = computedStyle;
105 | }
106 |
107 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
108 | top += body.offsetTop;
109 | left += body.offsetLeft;
110 | }
111 |
112 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
113 | top += Math.max( docElem.scrollTop, body.scrollTop );
114 | left += Math.max( docElem.scrollLeft, body.scrollLeft );
115 | }
116 |
117 | return { top: top, left: left };
118 | };
119 | }
120 |
121 | jQuery.offset = {};
122 |
123 | jQuery.each(
124 | ( "doesAddBorderForTableAndCells doesNotAddBorder " +
125 | "doesNotIncludeMarginInBodyOffset subtractsBorderForOverflowNotVisible " +
126 | "supportsFixedPosition" ).split(" "), function( i, prop ) {
127 |
128 | jQuery.offset[ prop ] = jQuery.support[ prop ];
129 | });
130 |
131 | jQuery.extend( jQuery.offset, {
132 |
133 | bodyOffset: function( body ) {
134 | var top = body.offsetTop,
135 | left = body.offsetLeft;
136 |
137 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
138 | top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
139 | left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
140 | }
141 |
142 | return { top: top, left: left };
143 | },
144 |
145 | setOffset: function( elem, options, i ) {
146 | var position = jQuery.css( elem, "position" );
147 |
148 | // set position first, in-case top/left are set even on static elem
149 | if ( position === "static" ) {
150 | elem.style.position = "relative";
151 | }
152 |
153 | var curElem = jQuery( elem ),
154 | curOffset = curElem.offset(),
155 | curCSSTop = jQuery.css( elem, "top" ),
156 | curCSSLeft = jQuery.css( elem, "left" ),
157 | calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
158 | props = {}, curPosition = {}, curTop, curLeft;
159 |
160 | // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
161 | if ( calculatePosition ) {
162 | curPosition = curElem.position();
163 | curTop = curPosition.top;
164 | curLeft = curPosition.left;
165 | } else {
166 | curTop = parseFloat( curCSSTop ) || 0;
167 | curLeft = parseFloat( curCSSLeft ) || 0;
168 | }
169 |
170 | if ( jQuery.isFunction( options ) ) {
171 | options = options.call( elem, i, curOffset );
172 | }
173 |
174 | if (options.top != null) {
175 | props.top = (options.top - curOffset.top) + curTop;
176 | }
177 | if (options.left != null) {
178 | props.left = (options.left - curOffset.left) + curLeft;
179 | }
180 |
181 | if ( "using" in options ) {
182 | options.using.call( elem, props );
183 | } else {
184 | curElem.css( props );
185 | }
186 | }
187 | });
188 |
189 |
190 | jQuery.fn.extend({
191 |
192 | position: function() {
193 | if ( !this[0] ) {
194 | return null;
195 | }
196 |
197 | var elem = this[0],
198 |
199 | // Get *real* offsetParent
200 | offsetParent = this.offsetParent(),
201 |
202 | // Get correct offsets
203 | offset = this.offset(),
204 | parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
205 |
206 | // Subtract element margins
207 | // note: when an element has margin: auto the offsetLeft and marginLeft
208 | // are the same in Safari causing offset.left to incorrectly be 0
209 | offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
210 | offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
211 |
212 | // Add offsetParent borders
213 | parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
214 | parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
215 |
216 | // Subtract the two offsets
217 | return {
218 | top: offset.top - parentOffset.top,
219 | left: offset.left - parentOffset.left
220 | };
221 | },
222 |
223 | offsetParent: function() {
224 | return this.map(function() {
225 | var offsetParent = this.offsetParent || document.body;
226 | while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
227 | offsetParent = offsetParent.offsetParent;
228 | }
229 | return offsetParent;
230 | });
231 | }
232 | });
233 |
234 |
235 | // Create scrollLeft and scrollTop methods
236 | jQuery.each( ["Left", "Top"], function( i, name ) {
237 | var method = "scroll" + name;
238 |
239 | jQuery.fn[ method ] = function( val ) {
240 | var elem, win;
241 |
242 | if ( val === undefined ) {
243 | elem = this[ 0 ];
244 |
245 | if ( !elem ) {
246 | return null;
247 | }
248 |
249 | win = getWindow( elem );
250 |
251 | // Return the scroll offset
252 | return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
253 | jQuery.support.boxModel && win.document.documentElement[ method ] ||
254 | win.document.body[ method ] :
255 | elem[ method ];
256 | }
257 |
258 | // Set the scroll offset
259 | return this.each(function() {
260 | win = getWindow( this );
261 |
262 | if ( win ) {
263 | win.scrollTo(
264 | !i ? val : jQuery( win ).scrollLeft(),
265 | i ? val : jQuery( win ).scrollTop()
266 | );
267 |
268 | } else {
269 | this[ method ] = val;
270 | }
271 | });
272 | };
273 | });
274 |
275 | function getWindow( elem ) {
276 | return jQuery.isWindow( elem ) ?
277 | elem :
278 | elem.nodeType === 9 ?
279 | elem.defaultView || elem.parentWindow :
280 | false;
281 | }
282 |
283 | })( jQuery );
284 |
--------------------------------------------------------------------------------
/src/outro.js:
--------------------------------------------------------------------------------
1 | // Expose jQuery to the global object
2 | window.jQuery = window.$ = jQuery;
3 | })(window);
4 |
--------------------------------------------------------------------------------
/src/queue.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | function handleQueueMarkDefer( elem, type, src ) {
4 | var deferDataKey = type + "defer",
5 | queueDataKey = type + "queue",
6 | markDataKey = type + "mark",
7 | defer = jQuery._data( elem, deferDataKey );
8 | if ( defer &&
9 | ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
10 | ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
11 | // Give room for hard-coded callbacks to fire first
12 | // and eventually mark/queue something else on the element
13 | setTimeout( function() {
14 | if ( !jQuery._data( elem, queueDataKey ) &&
15 | !jQuery._data( elem, markDataKey ) ) {
16 | jQuery.removeData( elem, deferDataKey, true );
17 | defer.fire();
18 | }
19 | }, 0 );
20 | }
21 | }
22 |
23 | jQuery.extend({
24 |
25 | _mark: function( elem, type ) {
26 | if ( elem ) {
27 | type = (type || "fx") + "mark";
28 | jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
29 | }
30 | },
31 |
32 | _unmark: function( force, elem, type ) {
33 | if ( force !== true ) {
34 | type = elem;
35 | elem = force;
36 | force = false;
37 | }
38 | if ( elem ) {
39 | type = type || "fx";
40 | var key = type + "mark",
41 | count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
42 | if ( count ) {
43 | jQuery._data( elem, key, count );
44 | } else {
45 | jQuery.removeData( elem, key, true );
46 | handleQueueMarkDefer( elem, type, "mark" );
47 | }
48 | }
49 | },
50 |
51 | queue: function( elem, type, data ) {
52 | var q;
53 | if ( elem ) {
54 | type = (type || "fx") + "queue";
55 | q = jQuery._data( elem, type );
56 |
57 | // Speed up dequeue by getting out quickly if this is just a lookup
58 | if ( data ) {
59 | if ( !q || jQuery.isArray(data) ) {
60 | q = jQuery._data( elem, type, jQuery.makeArray(data) );
61 | } else {
62 | q.push( data );
63 | }
64 | }
65 | return q || [];
66 | }
67 | },
68 |
69 | dequeue: function( elem, type ) {
70 | type = type || "fx";
71 |
72 | var queue = jQuery.queue( elem, type ),
73 | fn = queue.shift(),
74 | runner = {};
75 |
76 | // If the fx queue is dequeued, always remove the progress sentinel
77 | if ( fn === "inprogress" ) {
78 | fn = queue.shift();
79 | }
80 |
81 | if ( fn ) {
82 | // Add a progress sentinel to prevent the fx queue from being
83 | // automatically dequeued
84 | if ( type === "fx" ) {
85 | queue.unshift( "inprogress" );
86 | }
87 |
88 | jQuery._data( elem, type + ".run", runner );
89 | fn.call( elem, function() {
90 | jQuery.dequeue( elem, type );
91 | }, runner );
92 | }
93 |
94 | if ( !queue.length ) {
95 | jQuery.removeData( elem, type + "queue " + type + ".run", true );
96 | handleQueueMarkDefer( elem, type, "queue" );
97 | }
98 | }
99 | });
100 |
101 | jQuery.fn.extend({
102 | queue: function( type, data ) {
103 | if ( typeof type !== "string" ) {
104 | data = type;
105 | type = "fx";
106 | }
107 |
108 | if ( data === undefined ) {
109 | return jQuery.queue( this[0], type );
110 | }
111 | return this.each(function() {
112 | var queue = jQuery.queue( this, type, data );
113 |
114 | if ( type === "fx" && queue[0] !== "inprogress" ) {
115 | jQuery.dequeue( this, type );
116 | }
117 | });
118 | },
119 | dequeue: function( type ) {
120 | return this.each(function() {
121 | jQuery.dequeue( this, type );
122 | });
123 | },
124 | // Based off of the plugin by Clint Helfers, with permission.
125 | // http://blindsignals.com/index.php/2009/07/jquery-delay/
126 | delay: function( time, type ) {
127 | time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
128 | type = type || "fx";
129 |
130 | return this.queue( type, function( next, runner ) {
131 | var timeout = setTimeout( next, time );
132 | runner.stop = function() {
133 | clearTimeout( timeout );
134 | };
135 | });
136 | },
137 | clearQueue: function( type ) {
138 | return this.queue( type || "fx", [] );
139 | },
140 | // Get a promise resolved when queues of a certain type
141 | // are emptied (fx is the type by default)
142 | promise: function( type, object ) {
143 | if ( typeof type !== "string" ) {
144 | object = type;
145 | type = undefined;
146 | }
147 | type = type || "fx";
148 | var defer = jQuery.Deferred(),
149 | elements = this,
150 | i = elements.length,
151 | count = 1,
152 | deferDataKey = type + "defer",
153 | queueDataKey = type + "queue",
154 | markDataKey = type + "mark",
155 | tmp;
156 | function resolve() {
157 | if ( !( --count ) ) {
158 | defer.resolveWith( elements, [ elements ] );
159 | }
160 | }
161 | while( i-- ) {
162 | if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
163 | ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
164 | jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
165 | jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
166 | count++;
167 | tmp.add( resolve );
168 | }
169 | }
170 | resolve();
171 | return defer.promise();
172 | }
173 | });
174 |
175 | })( jQuery );
176 |
--------------------------------------------------------------------------------
/src/sizzle-jquery.js:
--------------------------------------------------------------------------------
1 | // Override sizzle attribute retrieval
2 | Sizzle.attr = jQuery.attr;
3 | Sizzle.selectors.attrMap = {};
4 | jQuery.find = Sizzle;
5 | jQuery.expr = Sizzle.selectors;
6 | jQuery.expr[":"] = jQuery.expr.filters;
7 | jQuery.unique = Sizzle.uniqueSort;
8 | jQuery.text = Sizzle.getText;
9 | jQuery.isXMLDoc = Sizzle.isXML;
10 | jQuery.contains = Sizzle.contains;
11 |
--------------------------------------------------------------------------------
/src/traversing.js:
--------------------------------------------------------------------------------
1 | (function( jQuery ) {
2 |
3 | var runtil = /Until$/,
4 | rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5 | // Note: This RegExp should be improved, or likely pulled from Sizzle
6 | rmultiselector = /,/,
7 | isSimple = /^.[^:#\[\.,]*$/,
8 | slice = Array.prototype.slice,
9 | POS = jQuery.expr.match.POS,
10 | // methods guaranteed to produce a unique set when starting from a unique set
11 | guaranteedUnique = {
12 | children: true,
13 | contents: true,
14 | next: true,
15 | prev: true
16 | };
17 |
18 | jQuery.fn.extend({
19 | find: function( selector ) {
20 | var self = this,
21 | i, l;
22 |
23 | if ( typeof selector !== "string" ) {
24 | return jQuery( selector ).filter(function() {
25 | for ( i = 0, l = self.length; i < l; i++ ) {
26 | if ( jQuery.contains( self[ i ], this ) ) {
27 | return true;
28 | }
29 | }
30 | });
31 | }
32 |
33 | var ret = this.pushStack( "", "find", selector ),
34 | length, n, r;
35 |
36 | for ( i = 0, l = this.length; i < l; i++ ) {
37 | length = ret.length;
38 | jQuery.find( selector, this[i], ret );
39 |
40 | if ( i > 0 ) {
41 | // Make sure that the results are unique
42 | for ( n = length; n < ret.length; n++ ) {
43 | for ( r = 0; r < length; r++ ) {
44 | if ( ret[r] === ret[n] ) {
45 | ret.splice(n--, 1);
46 | break;
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
53 | return ret;
54 | },
55 |
56 | has: function( target ) {
57 | var targets = jQuery( target );
58 | return this.filter(function() {
59 | for ( var i = 0, l = targets.length; i < l; i++ ) {
60 | if ( jQuery.contains( this, targets[i] ) ) {
61 | return true;
62 | }
63 | }
64 | });
65 | },
66 |
67 | not: function( selector ) {
68 | return this.pushStack( winnow(this, selector, false), "not", selector);
69 | },
70 |
71 | filter: function( selector ) {
72 | return this.pushStack( winnow(this, selector, true), "filter", selector );
73 | },
74 |
75 | is: function( selector ) {
76 | return !!selector && (
77 | typeof selector === "string" ?
78 | // If this is a positional selector, check membership in the returned set
79 | // so $("p:first").is("p:last") won't return true for a doc with two "p".
80 | POS.test( selector ) ?
81 | jQuery( selector, this.context ).index( this[0] ) >= 0 :
82 | jQuery.filter( selector, this ).length > 0 :
83 | this.filter( selector ).length > 0 );
84 | },
85 |
86 | closest: function( selectors, context ) {
87 | var ret = [], i, l, cur = this[0];
88 |
89 | // Array (deprecated as of jQuery 1.7)
90 | if ( jQuery.isArray( selectors ) ) {
91 | var level = 1;
92 |
93 | while ( cur && cur.ownerDocument && cur !== context ) {
94 | for ( i = 0; i < selectors.length; i++ ) {
95 |
96 | if ( jQuery( cur ).is( selectors[ i ] ) ) {
97 | ret.push({ selector: selectors[ i ], elem: cur, level: level });
98 | }
99 | }
100 |
101 | cur = cur.parentNode;
102 | level++;
103 | }
104 |
105 | return ret;
106 | }
107 |
108 | // String
109 | var pos = POS.test( selectors ) || typeof selectors !== "string" ?
110 | jQuery( selectors, context || this.context ) :
111 | 0;
112 |
113 | for ( i = 0, l = this.length; i < l; i++ ) {
114 | cur = this[i];
115 |
116 | while ( cur ) {
117 | if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
118 | ret.push( cur );
119 | break;
120 |
121 | } else {
122 | cur = cur.parentNode;
123 | if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
124 | break;
125 | }
126 | }
127 | }
128 | }
129 |
130 | ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
131 |
132 | return this.pushStack( ret, "closest", selectors );
133 | },
134 |
135 | // Determine the position of an element within
136 | // the matched set of elements
137 | index: function( elem ) {
138 |
139 | // No argument, return index in parent
140 | if ( !elem ) {
141 | return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
142 | }
143 |
144 | // index in selector
145 | if ( typeof elem === "string" ) {
146 | return jQuery.inArray( this[0], jQuery( elem ) );
147 | }
148 |
149 | // Locate the position of the desired element
150 | return jQuery.inArray(
151 | // If it receives a jQuery object, the first element is used
152 | elem.jquery ? elem[0] : elem, this );
153 | },
154 |
155 | add: function( selector, context ) {
156 | var set = typeof selector === "string" ?
157 | jQuery( selector, context ) :
158 | jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
159 | all = jQuery.merge( this.get(), set );
160 |
161 | return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
162 | all :
163 | jQuery.unique( all ) );
164 | },
165 |
166 | andSelf: function() {
167 | return this.add( this.prevObject );
168 | }
169 | });
170 |
171 | // A painfully simple check to see if an element is disconnected
172 | // from a document (should be improved, where feasible).
173 | function isDisconnected( node ) {
174 | return !node || !node.parentNode || node.parentNode.nodeType === 11;
175 | }
176 |
177 | jQuery.each({
178 | parent: function( elem ) {
179 | var parent = elem.parentNode;
180 | return parent && parent.nodeType !== 11 ? parent : null;
181 | },
182 | parents: function( elem ) {
183 | return jQuery.dir( elem, "parentNode" );
184 | },
185 | parentsUntil: function( elem, i, until ) {
186 | return jQuery.dir( elem, "parentNode", until );
187 | },
188 | next: function( elem ) {
189 | return jQuery.nth( elem, 2, "nextSibling" );
190 | },
191 | prev: function( elem ) {
192 | return jQuery.nth( elem, 2, "previousSibling" );
193 | },
194 | nextAll: function( elem ) {
195 | return jQuery.dir( elem, "nextSibling" );
196 | },
197 | prevAll: function( elem ) {
198 | return jQuery.dir( elem, "previousSibling" );
199 | },
200 | nextUntil: function( elem, i, until ) {
201 | return jQuery.dir( elem, "nextSibling", until );
202 | },
203 | prevUntil: function( elem, i, until ) {
204 | return jQuery.dir( elem, "previousSibling", until );
205 | },
206 | siblings: function( elem ) {
207 | return jQuery.sibling( elem.parentNode.firstChild, elem );
208 | },
209 | children: function( elem ) {
210 | return jQuery.sibling( elem.firstChild );
211 | },
212 | contents: function( elem ) {
213 | return jQuery.nodeName( elem, "iframe" ) ?
214 | elem.contentDocument || elem.contentWindow.document :
215 | jQuery.makeArray( elem.childNodes );
216 | }
217 | }, function( name, fn ) {
218 | jQuery.fn[ name ] = function( until, selector ) {
219 | var ret = jQuery.map( this, fn, until ),
220 | // The variable 'args' was introduced in
221 | // https://github.com/jquery/jquery/commit/52a0238
222 | // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
223 | // http://code.google.com/p/v8/issues/detail?id=1050
224 | args = slice.call(arguments);
225 |
226 | if ( !runtil.test( name ) ) {
227 | selector = until;
228 | }
229 |
230 | if ( selector && typeof selector === "string" ) {
231 | ret = jQuery.filter( selector, ret );
232 | }
233 |
234 | ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
235 |
236 | if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
237 | ret = ret.reverse();
238 | }
239 |
240 | return this.pushStack( ret, name, args.join(",") );
241 | };
242 | });
243 |
244 | jQuery.extend({
245 | filter: function( expr, elems, not ) {
246 | if ( not ) {
247 | expr = ":not(" + expr + ")";
248 | }
249 |
250 | return elems.length === 1 ?
251 | jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
252 | jQuery.find.matches(expr, elems);
253 | },
254 |
255 | dir: function( elem, dir, until ) {
256 | var matched = [],
257 | cur = elem[ dir ];
258 |
259 | while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
260 | if ( cur.nodeType === 1 ) {
261 | matched.push( cur );
262 | }
263 | cur = cur[dir];
264 | }
265 | return matched;
266 | },
267 |
268 | nth: function( cur, result, dir, elem ) {
269 | result = result || 1;
270 | var num = 0;
271 |
272 | for ( ; cur; cur = cur[dir] ) {
273 | if ( cur.nodeType === 1 && ++num === result ) {
274 | break;
275 | }
276 | }
277 |
278 | return cur;
279 | },
280 |
281 | sibling: function( n, elem ) {
282 | var r = [];
283 |
284 | for ( ; n; n = n.nextSibling ) {
285 | if ( n.nodeType === 1 && n !== elem ) {
286 | r.push( n );
287 | }
288 | }
289 |
290 | return r;
291 | }
292 | });
293 |
294 | // Implement the identical functionality for filter and not
295 | function winnow( elements, qualifier, keep ) {
296 |
297 | // Can't pass null or undefined to indexOf in Firefox 4
298 | // Set to 0 to skip string check
299 | qualifier = qualifier || 0;
300 |
301 | if ( jQuery.isFunction( qualifier ) ) {
302 | return jQuery.grep(elements, function( elem, i ) {
303 | var retVal = !!qualifier.call( elem, i, elem );
304 | return retVal === keep;
305 | });
306 |
307 | } else if ( qualifier.nodeType ) {
308 | return jQuery.grep(elements, function( elem, i ) {
309 | return (elem === qualifier) === keep;
310 | });
311 |
312 | } else if ( typeof qualifier === "string" ) {
313 | var filtered = jQuery.grep(elements, function( elem ) {
314 | return elem.nodeType === 1;
315 | });
316 |
317 | if ( isSimple.test( qualifier ) ) {
318 | return jQuery.filter(qualifier, filtered, !keep);
319 | } else {
320 | qualifier = jQuery.filter( qualifier, filtered );
321 | }
322 | }
323 |
324 | return jQuery.grep(elements, function( elem, i ) {
325 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
326 | });
327 | }
328 |
329 | })( jQuery );
330 |
--------------------------------------------------------------------------------
/test/csp.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CSP Test Page
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | CSP Test Page
30 |
31 |
32 |
--------------------------------------------------------------------------------
/test/data/atom+xml.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/test/data/badjson.js:
--------------------------------------------------------------------------------
1 | {bad: 1}
2 |
--------------------------------------------------------------------------------
/test/data/dashboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/data/echoData.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/test/data/echoQuery.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/data/errorWithText.php:
--------------------------------------------------------------------------------
1 |
22 |
--------------------------------------------------------------------------------
/test/data/headers.php:
--------------------------------------------------------------------------------
1 | $value ) {
10 |
11 | $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key );
12 | $headers[ $key ] = $value;
13 |
14 | }
15 |
16 | foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
17 | echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
18 | }
19 |
--------------------------------------------------------------------------------
/test/data/if_modified_since.php:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/test/data/iframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | iframe
4 |
5 |
6 | span text
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/data/json.php:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/test/data/json_obj.js:
--------------------------------------------------------------------------------
1 | { "data": {"lang": "en", "length": 25} }
2 |
--------------------------------------------------------------------------------
/test/data/jsonp.php:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/test/data/name.html:
--------------------------------------------------------------------------------
1 | ERROR
2 |
--------------------------------------------------------------------------------
/test/data/name.php:
--------------------------------------------------------------------------------
1 | $xml $result ";
12 | die();
13 | }
14 | $name = $_REQUEST['name'];
15 | if($name == 'foo') {
16 | echo "bar";
17 | die();
18 | } else if($name == 'peter') {
19 | echo "pan";
20 | die();
21 | }
22 |
23 | echo 'ERROR ';
24 | ?>
--------------------------------------------------------------------------------
/test/data/offset/absolute.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | absolute
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
40 |
41 |
42 | absolute-1
43 |
absolute-1-1
44 |
absolute-1-1-1
45 |
46 |
47 | absolute-2
48 | Has absolute position but no values set for the location ('auto').
49 |
50 | Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.
51 |
52 |
53 |
--------------------------------------------------------------------------------
/test/data/offset/body.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | body
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/test/data/offset/fixed.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | fixed
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | Click the white box to move the marker to it.
43 |
44 |
45 |
--------------------------------------------------------------------------------
/test/data/offset/relative.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | relative
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
34 |
35 |
36 |
37 |
38 |
39 | Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.
40 |
41 |
42 |
--------------------------------------------------------------------------------
/test/data/offset/scroll.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | scroll
7 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
38 |
39 |
40 |
45 |
46 |
47 | Click the white box to move the marker to it.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/test/data/offset/static.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | static
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
34 |
35 |
36 |
37 |
38 |
39 | Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.
40 |
41 |
42 |
--------------------------------------------------------------------------------
/test/data/offset/table.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | table
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
32 |
33 |
34 |
35 |
36 |
37 | th-1
38 | th-2
39 | th-3
40 |
41 |
42 |
43 |
44 | td-1
45 | td-2
46 | td-3
47 |
48 |
49 |
50 |
51 | Click the white box to move the marker to it.
52 |
53 |
54 |
--------------------------------------------------------------------------------
/test/data/params_html.php:
--------------------------------------------------------------------------------
1 |
2 | $value )
4 | echo "$value ";
5 | ?>
6 |
7 |
8 | $value )
10 | echo "$value ";
11 | ?>
12 |
--------------------------------------------------------------------------------
/test/data/readywaitasset.js:
--------------------------------------------------------------------------------
1 | var delayedMessage = "It worked!";
2 |
--------------------------------------------------------------------------------
/test/data/readywaitloader.js:
--------------------------------------------------------------------------------
1 | // Simple script loader that uses jQuery.readyWait via jQuery.holdReady()
2 |
3 | //Hold on jQuery!
4 | jQuery.holdReady(true);
5 |
6 | var readyRegExp = /^(complete|loaded)$/;
7 |
8 | function assetLoaded( evt ){
9 | var node = evt.currentTarget || evt.srcElement;
10 | if ( evt.type === "load" || readyRegExp.test(node.readyState) ) {
11 | jQuery.holdReady(false);
12 | }
13 | }
14 |
15 | setTimeout( function() {
16 | var script = document.createElement("script");
17 | script.type = "text/javascript";
18 | if ( script.addEventListener ) {
19 | script.addEventListener( "load", assetLoaded, false );
20 | } else {
21 | script.attachEvent( "onreadystatechange", assetLoaded );
22 | }
23 | script.src = "data/readywaitasset.js";
24 | document.getElementsByTagName("head")[0].appendChild(script);
25 | }, 2000 );
26 |
--------------------------------------------------------------------------------
/test/data/script.php:
--------------------------------------------------------------------------------
1 |
11 | ok( true, "Script executed correctly." );
12 |
--------------------------------------------------------------------------------
/test/data/selector.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | jQuery selector
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
38 |
39 |
40 |
42 |
43 |
45 |
46 |
59 |
60 |
64 |
65 |
68 |
69 |
71 |
72 |
74 |
75 |
77 |
78 |
80 |
81 |
88 |
My name is Elizabeth .
91 |
92 |
93 |
95 |
96 |
101 |
102 |
103 |
106 |
107 |
108 |
112 |
113 |
115 | blar
118 |
119 |
120 |
122 | Term This is the first definition in compact format.
123 | Term This is the second definition in compact format.
124 |
125 |
126 |
128 |
129 | Scrolling text (non-standard)
132 |
133 |
134 |
--------------------------------------------------------------------------------
/test/data/statusText.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/data/support/bodyBackground.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/test/data/support/boxModelIE.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/test/data/support/hiddenIFrameFF.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/data/support/testElementCrash.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/data/test.html:
--------------------------------------------------------------------------------
1 | html text
2 |
6 |
7 | blabla
8 |
--------------------------------------------------------------------------------
/test/data/test.js:
--------------------------------------------------------------------------------
1 | var foobar = "bar";
2 | jQuery('#ap').html('bar');
3 | ok( true, "test.js executed");
4 |
--------------------------------------------------------------------------------
/test/data/test.php:
--------------------------------------------------------------------------------
1 | html text
2 |
6 |
7 | blabla
--------------------------------------------------------------------------------
/test/data/test2.html:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/test/data/test3.html:
--------------------------------------------------------------------------------
1 | This is a user
2 | This is a user
3 | This is a teacher
4 |
--------------------------------------------------------------------------------
/test/data/testinit.js:
--------------------------------------------------------------------------------
1 | var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
2 | $ = this.$ || "$",
3 | originaljQuery = jQuery,
4 | original$ = $,
5 | amdDefined;
6 |
7 | /**
8 | * Set up a mock AMD define function for testing AMD registration.
9 | */
10 | function define(name, dependencies, callback) {
11 | amdDefined = callback();
12 | }
13 |
14 | define.amd = {
15 | jQuery: true
16 | };
17 |
18 | /**
19 | * Returns an array of elements with the given IDs, eg.
20 | * @example q("main", "foo", "bar")
21 | * @result [,
, ]
22 | */
23 | function q() {
24 | var r = [];
25 |
26 | for ( var i = 0; i < arguments.length; i++ ) {
27 | r.push( document.getElementById( arguments[i] ) );
28 | }
29 |
30 | return r;
31 | }
32 |
33 | /**
34 | * Asserts that a select matches the given IDs * @example t("Check for something", "//[a]", ["foo", "baar"]);
35 | * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
36 | */
37 | function t(a,b,c) {
38 | var f = jQuery(b).get(), s = "";
39 |
40 | for ( var i = 0; i < f.length; i++ ) {
41 | s += (s && ",") + '"' + f[i].id + '"';
42 | }
43 |
44 | same(f, q.apply(q,c), a + " (" + b + ")");
45 | }
46 |
47 | /**
48 | * Add random number to url to stop IE from caching
49 | *
50 | * @example url("data/test.html")
51 | * @result "data/test.html?10538358428943"
52 | *
53 | * @example url("data/test.php?foo=bar")
54 | * @result "data/test.php?foo=bar&10538358345554"
55 | */
56 | function url(value) {
57 | return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
58 | }
59 |
60 | (function () {
61 | // Store the old counts so that we only assert on tests that have actually leaked,
62 | // instead of asserting every time a test has leaked sometime in the past
63 | var oldCacheLength = 0,
64 | oldFragmentsLength = 0,
65 | oldTimersLength = 0,
66 | oldActive = 0;
67 |
68 | /**
69 | * Ensures that tests have cleaned up properly after themselves. Should be passed as the
70 | * teardown function on all modules' lifecycle object.
71 | */
72 | this.moduleTeardown = function () {
73 | var i, fragmentsLength = 0, cacheLength = 0;
74 |
75 | // Allow QUnit.reset to clean up any attached elements before checking for leaks
76 | QUnit.reset();
77 |
78 | for ( i in jQuery.cache ) {
79 | ++cacheLength;
80 | }
81 |
82 | jQuery.fragments = {};
83 |
84 | for ( i in jQuery.fragments ) {
85 | ++fragmentsLength;
86 | }
87 |
88 | // Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test,
89 | // if we unconditionally assert any of these, the test will fail with too many assertions :|
90 | if ( cacheLength !== oldCacheLength ) {
91 | equals( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
92 | oldCacheLength = cacheLength;
93 | }
94 | if ( fragmentsLength !== oldFragmentsLength ) {
95 | equals( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" );
96 | oldFragmentsLength = fragmentsLength;
97 | }
98 | if ( jQuery.timers.length !== oldTimersLength ) {
99 | equals( jQuery.timers.length, oldTimersLength, "No timers are still running" );
100 | oldTimersLength = jQuery.timers.length;
101 | }
102 | if ( jQuery.active !== oldActive ) {
103 | equals( jQuery.active, 0, "No AJAX requests are still active" );
104 | oldActive = jQuery.active;
105 | }
106 | }
107 | }());
--------------------------------------------------------------------------------
/test/data/testrunner.js:
--------------------------------------------------------------------------------
1 | jQuery.noConflict(); // Allow the test to run with other libs or jQuery's.
2 |
3 | // jQuery-specific QUnit.reset
4 | (function() {
5 | var reset = QUnit.reset,
6 | ajaxSettings = jQuery.ajaxSettings;
7 |
8 | QUnit.reset = function() {
9 | reset.apply(this, arguments);
10 | jQuery.event.global = {};
11 | jQuery.ajaxSettings = jQuery.extend({}, ajaxSettings);
12 | };
13 | })();
14 |
15 | // load testswarm agent
16 | (function() {
17 | var url = window.location.search;
18 | url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
19 | if ( !url || url.indexOf("http") !== 0 ) {
20 | return;
21 | }
22 |
23 | // (Temporarily) Disable Ajax tests to reduce network strain
24 | isLocal = QUnit.isLocal = true;
25 |
26 | document.write(" ");
27 | })();
28 |
29 | // QUnit Aliases
30 | (function() {
31 | window.equals = window.equal;
32 | window.same = window.deepEqual;
33 | })();
34 |
--------------------------------------------------------------------------------
/test/data/testsuite.css:
--------------------------------------------------------------------------------
1 | /* for testing opacity set in styles in IE */
2 | ol#empty { opacity: 0; filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); }
3 |
4 | div#fx-tests h4 {
5 | background: red;
6 | }
7 |
8 | div#fx-tests h4.pass {
9 | background: green;
10 | }
11 |
12 | div#fx-tests div.box {
13 | background: red;
14 | overflow: hidden;
15 | border: 2px solid #000;
16 | }
17 |
18 | div#fx-tests div.overflow {
19 | overflow: visible;
20 | }
21 |
22 | div.inline {
23 | display: inline;
24 | }
25 |
26 | div.autoheight {
27 | height: auto;
28 | }
29 |
30 | div.autowidth {
31 | width: auto;
32 | }
33 |
34 | div.autoopacity {
35 | opacity: auto;
36 | }
37 |
38 | div.largewidth {
39 | width: 100px;
40 | }
41 |
42 | div.largeheight {
43 | height: 100px;
44 | }
45 |
46 | div.largeopacity {
47 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
48 | }
49 |
50 | div.medwidth {
51 | width: 50px;
52 | }
53 |
54 | div.medheight {
55 | height: 50px;
56 | }
57 |
58 | div.medopacity {
59 | opacity: 0.5;
60 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
61 | }
62 |
63 | div.nowidth {
64 | width: 0px;
65 | }
66 |
67 | div.noheight {
68 | height: 0px;
69 | }
70 |
71 | div.noopacity {
72 | opacity: 0;
73 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
74 | }
75 |
76 | div.hidden {
77 | display: none;
78 | }
79 |
80 | div#fx-tests div.widewidth {
81 | background-repeat: repeat-x;
82 | }
83 |
84 | div#fx-tests div.wideheight {
85 | background-repeat: repeat-y;
86 | }
87 |
88 | div#fx-tests div.widewidth.wideheight {
89 | background-repeat: repeat;
90 | }
91 |
92 | div#fx-tests div.noback {
93 | background-image: none;
94 | }
95 |
96 | div.chain, div.chain div { width: 100px; height: 20px; position: relative; float: left; }
97 | div.chain div { position: absolute; top: 0px; left: 0px; }
98 |
99 | div.chain.test { background: red; }
100 | div.chain.test div { background: green; }
101 |
102 | div.chain.out { background: green; }
103 | div.chain.out div { background: red; display: none; }
104 |
105 | /* tests to ensure jQuery can determine the native display mode of elements
106 | that have been set as display: none in stylesheets */
107 | div#show-tests * { display: none; }
108 |
109 | #nothiddendiv { font-size: 16px; }
110 | #nothiddendivchild.em { font-size: 2em; }
111 | #nothiddendivchild.prct { font-size: 150%; }
112 |
113 | /* For testing type on vml in IE #7071 */
114 | v\:oval { behavior:url(#default#VML); display:inline-block; }
115 |
116 | /* 8099 changes to default styles are read correctly */
117 | tt { display: none; }
118 | sup { display: none; }
119 | dfn { display: none; }
120 |
121 | /* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */
122 | body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; }
123 |
124 | /* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */
125 | #t6652 div { filter: alpha(opacity=50); }
126 |
--------------------------------------------------------------------------------
/test/data/text.php:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet
2 | consectetuer adipiscing elit
3 | Sed lorem leo
4 | lorem leo consectetuer adipiscing elit
5 | Sed lorem leo
6 | rhoncus sit amet
7 | elementum at
8 | bibendum at, eros
9 | Cras at mi et tortor egestas vestibulum
10 | sed Cras at mi vestibulum
11 | Phasellus sed felis sit amet
12 | orci dapibus semper.
13 |
--------------------------------------------------------------------------------
/test/data/versioncheck.js:
--------------------------------------------------------------------------------
1 | // Run minified source from dist (do make first)
2 | // Should be loaded before QUnit but after src
3 | (function() {
4 | if ( /jquery\=min/.test( window.location.search ) ) {
5 | jQuery.noConflict( true );
6 | document.write(unescape("%3Cscript%20src%3D%27../dist/jquery.min.js%27%3E%3C/script%3E"));
7 | }
8 | })();
--------------------------------------------------------------------------------
/test/data/with_fries.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 1
14 |
15 |
16 |
17 |
18 | foo
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/test/data/with_fries_over_jsonp.php:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/test/delegatetest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Event Delegation Tests
5 |
14 |
32 |
33 |
34 | Delegate Tests (BAD FILE IN URL , x )
35 |
36 |
98 | NOTE: Only IE supports propertychange, beforeactivate, beforedeactivate; buttons do not support change events.
99 |
100 | Submit Tests
101 |
131 |
132 |
205 |
206 |
207 |
--------------------------------------------------------------------------------
/test/hovertest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hover tests
4 |
5 |
32 |
33 |
34 | Hover (mouse{over,out,enter,leave}) Tests
35 | Be sure to try moving the mouse out of the browser via the left side on each test.
36 |
37 |
38 |
39 |
40 | Activate
41 | .hover() in/out: 0 / 0
42 |
43 |
44 | Mouse over here should NOT trigger the counter.
45 |
46 |
47 |
48 |
49 | Activate
50 | Live enter/leave: 0 / 0
51 |
52 |
53 | Mouse over here should NOT trigger the counter.
54 |
55 |
56 |
57 |
58 | Activate
59 | Delegated enter/leave: 0 / 0
60 |
61 |
62 | Mouse over here should NOT trigger the counter.
63 |
64 |
65 |
66 |
67 |
68 | Activate
69 | Bind over/out: 0 / 0
70 |
71 |
72 | Mouse over here SHOULD trigger the counter.
73 |
74 |
75 |
76 |
77 | Activate
78 | Live over/out: 0 / 0
79 |
80 |
81 | Mouse over here SHOULD trigger the counter.
82 |
83 |
84 |
85 |
86 | Activate
87 | Delegated over/out: 0 / 0
88 |
89 |
90 | Mouse over here SHOULD trigger the counter.
91 |
92 |
93 |
94 |
95 |
96 |
157 |
158 |
159 |
--------------------------------------------------------------------------------
/test/localfile.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | jQuery Local File Test
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
32 | jQuery Local File Test
33 |
34 | Introduction
35 |
36 |
37 |
38 | Access this file using the "file:" protocol,
39 |
40 |
41 | two green "OK" strings must appear below,
42 |
43 |
44 | Empty local files will issue errors, it's a known limitation.
45 |
46 |
47 |
48 | Results
49 |
50 |
51 |
52 | Success:
53 |
54 |
55 |
56 |
57 | Error:
58 |
59 |
60 |
61 |
62 |
63 | Logs:
64 |
65 |
67 |
93 |
--------------------------------------------------------------------------------
/test/networkerror.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 | jQuery Network Error Test for Firefox
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
54 |
55 |
56 |
57 | jQuery Network Error Test for Firefox
58 |
59 |
60 | This is a test page for
61 |
62 | #8135
63 |
64 | which was reported in Firefox when accessing properties
65 | of an XMLHttpRequest object after a network error occured.
66 |
67 | Take the following steps:
68 |
69 |
70 | make sure you accessed this page through a web server,
71 |
72 |
73 | stop the web server,
74 |
75 |
76 | open the console,
77 |
78 |
79 | click this
80 | button
81 | ,
82 |
83 |
84 | wait for both requests to fail.
85 |
86 |
87 |
88 | Test passes if you get two log lines:
89 |
90 |
91 | the first starting with "abort",
92 |
93 |
94 | the second starting with "complete",
95 |
96 |
97 |
98 |
99 | Test fails if the browser notifies an exception.
100 |
101 |
102 |
--------------------------------------------------------------------------------
/test/polluted.php:
--------------------------------------------------------------------------------
1 | array(
5 | "versions" => array( "1.1.1", "1.2.0", "1.2.3", "1.3.0", "1.3.1", "1.3.2", "1.4.0", "1.4.1", "1.4.3", "1.5.0" ),
6 | "url" => "dojo/XYZ/dojo/dojo.xd.js"
7 | ),
8 | "ExtCore" => array(
9 | "versions" => array( "3.0.0", "3.1.0" ),
10 | "url" => "ext-core/XYZ/ext-core.js"
11 | ),
12 | "jQuery" => array(
13 | "versions" => array( "1.2.3", "1.2.6", "1.3.0", "1.3.1", "1.3.2", "1.4.0", "1.4.1", "1.4.2", "1.4.3", "1.4.4", "1.5.0" ),
14 | "url" => "jquery/XYZ/jquery.min.js"
15 | ),
16 | "jQueryUI" => array(
17 | "versions" => array( "1.5.2", "1.5.3", "1.6.0", "1.7.0", "1.7.1", "1.7.2", "1.7.3", "1.8.0", "1.8.1", "1.8.2", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9" ),
18 | "url" => "jqueryui/XYZ/jquery-ui.min.js"
19 | ),
20 | "MooTools" => array(
21 | "versions" => array( "1.1.1", "1.1.2", "1.2.1", "1.2.2", "1.2.3", "1.2.4", "1.2.5", "1.3.0" ),
22 | "url" => "mootools/XYZ/mootools-yui-compressed.js"
23 | ),
24 | "Prototype" => array(
25 | "versions" => array( "1.6.0.2", "1.6.0.3", "1.6.1.0", "1.7.0.0" ),
26 | "url" => "prototype/XYZ/prototype.js"
27 | ),
28 | "scriptaculous" => array(
29 | "versions" => array( "1.8.1", "1.8.2", "1.8.3" ),
30 | "url" => "scriptaculous/XYZ/scriptaculous.js"
31 | ),
32 | "SWFObject" => array(
33 | "versions" => array( "2.1", "2.2" ),
34 | "url" => "swfobject/XYZ/swfobject.js"
35 | ),
36 | "YUI" => array(
37 | "versions" => array( "2.6.0", "2.7.0", "2.8.0r4", "2.8.1", "2.8.2", "3.3.0" ),
38 | "url" => "yui/XYZ/build/yui/yui-min.js"
39 | )
40 | );
41 |
42 | if( count($_POST) ) {
43 | $includes = array();
44 | foreach( $_POST as $name => $ver ){
45 | $url = $libraries[ $name ][ "url" ];
46 | if( $name == "YUI" && $ver[0] == "2" ) {
47 | $url = str_replace( "/yui", "/yuiloader", $url, $count = 2 );
48 | }
49 | $include = "\n";
50 | if( $lib == "prototype" ) { // prototype must be included first
51 | array_unshift( $includes, $include );
52 | } else {
53 | array_push( $includes, $include );
54 | }
55 | }
56 |
57 | $includes = implode( "\n", $includes );
58 | $suite = file_get_contents( "index.html" );
59 | echo str_replace( "", $includes, $suite );
60 | exit;
61 | }
62 | ?>
63 |
64 |
65 |
66 |
67 | Run jQuery Test Suite Polluted
68 |
76 |
77 |
78 |
79 |
80 |
81 | Choose other libraries to include
82 |
83 |
84 | $data ) {
86 | echo "$name ";
87 | $i = 0;
88 | foreach( $data[ "versions" ] as $ver ) {
89 | $i++;
90 | echo " $ver ";
91 | if( !($i % 4) ) echo " ";
92 | }
93 | echo " ";
94 | }
95 | ?>
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/test/readywait.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 | jQuery.holdReady Test
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
39 |
40 |
41 |
52 |
53 |
54 |
55 | jQuery.holdReady Test
56 |
57 |
58 | This is a test page for jQuery.readyWait and jQuery.holdReady,
59 | see
60 | #6781
61 | and
62 | #8803 .
63 |
64 |
65 | Test for jQuery.holdReady, which can be used
66 | by plugins and other scripts to indicate something
67 | important to the page is still loading and needs
68 | to block the DOM ready callbacks that are registered
69 | with jQuery.
70 |
71 |
72 | Script loaders are the most likely kind of script
73 | to use jQuery.holdReady, but it could be used by
74 | other things like a script that loads a CSS file
75 | and wants to pause the DOM ready callbacks.
76 |
77 |
78 | Expected Result : The text
79 | It Worked!
80 | appears below after about 2 seconds.
81 |
82 |
83 | If there is an error in the console,
84 | or the text does not show up, then the test failed.
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/test/unit/callbacks.js:
--------------------------------------------------------------------------------
1 | module("callbacks", { teardown: moduleTeardown });
2 |
3 | (function() {
4 |
5 | var output,
6 | addToOutput = function( string ) {
7 | return function() {
8 | output += string;
9 | };
10 | },
11 | outputA = addToOutput( "A" ),
12 | outputB = addToOutput( "B" ),
13 | outputC = addToOutput( "C" ),
14 | tests = {
15 | "": "XABC X XABCABCC X XBB X XABA X",
16 | "once": "XABC X X X X X XABA X",
17 | "memory": "XABC XABC XABCABCCC XA XBB XB XABA XC",
18 | "unique": "XABC X XABCA X XBB X XAB X",
19 | "stopOnFalse": "XABC X XABCABCC X XBB X XA X",
20 | "once memory": "XABC XABC X XA X XA XABA XC",
21 | "once unique": "XABC X X X X X XAB X",
22 | "once stopOnFalse": "XABC X X X X X XA X",
23 | "memory unique": "XABC XA XABCA XA XBB XB XAB XC",
24 | "memory stopOnFalse": "XABC XABC XABCABCCC XA XBB XB XA X",
25 | "unique stopOnFalse": "XABC X XABCA X XBB X XA X"
26 | },
27 | filters = {
28 | "no filter": undefined,
29 | "filter": function( fn ) {
30 | return function() {
31 | return fn.apply( this, arguments );
32 | };
33 | }
34 | };
35 |
36 | jQuery.each( tests, function( flags, resultString ) {
37 |
38 | jQuery.each( filters, function( filterLabel, filter ) {
39 |
40 | test( "jQuery.Callbacks( \"" + flags + "\" ) - " + filterLabel, function() {
41 |
42 | expect( 19 );
43 |
44 | // Give qunit a little breathing room
45 | stop();
46 | setTimeout( start, 0 );
47 |
48 | var cblist;
49 | results = resultString.split( /\s+/ );
50 |
51 | // Basic binding and firing
52 | output = "X";
53 | cblist = jQuery.Callbacks( flags );
54 | cblist.add(function( str ) {
55 | output += str;
56 | });
57 | cblist.fire( "A" );
58 | strictEqual( output, "XA", "Basic binding and firing" );
59 | output = "X";
60 | cblist.disable();
61 | cblist.add(function( str ) {
62 | output += str;
63 | });
64 | strictEqual( output, "X", "Adding a callback after disabling" );
65 | cblist.fire( "A" );
66 | strictEqual( output, "X", "Firing after disabling" );
67 |
68 | // Basic binding and firing (context, arguments)
69 | output = "X";
70 | cblist = jQuery.Callbacks( flags );
71 | cblist.add(function() {
72 | equals( this, window, "Basic binding and firing (context)" );
73 | output += Array.prototype.join.call( arguments, "" );
74 | });
75 | cblist.fireWith( window, [ "A", "B" ] );
76 | strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
77 |
78 | // fireWith with no arguments
79 | output = "";
80 | cblist = jQuery.Callbacks( flags );
81 | cblist.add(function() {
82 | equals( this, window, "fireWith with no arguments (context is window)" );
83 | strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
84 | });
85 | cblist.fireWith();
86 |
87 | // Basic binding, removing and firing
88 | output = "X";
89 | cblist = jQuery.Callbacks( flags );
90 | cblist.add( outputA, outputB, outputC );
91 | cblist.remove( outputB, outputC );
92 | cblist.fire();
93 | strictEqual( output, "XA", "Basic binding, removing and firing" );
94 |
95 | // Empty
96 | output = "X";
97 | cblist = jQuery.Callbacks( flags );
98 | cblist.add( outputA );
99 | cblist.add( outputB );
100 | cblist.add( outputC );
101 | cblist.empty();
102 | cblist.fire();
103 | strictEqual( output, "X", "Empty" );
104 |
105 | // Locking
106 | output = "X";
107 | cblist = jQuery.Callbacks( flags );
108 | cblist.add( function( str ) {
109 | output += str;
110 | });
111 | cblist.lock();
112 | cblist.add( function( str ) {
113 | output += str;
114 | });
115 | cblist.fire( "A" );
116 | cblist.add( function( str ) {
117 | output += str;
118 | });
119 | strictEqual( output, "X", "Lock early" );
120 |
121 | // Ordering
122 | output = "X";
123 | cblist = jQuery.Callbacks( flags );
124 | cblist.add( function() {
125 | cblist.add( outputC );
126 | outputA();
127 | }, outputB );
128 | cblist.fire();
129 | strictEqual( output, results.shift(), "Proper ordering" );
130 |
131 | // Add and fire again
132 | output = "X";
133 | cblist.add( function() {
134 | cblist.add( outputC );
135 | outputA();
136 | }, outputB );
137 | strictEqual( output, results.shift(), "Add after fire" );
138 |
139 | output = "X";
140 | cblist.fire();
141 | strictEqual( output, results.shift(), "Fire again" );
142 |
143 | // Multiple fire
144 | output = "X";
145 | cblist = jQuery.Callbacks( flags );
146 | cblist.add( function( str ) {
147 | output += str;
148 | } );
149 | cblist.fire( "A" );
150 | strictEqual( output, "XA", "Multiple fire (first fire)" );
151 | output = "X";
152 | cblist.add( function( str ) {
153 | output += str;
154 | } );
155 | strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
156 | output = "X";
157 | cblist.fire( "B" );
158 | strictEqual( output, results.shift(), "Multiple fire (second fire)" );
159 | output = "X";
160 | cblist.add( function( str ) {
161 | output += str;
162 | } );
163 | strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
164 |
165 | // Return false
166 | output = "X";
167 | cblist = jQuery.Callbacks( flags );
168 | cblist.add( outputA, function() { return false; }, outputB );
169 | cblist.add( outputA );
170 | cblist.fire();
171 | strictEqual( output, results.shift(), "Callback returning false" );
172 |
173 | // Add another callback (to control lists with memory do not fire anymore)
174 | output = "X";
175 | cblist.add( outputC );
176 | strictEqual( output, results.shift(), "Adding a callback after one returned false" );
177 |
178 | });
179 | });
180 | });
181 |
182 | })();
183 |
--------------------------------------------------------------------------------
/test/unit/deferred.js:
--------------------------------------------------------------------------------
1 | module("deferred", { teardown: moduleTeardown });
2 |
3 | jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
4 |
5 | function createDeferred( fn ) {
6 | return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn );
7 | }
8 |
9 | test("jQuery.Deferred" + withNew, function() {
10 |
11 | expect( 20 );
12 |
13 | createDeferred().resolve().then( function() {
14 | ok( true , "Success on resolve" );
15 | ok( this.isResolved(), "Deferred is resolved" );
16 | }, function() {
17 | ok( false , "Error on resolve" );
18 | }).always( function() {
19 | ok( true , "Always callback on resolve" );
20 | });
21 |
22 | createDeferred().reject().then( function() {
23 | ok( false , "Success on reject" );
24 | }, function() {
25 | ok( true , "Error on reject" );
26 | ok( this.isRejected(), "Deferred is rejected" );
27 | }).always( function() {
28 | ok( true , "Always callback on reject" );
29 | });
30 |
31 | createDeferred( function( defer ) {
32 | ok( this === defer , "Defer passed as this & first argument" );
33 | this.resolve( "done" );
34 | }).then( function( value ) {
35 | strictEqual( value , "done" , "Passed function executed" );
36 | });
37 |
38 | jQuery.each( "resolve reject".split( " " ), function( _, change ) {
39 | createDeferred( function( defer ) {
40 | ok( defer.isPending(), "pending after creation" );
41 | var checked = 0;
42 | defer.progress(function( value ) {
43 | strictEqual( value, checked, "Progress: right value (" + value + ") received" );
44 | });
45 | for( checked = 0; checked < 3 ; checked++ ) {
46 | defer.notify( checked );
47 | }
48 | ok( defer.isPending(), "pending after notification" );
49 | defer[ change ]();
50 | ok( !defer.isPending(), "not pending after " + change );
51 | defer.notify();
52 | });
53 | });
54 | });
55 | } );
56 |
57 | test( "jQuery.Deferred.pipe - filtering (done)", function() {
58 |
59 | expect(4);
60 |
61 | var defer = jQuery.Deferred(),
62 | piped = defer.pipe(function( a, b ) {
63 | return a * b;
64 | }),
65 | value1,
66 | value2,
67 | value3;
68 |
69 | piped.done(function( result ) {
70 | value3 = result;
71 | });
72 |
73 | defer.done(function( a, b ) {
74 | value1 = a;
75 | value2 = b;
76 | });
77 |
78 | defer.resolve( 2, 3 );
79 |
80 | strictEqual( value1, 2, "first resolve value ok" );
81 | strictEqual( value2, 3, "second resolve value ok" );
82 | strictEqual( value3, 6, "result of filter ok" );
83 |
84 | jQuery.Deferred().reject().pipe(function() {
85 | ok( false, "pipe should not be called on reject" );
86 | });
87 |
88 | jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) {
89 | strictEqual( value, undefined, "pipe done callback can return undefined/null" );
90 | });
91 | });
92 |
93 | test( "jQuery.Deferred.pipe - filtering (fail)", function() {
94 |
95 | expect(4);
96 |
97 | var defer = jQuery.Deferred(),
98 | piped = defer.pipe( null, function( a, b ) {
99 | return a * b;
100 | } ),
101 | value1,
102 | value2,
103 | value3;
104 |
105 | piped.fail(function( result ) {
106 | value3 = result;
107 | });
108 |
109 | defer.fail(function( a, b ) {
110 | value1 = a;
111 | value2 = b;
112 | });
113 |
114 | defer.reject( 2, 3 );
115 |
116 | strictEqual( value1, 2, "first reject value ok" );
117 | strictEqual( value2, 3, "second reject value ok" );
118 | strictEqual( value3, 6, "result of filter ok" );
119 |
120 | jQuery.Deferred().resolve().pipe( null, function() {
121 | ok( false, "pipe should not be called on resolve" );
122 | } );
123 |
124 | jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) {
125 | strictEqual( value, undefined, "pipe fail callback can return undefined/null" );
126 | });
127 | });
128 |
129 | test( "jQuery.Deferred.pipe - filtering (progress)", function() {
130 |
131 | expect(3);
132 |
133 | var defer = jQuery.Deferred(),
134 | piped = defer.pipe( null, null, function( a, b ) {
135 | return a * b;
136 | } ),
137 | value1,
138 | value2,
139 | value3;
140 |
141 | piped.progress(function( result ) {
142 | value3 = result;
143 | });
144 |
145 | defer.progress(function( a, b ) {
146 | value1 = a;
147 | value2 = b;
148 | });
149 |
150 | defer.notify( 2, 3 );
151 |
152 | strictEqual( value1, 2, "first progress value ok" );
153 | strictEqual( value2, 3, "second progress value ok" );
154 | strictEqual( value3, 6, "result of filter ok" );
155 | });
156 |
157 | test( "jQuery.Deferred.pipe - deferred (done)", function() {
158 |
159 | expect(3);
160 |
161 | var defer = jQuery.Deferred(),
162 | piped = defer.pipe(function( a, b ) {
163 | return jQuery.Deferred(function( defer ) {
164 | defer.reject( a * b );
165 | });
166 | }),
167 | value1,
168 | value2,
169 | value3;
170 |
171 | piped.fail(function( result ) {
172 | value3 = result;
173 | });
174 |
175 | defer.done(function( a, b ) {
176 | value1 = a;
177 | value2 = b;
178 | });
179 |
180 | defer.resolve( 2, 3 );
181 |
182 | strictEqual( value1, 2, "first resolve value ok" );
183 | strictEqual( value2, 3, "second resolve value ok" );
184 | strictEqual( value3, 6, "result of filter ok" );
185 | });
186 |
187 | test( "jQuery.Deferred.pipe - deferred (fail)", function() {
188 |
189 | expect(3);
190 |
191 | var defer = jQuery.Deferred(),
192 | piped = defer.pipe( null, function( a, b ) {
193 | return jQuery.Deferred(function( defer ) {
194 | defer.resolve( a * b );
195 | });
196 | } ),
197 | value1,
198 | value2,
199 | value3;
200 |
201 | piped.done(function( result ) {
202 | value3 = result;
203 | });
204 |
205 | defer.fail(function( a, b ) {
206 | value1 = a;
207 | value2 = b;
208 | });
209 |
210 | defer.reject( 2, 3 );
211 |
212 | strictEqual( value1, 2, "first reject value ok" );
213 | strictEqual( value2, 3, "second reject value ok" );
214 | strictEqual( value3, 6, "result of filter ok" );
215 | });
216 |
217 | test( "jQuery.Deferred.pipe - deferred (progress)", function() {
218 |
219 | expect(3);
220 |
221 | var defer = jQuery.Deferred(),
222 | piped = defer.pipe( null, null, function( a, b ) {
223 | return jQuery.Deferred(function( defer ) {
224 | defer.resolve( a * b );
225 | });
226 | } ),
227 | value1,
228 | value2,
229 | value3;
230 |
231 | piped.done(function( result ) {
232 | value3 = result;
233 | });
234 |
235 | defer.progress(function( a, b ) {
236 | value1 = a;
237 | value2 = b;
238 | });
239 |
240 | defer.notify( 2, 3 );
241 |
242 | strictEqual( value1, 2, "first progress value ok" );
243 | strictEqual( value2, 3, "second progress value ok" );
244 | strictEqual( value3, 6, "result of filter ok" );
245 | });
246 |
247 | test( "jQuery.Deferred.pipe - context", function() {
248 |
249 | expect(4);
250 |
251 | var context = {};
252 |
253 | jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(function( value ) {
254 | return value * 3;
255 | }).done(function( value ) {
256 | strictEqual( this, context, "custom context correctly propagated" );
257 | strictEqual( value, 6, "proper value received" );
258 | });
259 |
260 | var defer = jQuery.Deferred(),
261 | piped = defer.pipe(function( value ) {
262 | return value * 3;
263 | });
264 |
265 | defer.resolve( 2 );
266 |
267 | piped.done(function( value ) {
268 | strictEqual( this.promise(), piped, "default context gets updated to latest defer in the chain" );
269 | strictEqual( value, 6, "proper value received" );
270 | });
271 | });
272 |
273 | test( "jQuery.when" , function() {
274 |
275 | expect( 23 );
276 |
277 | // Some other objects
278 | jQuery.each( {
279 |
280 | "an empty string": "",
281 | "a non-empty string": "some string",
282 | "zero": 0,
283 | "a number other than zero": 1,
284 | "true": true,
285 | "false": false,
286 | "null": null,
287 | "undefined": undefined,
288 | "a plain object": {}
289 |
290 | } , function( message , value ) {
291 |
292 | ok( jQuery.isFunction( jQuery.when( value ).done(function( resolveValue ) {
293 | strictEqual( resolveValue , value , "Test the promise was resolved with " + message );
294 | }).promise ) , "Test " + message + " triggers the creation of a new Promise" );
295 |
296 | } );
297 |
298 | ok( jQuery.isFunction( jQuery.when().done(function( resolveValue ) {
299 | strictEqual( resolveValue , undefined , "Test the promise was resolved with no parameter" );
300 | }).promise ) , "Test calling when with no parameter triggers the creation of a new Promise" );
301 |
302 | var cache, i;
303 |
304 | for( i = 1 ; i < 4 ; i++ ) {
305 | jQuery.when( cache || jQuery.Deferred( function() {
306 | this.resolve( i );
307 | }) ).done(function( value ) {
308 | strictEqual( value , 1 , "Function executed" + ( i > 1 ? " only once" : "" ) );
309 | cache = value;
310 | });
311 | }
312 | });
313 |
314 | test("jQuery.when - joined", function() {
315 |
316 | expect(53);
317 |
318 | var deferreds = {
319 | value: 1,
320 | success: jQuery.Deferred().resolve( 1 ),
321 | error: jQuery.Deferred().reject( 0 ),
322 | futureSuccess: jQuery.Deferred().notify( true ),
323 | futureError: jQuery.Deferred().notify( true ),
324 | notify: jQuery.Deferred().notify( true )
325 | },
326 | willSucceed = {
327 | value: true,
328 | success: true,
329 | futureSuccess: true
330 | },
331 | willError = {
332 | error: true,
333 | futureError: true
334 | },
335 | willNotify = {
336 | futureSuccess: true,
337 | futureError: true,
338 | notify: true
339 | };
340 |
341 | jQuery.each( deferreds, function( id1, defer1 ) {
342 | jQuery.each( deferreds, function( id2, defer2 ) {
343 | var shouldResolve = willSucceed[ id1 ] && willSucceed[ id2 ],
344 | shouldError = willError[ id1 ] || willError[ id2 ],
345 | shouldNotify = willNotify[ id1 ] || willNotify[ id2 ],
346 | expected = shouldResolve ? [ 1, 1 ] : [ 0, undefined ],
347 | expectedNotify = shouldNotify && [ willNotify[ id1 ], willNotify[ id2 ] ],
348 | code = id1 + "/" + id2;
349 |
350 | var promise = jQuery.when( defer1, defer2 ).done(function( a, b ) {
351 | if ( shouldResolve ) {
352 | same( [ a, b ], expected, code + " => resolve" );
353 | } else {
354 | ok( false , code + " => resolve" );
355 | }
356 | }).fail(function( a, b ) {
357 | if ( shouldError ) {
358 | same( [ a, b ], expected, code + " => reject" );
359 | } else {
360 | ok( false , code + " => reject" );
361 | }
362 | }).progress(function progress( a, b ) {
363 | same( [ a, b ], expectedNotify, code + " => progress" );
364 | });
365 | } );
366 | } );
367 | deferreds.futureSuccess.resolve( 1 );
368 | deferreds.futureError.reject( 0 );
369 | });
370 |
--------------------------------------------------------------------------------
/test/unit/queue.js:
--------------------------------------------------------------------------------
1 | module("queue", { teardown: moduleTeardown });
2 |
3 | test("queue() with other types",function() {
4 | expect(11);
5 | var counter = 0;
6 |
7 | stop();
8 |
9 | var $div = jQuery({}),
10 | defer;
11 |
12 | $div.promise("foo").done(function() {
13 | equals( counter, 0, "Deferred for collection with no queue is automatically resolved" );
14 | });
15 |
16 | $div
17 | .queue("foo",function(){
18 | equals( ++counter, 1, "Dequeuing" );
19 | jQuery.dequeue(this,"foo");
20 | })
21 | .queue("foo",function(){
22 | equals( ++counter, 2, "Dequeuing" );
23 | jQuery(this).dequeue("foo");
24 | })
25 | .queue("foo",function(){
26 | equals( ++counter, 3, "Dequeuing" );
27 | })
28 | .queue("foo",function(){
29 | equals( ++counter, 4, "Dequeuing" );
30 | });
31 |
32 | defer = $div.promise("foo").done(function() {
33 | equals( counter, 4, "Testing previous call to dequeue in deferred" );
34 | start();
35 | });
36 |
37 | equals( $div.queue("foo").length, 4, "Testing queue length" );
38 |
39 | $div.dequeue("foo");
40 |
41 | equals( counter, 3, "Testing previous call to dequeue" );
42 | equals( $div.queue("foo").length, 1, "Testing queue length" );
43 |
44 | $div.dequeue("foo");
45 |
46 | equals( counter, 4, "Testing previous call to dequeue" );
47 | equals( $div.queue("foo").length, 0, "Testing queue length" );
48 | });
49 |
50 | test("queue(name) passes in the next item in the queue as a parameter", function() {
51 | expect(2);
52 |
53 | var div = jQuery({});
54 | var counter = 0;
55 |
56 | div.queue("foo", function(next) {
57 | equals(++counter, 1, "Dequeueing");
58 | next();
59 | }).queue("foo", function(next) {
60 | equals(++counter, 2, "Next was called");
61 | next();
62 | }).queue("bar", function() {
63 | equals(++counter, 3, "Other queues are not triggered by next()")
64 | });
65 |
66 | div.dequeue("foo");
67 | });
68 |
69 | test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
70 | expect(3);
71 | stop();
72 |
73 | var div = jQuery({});
74 | var counter = 0;
75 |
76 | div.queue(function(next) {
77 | equals(++counter, 1, "Dequeueing");
78 | var self = this;
79 | setTimeout(function() { next() }, 500);
80 | }).queue(function(next) {
81 | equals(++counter, 2, "Next was called");
82 | next();
83 | }).queue("bar", function() {
84 | equals(++counter, 3, "Other queues are not triggered by next()")
85 | });
86 |
87 | jQuery.when( div.promise("fx"), div ).done(function() {
88 | equals(counter, 2, "Deferreds resolved");
89 | start();
90 | });
91 | });
92 |
93 | test("callbacks keep their place in the queue", function() {
94 | expect(5);
95 | stop();
96 | var div = jQuery(""),
97 | counter = 0;
98 |
99 | div.queue(function( next ) {
100 | equal( ++counter, 1, "Queue/callback order: first called" );
101 | setTimeout( next, 200 );
102 | }).show(100, function() {
103 | equal( ++counter, 2, "Queue/callback order: second called" );
104 | jQuery(this).hide(100, function() {
105 | equal( ++counter, 4, "Queue/callback order: fourth called" );
106 | });
107 | }).queue(function( next ) {
108 | equal( ++counter, 3, "Queue/callback order: third called" );
109 | next();
110 | });
111 |
112 | div.promise("fx").done(function() {
113 | equals(counter, 4, "Deferreds resolved");
114 | start();
115 | });
116 | });
117 |
118 | test("delay()", function() {
119 | expect(2);
120 | stop();
121 |
122 | var foo = jQuery({}), run = 0;
123 |
124 | foo.delay(100).queue(function(){
125 | run = 1;
126 | ok( true, "The function was dequeued." );
127 | start();
128 | });
129 |
130 | equals( run, 0, "The delay delayed the next function from running." );
131 | });
132 |
133 | test("delay() can be stopped", function() {
134 | expect( 3 );
135 | stop();
136 |
137 | var foo = jQuery({}), run = 0;
138 |
139 | foo
140 | .queue( "alternate", function( next ) {
141 | run++;
142 | ok( true, "This first function was dequeued" );
143 | next();
144 | })
145 | .delay( 100, "alternate" )
146 | .queue( "alternate", function() {
147 | run++;
148 | ok( true, "The function was dequeued immediately, the delay was stopped" );
149 | })
150 | .dequeue( "alternate" )
151 |
152 | // stop( false ) will NOT clear the queue, so it should automatically dequeue the next
153 | .stop( false, false, "alternate" )
154 |
155 | // this test
156 | .delay( 100 )
157 | .queue(function() {
158 | run++;
159 | ok( false, "This queue should never run" );
160 | })
161 |
162 | // stop( clearQueue ) should clear the queue
163 | .stop( true, false );
164 |
165 | equal( run, 2, "Queue ran the proper functions" );
166 |
167 | setTimeout( start, 200 );
168 | });
169 |
170 |
171 | test("clearQueue(name) clears the queue", function() {
172 | expect(2);
173 |
174 | stop()
175 |
176 | var div = jQuery({});
177 | var counter = 0;
178 |
179 | div.queue("foo", function(next) {
180 | counter++;
181 | jQuery(this).clearQueue("foo");
182 | next();
183 | }).queue("foo", function(next) {
184 | counter++;
185 | });
186 |
187 | div.promise("foo").done(function() {
188 | ok( true, "dequeue resolves the deferred" );
189 | start();
190 | });
191 |
192 | div.dequeue("foo");
193 |
194 | equals(counter, 1, "the queue was cleared");
195 | });
196 |
197 | test("clearQueue() clears the fx queue", function() {
198 | expect(1);
199 |
200 | var div = jQuery({});
201 | var counter = 0;
202 |
203 | div.queue(function(next) {
204 | counter++;
205 | var self = this;
206 | setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
207 | }).queue(function(next) {
208 | counter++;
209 | });
210 |
211 | equals(counter, 1, "the queue was cleared");
212 |
213 | div.removeData();
214 | });
215 |
216 | test("_mark() and _unmark()", function() {
217 | expect(1);
218 |
219 | var div = {},
220 | $div = jQuery( div );
221 |
222 | stop();
223 |
224 | jQuery._mark( div, "foo" );
225 | jQuery._mark( div, "foo" );
226 | jQuery._unmark( div, "foo" );
227 | jQuery._unmark( div, "foo" );
228 |
229 | $div.promise( "foo" ).done(function() {
230 | ok( true, "No more marks" );
231 | start();
232 | });
233 | });
234 |
235 | test("_mark() and _unmark() default to 'fx'", function() {
236 | expect(1);
237 |
238 | var div = {},
239 | $div = jQuery( div );
240 |
241 | stop();
242 |
243 | jQuery._mark( div );
244 | jQuery._mark( div );
245 | jQuery._unmark( div, "fx" );
246 | jQuery._unmark( div );
247 |
248 | $div.promise().done(function() {
249 | ok( true, "No more marks" );
250 | start();
251 | });
252 | });
253 |
254 | test("promise()", function() {
255 | expect(1);
256 |
257 | stop();
258 |
259 | var objects = [];
260 |
261 | jQuery.each( [{}, {}], function( i, div ) {
262 | var $div = jQuery( div );
263 | $div.queue(function( next ) {
264 | setTimeout( function() {
265 | if ( i ) {
266 | next();
267 | setTimeout( function() {
268 | jQuery._unmark( div );
269 | }, 20 );
270 | } else {
271 | jQuery._unmark( div );
272 | setTimeout( function() {
273 | next();
274 | }, 20 );
275 | }
276 | }, 50 );
277 | }).queue(function( next ) {
278 | next();
279 | });
280 | jQuery._mark( div );
281 | objects.push( $div );
282 | });
283 |
284 | jQuery.when.apply( jQuery, objects ).done(function() {
285 | ok( true, "Deferred resolved" );
286 | start();
287 | });
288 |
289 | jQuery.each( objects, function() {
290 | this.dequeue();
291 | });
292 | });
--------------------------------------------------------------------------------
/test/unit/selector.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This test page is for selector tests that address selector issues that have already been addressed in jQuery functions
3 | * and which only work because jQuery has hooked into Sizzle.
4 | * These tests may or may not fail in an independent Sizzle.
5 | */
6 |
7 | module("selector - jQuery only", { teardown: moduleTeardown });
8 |
9 | /**
10 | * Loads an iframe for the selector context
11 | * @param {String} fileName - Name of the html file to load
12 | * @param {String} name - Test name
13 | * @param {Function} fn - Test callback containing the tests to run
14 | */
15 | var testIframe = function( fileName, name, fn ) {
16 |
17 | var loadFixture = function() {
18 |
19 | // Creates iframe with cache disabled
20 | var src = "./data/" + fileName + ".html?" + parseInt( Math.random()*1000, 10 ),
21 | iframe = jQuery("
").css({
22 | width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden"
23 | }).appendTo("body")[0];
24 | iframe.contentWindow.location = src;
25 | return iframe;
26 | };
27 |
28 | test(name, function() {
29 | // pause execution for now
30 | stop();
31 |
32 | // load fixture in iframe
33 | var iframe = loadFixture(),
34 | win = iframe.contentWindow,
35 | interval = setInterval( function() {
36 | if ( win && win.jQuery && win.jQuery.isReady ) {
37 | clearInterval( interval );
38 | // continue
39 | start();
40 | // call actual tests passing the correct jQuery instance to use
41 | fn.call( this, win.jQuery, win );
42 | document.body.removeChild( iframe );
43 | iframe = null;
44 | }
45 | }, 15 );
46 | });
47 | };
48 |
49 | testIframe("selector", "attributes - jQuery.attr", function( jQuery, window ) {
50 | expect(34);
51 |
52 | var document = window.document;
53 |
54 | /**
55 | * Returns an array of elements with the given IDs, eg.
56 | */
57 | var q = function() {
58 | var r = [];
59 |
60 | for ( var i = 0; i < arguments.length; i++ ) {
61 | r.push( document.getElementById( arguments[i] ) );
62 | }
63 |
64 | return r;
65 | };
66 |
67 | /**
68 | * Asserts that a select matches the given IDs * @example t("Check for something", "//[a]", ["foo", "baar"]);
69 | * @param {String} a - Assertion name
70 | * @param {String} b - Sizzle selector
71 | * @param {String} c - Array of ids to construct what is expected
72 | */
73 | var t = function( a, b, c ) {
74 | var f = jQuery(b).get(), s = "";
75 |
76 | for ( var i = 0; i < f.length; i++ ) {
77 | s += (s && ",") + '"' + f[i].id + '"';
78 | }
79 |
80 | deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
81 | };
82 |
83 | // ====== All known boolean attributes, including html5 booleans ======
84 | // autobuffer, autofocus, autoplay, async, checked,
85 | // compact, controls, declare, defer, disabled,
86 | // formnovalidate, hidden, indeterminate (property only),
87 | // ismap, itemscope, loop, multiple, muted, nohref, noresize,
88 | // noshade, nowrap, novalidate, open, pubdate, readonly, required,
89 | // reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object)
90 |
91 | t( "Attribute Exists", "[autobuffer]", ["video1"]);
92 | t( "Attribute Exists", "[autofocus]", ["text1"]);
93 | t( "Attribute Exists", "[autoplay]", ["video1"]);
94 | t( "Attribute Exists", "[async]", ["script1"]);
95 | t( "Attribute Exists", "[checked]", ["check1"]);
96 | t( "Attribute Exists", "[compact]", ["dl"]);
97 | t( "Attribute Exists", "[controls]", ["video1"]);
98 | t( "Attribute Exists", "[declare]", ["object1"]);
99 | t( "Attribute Exists", "[defer]", ["script1"]);
100 | t( "Attribute Exists", "[disabled]", ["check1"]);
101 | t( "Attribute Exists", "[formnovalidate]", ["form1"]);
102 | t( "Attribute Exists", "[hidden]", ["div1"]);
103 | t( "Attribute Exists", "[indeterminate]", []);
104 | t( "Attribute Exists", "[ismap]", ["img1"]);
105 | t( "Attribute Exists", "[itemscope]", ["div1"]);
106 | // t( "Attribute Exists", "[loop]", ["video1"]); // IE 6/7 cannot differentiate here. loop is also used on img, input, and marquee tags as well as video/audio. getAttributeNode unfortunately only retrieves the property value.
107 | t( "Attribute Exists", "[multiple]", ["select1"]);
108 | t( "Attribute Exists", "[muted]", ["audio1"]);
109 | // t( "Attribute Exists", "[nohref]", ["area1"]); // IE 6/7 keep this set to false regardless of presence. The attribute node is not retrievable.
110 | t( "Attribute Exists", "[noresize]", ["textarea1"]);
111 | t( "Attribute Exists", "[noshade]", ["hr1"]);
112 | t( "Attribute Exists", "[nowrap]", ["td1", "div1"]);
113 | t( "Attribute Exists", "[novalidate]", ["form1"]);
114 | t( "Attribute Exists", "[open]", ["details1"]);
115 | t( "Attribute Exists", "[pubdate]", ["article1"]);
116 | t( "Attribute Exists", "[readonly]", ["text1"]);
117 | t( "Attribute Exists", "[required]", ["text1"]);
118 | t( "Attribute Exists", "[reversed]", ["ol1"]);
119 | t( "Attribute Exists", "[scoped]", ["style1"]);
120 | t( "Attribute Exists", "[seamless]", ["iframe1"]);
121 | // t( "Attribute Exists", "[selected]", ["option1"]); // IE8's querySelectorAll fails here. Redirecting to oldSizzle would work, but it would require an additional support test as well as a check for the selected attribute within the qsa logic
122 | t( "Attribute Exists", "[truespeed]", ["marquee1"]);
123 |
124 | // Enumerated attributes (these are not boolean content attributes)
125 | jQuery.each([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
126 | t( "Enumerated attribute", "[" + val + "]", ["div1"]);
127 | });
128 | t( "Enumerated attribute", "[spellcheck]", ["span1"]);
129 |
130 | // t( "tabindex selector does not retrieve all elements in IE6/7(#8473)", "form, [tabindex]", ["form1", "text1"]); // Uncomment this when the tabindex attrHook is deprecated
131 |
132 | t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"]);
133 | });
134 |
--------------------------------------------------------------------------------
/test/unit/support.js:
--------------------------------------------------------------------------------
1 | module("support", { teardown: moduleTeardown });
2 |
3 | function supportIFrameTest( title, url, noDisplay, func ) {
4 |
5 | if ( noDisplay !== true ) {
6 | func = noDisplay;
7 | noDisplay = false;
8 | }
9 |
10 | test( title, function() {
11 | var iframe;
12 |
13 | stop();
14 | window.supportCallback = function() {
15 | var self = this,
16 | args = arguments;
17 | setTimeout( function() {
18 | window.supportCallback = undefined;
19 | iframe.remove();
20 | func.apply( self, args );
21 | start();
22 | }, 0 );
23 | };
24 | iframe = jQuery( "
" ).css( "display", noDisplay ? "none" : "block" ).append(
25 | jQuery( "
" ).attr( "src", "data/support/" + url + ".html" )
26 | ).appendTo( "body" );
27 | });
28 | }
29 |
30 | supportIFrameTest( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "boxModelIE", function( compatMode, boxModel ) {
31 | ok( compatMode !== "CSS1Compat" || boxModel, "boxModel properly detected" );
32 | });
33 |
34 | supportIFrameTest( "body background is not lost if set prior to loading jQuery (#9238)", "bodyBackground", function( color, support ) {
35 | expect( 2 );
36 | var okValue = {
37 | "#000000": true,
38 | "rgb(0, 0, 0)": true
39 | };
40 | ok( okValue[ color ], "color was not reset (" + color + ")" );
41 | var i, passed = true;
42 | for ( i in jQuery.support ) {
43 | if ( jQuery.support[ i ] !== support[ i ] ) {
44 | passed = false;
45 | strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
46 | }
47 | }
48 | for ( i in support ) {
49 | if ( !( i in jQuery.support ) ) {
50 | passed = false;
51 | strictEqual( src[ i ], dest[ i ], "Unexpected property: " + i );
52 | }
53 | }
54 | ok( passed, "Same support properties" );
55 | });
56 |
57 | supportIFrameTest( "A background on the testElement does not cause IE8 to crash (#9823)", "testElementCrash", function() {
58 | expect(1);
59 | ok( true, "IE8 does not crash" );
60 | });
61 |
--------------------------------------------------------------------------------
/test/xhtml.php:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 1.7pre
--------------------------------------------------------------------------------