1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

merge from dev

This commit is contained in:
Luke Pulverenti 2016-01-12 14:55:45 -05:00
parent 9e1a2cf66a
commit 189942e289
298 changed files with 53049 additions and 5413 deletions

View file

@ -16,12 +16,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.0.21", "version": "1.0.24",
"_release": "1.0.21", "_release": "1.0.24",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.0.21", "tag": "1.0.24",
"commit": "e341b097c05c31ec012e04dfbd0455ae9dfc4929" "commit": "4b9b655cad98bd908e78352d5bbed028644505d4"
}, },
"_source": "git://github.com/MediaBrowser/Emby.ApiClient.Javascript.git", "_source": "git://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "~1.0.3", "_target": "~1.0.3",

View file

@ -1123,7 +1123,7 @@
if (options.updateDateLastAccessed !== false) { if (options.updateDateLastAccessed !== false) {
server.DateLastAccessed = new Date().getTime(); server.DateLastAccessed = new Date().getTime();
if (server.LastConnectionMode == ConnectionMode.Local) { if (connectionMode == ConnectionMode.Local) {
server.DateLastLocalConnection = new Date().getTime(); server.DateLastLocalConnection = new Date().getTime();
} }
} }
@ -1466,6 +1466,17 @@
self.getRegistrationInfo = function (feature, apiClient) { self.getRegistrationInfo = function (feature, apiClient) {
if (isConnectUserSupporter()) {
return new Promise(function (resolve, reject) {
resolve({
Name: feature,
IsRegistered: true,
IsTrial: false
});
});
}
return self.getAvailableServers().then(function (servers) { return self.getAvailableServers().then(function (servers) {
var matchedServers = servers.filter(function (s) { var matchedServers = servers.filter(function (s) {
@ -1498,6 +1509,19 @@
}); });
}; };
function isConnectUserSupporter() {
if (self.isLoggedIntoConnect()) {
var connectUser = self.connectUser();
if (connectUser && connectUser.IsSupporter) {
return true;
}
}
return false;
}
function updateDateLastLocalConnection(serverId) { function updateDateLastLocalConnection(serverId) {
var credentials = credentialProvider.credentials(); var credentials = credentialProvider.credentials();

View file

@ -15,12 +15,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.0.14", "version": "1.0.16",
"_release": "1.0.14", "_release": "1.0.16",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.0.14", "tag": "1.0.16",
"commit": "a7a8baf260ab509c5f9b1750cbf6fe921883141c" "commit": "8058a1a93ad995fd3b7f56019719c33654698df6"
}, },
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git", "_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "~1.0.0", "_target": "~1.0.0",

View file

@ -103,12 +103,23 @@
profile.DirectPlayProfiles = []; profile.DirectPlayProfiles = [];
var videoAudioCodecs = [];
if (canPlayMp3) {
videoAudioCodecs.push('mp3');
}
if (canPlayAac) {
videoAudioCodecs.push('aac');
}
if (canPlayAc3) {
videoAudioCodecs.push('ac3');
}
if (supportedFormats.indexOf('h264') != -1) { if (supportedFormats.indexOf('h264') != -1) {
profile.DirectPlayProfiles.push({ profile.DirectPlayProfiles.push({
Container: 'mp4,m4v', Container: 'mp4,m4v',
Type: 'Video', Type: 'Video',
VideoCodec: 'h264', VideoCodec: 'h264',
AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') AudioCodec: videoAudioCodecs.join(',')
}); });
} }
@ -117,7 +128,7 @@
Container: 'mkv,mov', Container: 'mkv,mov',
Type: 'Video', Type: 'Video',
VideoCodec: 'h264', VideoCodec: 'h264',
AudioCodec: 'aac' + (canPlayMp3 ? ',mp3' : '') + (canPlayAc3 ? ',ac3' : '') AudioCodec: videoAudioCodecs.join(',')
}); });
} }
@ -268,24 +279,6 @@
] ]
}); });
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac,mp3',
Conditions: [
{
Condition: 'LessThanEqual',
Property: 'AudioChannels',
Value: videoAudioChannels
},
{
Condition: 'Equals',
Property: 'IsSecondaryAudio',
Value: 'false',
IsRequired: 'false'
}
]
});
profile.CodecProfiles.push({ profile.CodecProfiles.push({
Type: 'VideoAudio', Type: 'VideoAudio',
Conditions: [ Conditions: [

View file

@ -0,0 +1,34 @@
define([], function () {
/**
* Copyright 2012, Digital Fusion
* Licensed under the MIT license.
* http://teamdf.com/jquery-plugins/license/
*
* @author Sam Sehnert
* @desc A small plugin that checks whether elements are within
* the user visible viewport of a web browser.
* only accounts for vertical position, not horizontal.
*/
function visibleInViewport(elem, partial, thresholdX, thresholdY) {
thresholdX = thresholdX || 0;
thresholdY = thresholdY || 0;
var vpWidth = window.innerWidth,
vpHeight = window.innerHeight;
// Use this native browser method, if available.
var rec = elem.getBoundingClientRect(),
tViz = rec.top >= 0 && rec.top < vpHeight + thresholdY,
bViz = rec.bottom > 0 && rec.bottom <= vpHeight + thresholdY,
lViz = rec.left >= 0 && rec.left < vpWidth + thresholdX,
rViz = rec.right > 0 && rec.right <= vpWidth + thresholdX,
vVisible = partial ? tViz || bViz : tViz && bViz,
hVisible = partial ? lViz || rViz : lViz && rViz;
return vVisible && hVisible;
}
return visibleInViewport;
});

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-a11y-keys-behavior", "name": "iron-a11y-keys-behavior",
"version": "1.1.0", "version": "1.1.1",
"description": "A behavior that enables keybindings for greater a11y.", "description": "A behavior that enables keybindings for greater a11y.",
"keywords": [ "keywords": [
"web-components", "web-components",
@ -31,11 +31,11 @@
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/polymerelements/iron-a11y-keys-behavior", "homepage": "https://github.com/polymerelements/iron-a11y-keys-behavior",
"_release": "1.1.0", "_release": "1.1.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.1.0", "tag": "v1.1.1",
"commit": "cd8c972278c0d916bef57209d7dce5b81e67687c" "commit": "12af7cb19b2c6b3887e37a5ea1501ffe676d1e8a"
}, },
"_source": "git://github.com/polymerelements/iron-a11y-keys-behavior.git", "_source": "git://github.com/polymerelements/iron-a11y-keys-behavior.git",
"_target": "^1.0.0", "_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-a11y-keys-behavior", "name": "iron-a11y-keys-behavior",
"version": "1.1.0", "version": "1.1.1",
"description": "A behavior that enables keybindings for greater a11y.", "description": "A behavior that enables keybindings for greater a11y.",
"keywords": [ "keywords": [
"web-components", "web-components",

View file

@ -86,7 +86,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
keyBindings: { keyBindings: {
'* pageup pagedown left right down up home end space enter @ ~ " $ ? ! \\ + : # backspace': '_updatePressed', '* pageup pagedown left right down up home end space enter @ ~ " $ ? ! \\ + : # backspace': '_updatePressed',
'a': '_updatePressed', 'a': '_updatePressed',
'shift+a alt+a': '_updatePressed' 'shift+a alt+a': '_updatePressed',
'shift+tab shift+space': '_updatePressed'
}, },
_updatePressed: function(event) { _updatePressed: function(event) {

View file

@ -65,6 +65,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
'meta': 'metaKey' 'meta': 'metaKey'
}; };
/**
* KeyboardEvent.key is mostly represented by printable character made by
* the keyboard, with unprintable keys labeled nicely.
*
* However, on OS X, Alt+char can make a Unicode character that follows an
* Apple-specific mapping. In this case, we fall back to .keyCode.
*/
var KEY_CHAR = /[a-z0-9*]/;
/** /**
* Matches a keyIdentifier string. * Matches a keyIdentifier string.
*/ */
@ -81,14 +90,22 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/ */
var SPACE_KEY = /^space(bar)?/; var SPACE_KEY = /^space(bar)?/;
function transformKey(key) { /**
* Transforms the key.
* @param {string} key The KeyBoardEvent.key
* @param {Boolean} [noSpecialChars] Limits the transformation to
* alpha-numeric characters.
*/
function transformKey(key, noSpecialChars) {
var validKey = ''; var validKey = '';
if (key) { if (key) {
var lKey = key.toLowerCase(); var lKey = key.toLowerCase();
if (lKey === ' ' || SPACE_KEY.test(lKey)) { if (lKey === ' ' || SPACE_KEY.test(lKey)) {
validKey = 'space'; validKey = 'space';
} else if (lKey.length == 1) { } else if (lKey.length == 1) {
validKey = lKey; if (!noSpecialChars || KEY_CHAR.test(lKey)) {
validKey = lKey;
}
} else if (ARROW_KEY.test(lKey)) { } else if (ARROW_KEY.test(lKey)) {
validKey = lKey.replace('arrow', ''); validKey = lKey.replace('arrow', '');
} else if (lKey == 'multiply') { } else if (lKey == 'multiply') {
@ -139,17 +156,29 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return validKey; return validKey;
} }
function normalizedKeyForEvent(keyEvent) { /**
// fall back from .key, to .keyIdentifier, to .keyCode, and then to * Calculates the normalized key for a KeyboardEvent.
// .detail.key to support artificial keyboard events * @param {KeyboardEvent} keyEvent
return transformKey(keyEvent.key) || * @param {Boolean} [noSpecialChars] Set to true to limit keyEvent.key
* transformation to alpha-numeric chars. This is useful with key
* combinations like shift + 2, which on FF for MacOS produces
* keyEvent.key = @
* To get 2 returned, set noSpecialChars = true
* To get @ returned, set noSpecialChars = false
*/
function normalizedKeyForEvent(keyEvent, noSpecialChars) {
// Fall back from .key, to .keyIdentifier, to .keyCode, and then to
// .detail.key to support artificial keyboard events.
return transformKey(keyEvent.key, noSpecialChars) ||
transformKeyIdentifier(keyEvent.keyIdentifier) || transformKeyIdentifier(keyEvent.keyIdentifier) ||
transformKeyCode(keyEvent.keyCode) || transformKeyCode(keyEvent.keyCode) ||
transformKey(keyEvent.detail.key) || ''; transformKey(keyEvent.detail.key, noSpecialChars) || '';
} }
function keyComboMatchesEvent(keyCombo, event, eventKey) { function keyComboMatchesEvent(keyCombo, event) {
return eventKey === keyCombo.key && // For combos with modifiers we support only alpha-numeric keys
var keyEvent = normalizedKeyForEvent(event, keyCombo.hasModifiers);
return keyEvent === keyCombo.key &&
(!keyCombo.hasModifiers || ( (!keyCombo.hasModifiers || (
!!event.shiftKey === !!keyCombo.shiftKey && !!event.shiftKey === !!keyCombo.shiftKey &&
!!event.ctrlKey === !!keyCombo.ctrlKey && !!event.ctrlKey === !!keyCombo.ctrlKey &&
@ -286,9 +315,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
keyboardEventMatchesKeys: function(event, eventString) { keyboardEventMatchesKeys: function(event, eventString) {
var keyCombos = parseEventString(eventString); var keyCombos = parseEventString(eventString);
var eventKey = normalizedKeyForEvent(event);
for (var i = 0; i < keyCombos.length; ++i) { for (var i = 0; i < keyCombos.length; ++i) {
if (keyComboMatchesEvent(keyCombos[i], event, eventKey)) { if (keyComboMatchesEvent(keyCombos[i], event)) {
return true; return true;
} }
} }
@ -388,11 +416,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return; return;
} }
var eventKey = normalizedKeyForEvent(event);
for (var i = 0; i < keyBindings.length; i++) { for (var i = 0; i < keyBindings.length; i++) {
var keyCombo = keyBindings[i][0]; var keyCombo = keyBindings[i][0];
var handlerName = keyBindings[i][1]; var handlerName = keyBindings[i][1];
if (keyComboMatchesEvent(keyCombo, event, eventKey)) { if (keyComboMatchesEvent(keyCombo, event)) {
this._triggerKeyHandler(keyCombo, handlerName, event); this._triggerKeyHandler(keyCombo, handlerName, event);
// exit the loop if eventDefault was prevented // exit the loop if eventDefault was prevented
if (event.defaultPrevented) { if (event.defaultPrevented) {

View file

@ -97,7 +97,8 @@ suite('Polymer.IronA11yKeysBehavior', function() {
], ],
keyBindings: { keyBindings: {
'space': '_keyHandler' 'space': '_keyHandler',
'@': '_keyHandler'
} }
}); });
@ -179,6 +180,13 @@ suite('Polymer.IronA11yKeysBehavior', function() {
expect(keys.keyCount).to.be.equal(1); expect(keys.keyCount).to.be.equal(1);
}); });
test('handles special character @', function() {
var event = new CustomEvent('keydown');
event.key = '@';
keys.dispatchEvent(event);
expect(keys.keyCount).to.be.equal(1);
});
test('do not trigger the handler for non-specified keys', function() { test('do not trigger the handler for non-specified keys', function() {
MockInteractions.pressEnter(keys); MockInteractions.pressEnter(keys);
@ -284,6 +292,19 @@ suite('Polymer.IronA11yKeysBehavior', function() {
expect(keys.keyCount).to.be.equal(1); expect(keys.keyCount).to.be.equal(1);
}); });
test('check if KeyBoardEvent.key is alpha-numberic', function() {
var event = new CustomEvent('keydown');
event.ctrlKey = true;
event.shiftKey = true;
event.key = 'å';
event.keyCode = event.code = 65;
keys.dispatchEvent(event);
expect(keys.keyCount).to.be.equal(1);
});
test('trigger also bindings without modifiers', function() { test('trigger also bindings without modifiers', function() {
var event = new CustomEvent('keydown'); var event = new CustomEvent('keydown');
// Combo `shift+enter`. // Combo `shift+enter`.
@ -305,6 +326,7 @@ suite('Polymer.IronA11yKeysBehavior', function() {
expect(shiftEnterSpy.called).to.be.true; expect(shiftEnterSpy.called).to.be.true;
expect(enterSpy.calledAfter(shiftEnterSpy)).to.be.true; expect(enterSpy.calledAfter(shiftEnterSpy)).to.be.true;
}); });
}); });
suite('alternative event keys', function() { suite('alternative event keys', function() {

View file

@ -28,14 +28,14 @@
"iron-component-page": "polymerelements/iron-component-page#^1.0.0" "iron-component-page": "polymerelements/iron-component-page#^1.0.0"
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/PolymerElements/iron-flex-layout", "homepage": "https://github.com/polymerelements/iron-flex-layout",
"_release": "1.2.2", "_release": "1.2.2",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.2.2", "tag": "v1.2.2",
"commit": "41c4f35be1368afb770312b907a258175565dbdf" "commit": "41c4f35be1368afb770312b907a258175565dbdf"
}, },
"_source": "git://github.com/PolymerElements/iron-flex-layout.git", "_source": "git://github.com/polymerelements/iron-flex-layout.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-flex-layout" "_originalSource": "polymerelements/iron-flex-layout"
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-icons", "name": "iron-icons",
"version": "1.1.0", "version": "1.1.1",
"description": "A set of icons for use with iron-icon", "description": "A set of icons for use with iron-icon",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
@ -34,11 +34,11 @@
"util", "util",
"update-icons.sh" "update-icons.sh"
], ],
"_release": "1.1.0", "_release": "1.1.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.1.0", "tag": "v1.1.1",
"commit": "623d8dae77cd8658ce1f6834b30a4f3f6e2100ea" "commit": "77a8e0190d6c481d8b5df0495fa484928880ea53"
}, },
"_source": "git://github.com/PolymerElements/iron-icons.git", "_source": "git://github.com/PolymerElements/iron-icons.git",
"_target": "^1.0.0", "_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "iron-icons", "name": "iron-icons",
"version": "1.1.0", "version": "1.1.1",
"description": "A set of icons for use with iron-icon", "description": "A set of icons for use with iron-icon",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"

View file

@ -30,6 +30,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<link rel="import" href="../maps-icons.html"> <link rel="import" href="../maps-icons.html">
<link rel="import" href="../notification-icons.html"> <link rel="import" href="../notification-icons.html">
<link rel="import" href="../social-icons.html"> <link rel="import" href="../social-icons.html">
<link rel="import" href="../places-icons.html">
<style is="custom-style"> <style is="custom-style">

View file

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

View file

@ -0,0 +1,27 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# Tabs in JS unless otherwise specified
[**.js]
indent_style = tab
[test/**.xml]
indent_style = tab
[test/**.php]
indent_style = tab
[test/**.html]
indent_style = tab
[test/**.css]
indent_style = tab

View file

@ -0,0 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto
# JS files must always use LF for tools to work
*.js eol=lf

View file

@ -0,0 +1,14 @@
.project
.settings
*~
*.diff
*.patch
/*.html
.DS_Store
.bower.json
.sizecache.json
/dist
/node_modules
/test/node_smoke_tests/lib/ensure_iterability.js

View file

@ -0,0 +1,10 @@
{
"preset": "jquery",
// remove after https://github.com/jscs-dev/node-jscs/issues/1685
// and https://github.com/jscs-dev/node-jscs/issues/1686
"requireCapitalizedComments": null,
"excludeFiles": [ "external", "src/intro.js", "src/outro.js",
"test/node_smoke_tests/lib/ensure_iterability.js", "node_modules" ]
}

View file

@ -0,0 +1,12 @@
external
src/intro.js
src/outro.js
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
test/data/json_obj.js
test/data/readywaitasset.js
test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js
test/node_smoke_tests/lib/ensure_iterability.js

View file

@ -0,0 +1,14 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"node": true
}

View file

@ -0,0 +1,104 @@
Adam Coulombe <me@adam.co> <adamcoulombe187@hotmail.com>
Adam J. Sontag <ajpiano@ajpiano.com>
Alexander Farkas <info@corrupt-system.de>
Alexander Farkas <info@corrupt-system.de> <a.farkas.pm@googlemail.com>
Alexis Abril <me@alexisabril.com> <alexis.abril@gmail.com>
Andrew E Monat <amonat@gmail.com>
Anton Matzneller <obhvsbypqghgc@gmail.com>
Anton Matzneller <obhvsbypqghgc@gmail.com> <haskell_noob-github@yahoo.de>
Batiste Bieler <batiste.bieler@gmail.com>
Benjamin Truyman <bentruyman@gmail.com>
Brandon Aaron <brandon.aaron@gmail.com>
Carl Danley <carldanley@gmail.com>
Carl Fürstenberg <azatoth@gmail.com>
Carl Fürstenberg <azatoth@gmail.com> <carl@excito.com>
Charles McNulty <cmcnulty@kznf.com>
Christopher Jones <chris@cjqed.com> cjqed <christopherjonesqed@gmail.com>
Colin Snover <github.com@zetafleet.com> <colin@alpha.zetafleet.com>
Corey Frang <gnarf37@gmail.com> <gnarf@gnarf.net>
Dan Heberden <danheberden@gmail.com>
Daniel Chatfield <chatfielddaniel@gmail.com> <chatfielddaniel@googlemail.com>
Daniel Gálvez <dgalvez@editablething.com>
Danil Somsikov <danilasomsikov@gmail.com>
Dave Methvin <dave.methvin@gmail.com>
Dave Reed <dareed@microsoft.com>
David Fox <dfoxinator@gmail.com> <dfox@snap-interactive.com>
David Hong <d.hong@me.com>
David Murdoch <david@davidmurdoch.com> <musicisair@yahoo.com>
Devin Cooper <cooper.semantics@gmail.com> <dcooper@snap-interactive.com>
Douglas Neiner <doug@dougneiner.com> <doug@pixelgraphics.us>
Dmitry Gusev <dmitry.gusev@gmail.com>
Earle Castledine <mrspeaker@gmail.com>
Erick Ruiz de Chávez <erickrdch@gmail.com>
Gianni Alessandro Chiappetta <gianni@runlevel6.org>
Heungsub Lee <h@subl.ee> <lee@heungsub.net>
Iraê Carvalho <irae@irae.pro.br>
Isaac Z. Schlueter <i@izs.me>
Ismail Khair <ismail.khair@gmail.com>
James Burke <jrburke@gmail.com>
James Padolsey <cla@padolsey.net> <jamespadolsey@gmail.com>
Jason Bedard <jason+jquery@jbedard.ca> <github@jbedard.ca>
Jay Merrifield <fracmak@gmail.com>
Jay Merrifield <fracmak@gmail.com> <jmerrifiel@gannett.com>
Jean Boussier <jean.boussier@gmail.com>
Jephte Clain <Jephte.Clain@univ-reunion.fr>
Jess Thrysoee <jess@thrysoee.dk>
Joao Henrique de Andrade Bruni <joaohbruni@yahoo.com.br>
Joe Presbrey <presbrey@gmail.com> <presbrey+jwp@gmail.com>
John Resig <jeresig@gmail.com>
John Resig <jeresig@gmail.com> <jeresig@Archimedes.local>
Jordan Boesch <jboesch26@gmail.com> <jordan@boedesign.com>
Josh Varner <josh.varner@gmail.com> <josh.varner@gmail.com>
Julian Aubourg <aubourg.julian@gmail.com>
Julian Aubourg <aubourg.julian@gmail.com> <j@ubourg.net>
Julian Aubourg <aubourg.julian@gmail.com> <Julian@.(none)>
Jörn Zaefferer <joern.zaefferer@gmail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com> <joern.zaefferer@googlemail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com> <JZA@.(none)>
Karl Swedberg <kswedberg@gmail.com> <karl@englishrules.com>
Klaus Hartl <klaus.hartl@gmail.com> <klaus.hartl@googlemail.com>
Kris Borchers <kris.borchers@gmail.com>
Lee Carpenter <elcarpie@gmail.com>
Li Xudong <istonelee@gmail.com>
Louis-Rémi Babé <lrbabe@gmail.com>
Louis-Rémi Babé <lrbabe@gmail.com> <louisremi@louisremi-laptop.(none)>
Louis-Rémi Babé <lrbabe@gmail.com> <lrbabe@lrbabe-laptop.(none)>
Louis-Rémi Babé <lrbabe@gmail.com> <lrbabe@lrbabe-laptop>
Marcel Greter <marcel.greter@ocbnet.ch> <mgr@rtp.ch>
Matthias Jäggli <matthias.jaeggli@gmail.com> <matthias.jaeggli@scout24.ch>
Michael Murray <m@murz.net> <mmurray.wa@gmail.com>
Michał Gołębiowski <m.goleb@gmail.com>
Michał Gołębiowski <m.goleb@gmail.com> <michal.golebiowski@laboratorium.ee>
Mike Alsup <malsup@gmail.com>
Nguyen Phuc Lam <ruado1987@gmail.com>
Oleg Gaidarenko <markelog@gmail.com>
Paul Bakaus <paul.bakaus@gmail.com> <paul.bakaus@googlemail.com>
Rafaël Blais Masson <rafbmasson@gmail.com>
Richard D. Worth <rdworth@gmail.com>
Rick Waldron <waldron.rick@gmail.com>
Rick Waldron <waldron.rick@gmail.com> <rick@bocoup.com>
Robert Katić <robert.katic@gmail.com>
Roman Reiß <me@silverwind.io>
Ron Otten <r.j.g.otten@gmail.com>
Sai Lung Wong <sai.wong@huffingtonpost.com>
Scott González <scott.gonzalez@gmail.com> <sgonzale@sgonzale-laptop.local>
Scott Jehl <scottjehl@gmail.com> <scott@scottjehl.com>
Sebastian Burkhard <sebi.burkhard@gmail.com>
Senya Pugach <upisfree@outlook.com>
Thomas Tortorini <thomastortorini@gmail.com> Mr21
Timmy Willison <timmywillisn@gmail.com>
Timmy Willison <timmywillisn@gmail.com> <tim.willison@thisismedium.com>
Timo Tijhof <krinklemail@gmail.com>
TJ Holowaychuk <tj@vision-media.ca>
Tom H Fuertes <tomfuertes@gmail.com>
Tom H Fuertes <tomfuertes@gmail.com> Tom H Fuertes <TomFuertes@gmail.com>
Tom Viner <github@viner.tv>
Wesley Walser <waw325@gmail.com> <wwalser@atlassian.com>
Xavi Ramirez <xavi.rmz@gmail.com>
Xavier Montillet <xavierm02.net@gmail.com>
Yehuda Katz <wycats@gmail.com>
Yehuda Katz <wycats@gmail.com> <wycats@12-189-125-93.att-inc.com>
Yehuda Katz <wycats@gmail.com> <wycats@mobile005.mycingular.net>
Yehuda Katz <wycats@gmail.com> <wycats@Yehuda-Katz.local>
Yiming He <yiminghe@gmail.com>
Terry Jones <terry@jon.es> <terry@fluidinfo.com>

View file

@ -0,0 +1,17 @@
.jshintignore
.jshintrc
/.editorconfig
/.gitattributes
/.jscs.json
/.mailmap
/.travis.yml
/build
/speed
/test
/Gruntfile.js
/external/qunit
/external/requirejs
/external/sinon

View file

@ -0,0 +1,7 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "4"
- "5"

View file

@ -0,0 +1,275 @@
Authors ordered by first contribution.
John Resig <jeresig@gmail.com>
Gilles van den Hoven <gilles0181@gmail.com>
Michael Geary <mike@geary.com>
Stefan Petre <stefan.petre@gmail.com>
Yehuda Katz <wycats@gmail.com>
Corey Jewett <cj@syntheticplayground.com>
Klaus Hartl <klaus.hartl@gmail.com>
Franck Marcia <franck.marcia@gmail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com>
Paul Bakaus <paul.bakaus@gmail.com>
Brandon Aaron <brandon.aaron@gmail.com>
Mike Alsup <malsup@gmail.com>
Dave Methvin <dave.methvin@gmail.com>
Ed Engelhardt <edengelhardt@gmail.com>
Sean Catchpole <littlecooldude@gmail.com>
Paul Mclanahan <pmclanahan@gmail.com>
David Serduke <davidserduke@gmail.com>
Richard D. Worth <rdworth@gmail.com>
Scott González <scott.gonzalez@gmail.com>
Ariel Flesler <aflesler@gmail.com>
Jon Evans <jon@springyweb.com>
TJ Holowaychuk <tj@vision-media.ca>
Michael Bensoussan <mickey@seesmic.com>
Robert Katić <robert.katic@gmail.com>
Louis-Rémi Babé <lrbabe@gmail.com>
Earle Castledine <mrspeaker@gmail.com>
Damian Janowski <damian.janowski@gmail.com>
Rich Dougherty <rich@rd.gen.nz>
Kim Dalsgaard <kim@kimdalsgaard.com>
Andrea Giammarchi <andrea.giammarchi@gmail.com>
Mark Gibson <jollytoad@gmail.com>
Karl Swedberg <kswedberg@gmail.com>
Justin Meyer <justinbmeyer@gmail.com>
Ben Alman <cowboy@rj3.net>
James Padolsey <cla@padolsey.net>
David Petersen <public@petersendidit.com>
Batiste Bieler <batiste.bieler@gmail.com>
Alexander Farkas <info@corrupt-system.de>
Rick Waldron <waldron.rick@gmail.com>
Filipe Fortes <filipe@fortes.com>
Neeraj Singh <neerajdotname@gmail.com>
Paul Irish <paul.irish@gmail.com>
Iraê Carvalho <irae@irae.pro.br>
Matt Curry <matt@pseudocoder.com>
Michael Monteleone <michael@michaelmonteleone.net>
Noah Sloan <noah.sloan@gmail.com>
Tom Viner <github@viner.tv>
Douglas Neiner <doug@dougneiner.com>
Adam J. Sontag <ajpiano@ajpiano.com>
Dave Reed <dareed@microsoft.com>
Ralph Whitbeck <ralph.whitbeck@gmail.com>
Carl Fürstenberg <azatoth@gmail.com>
Jacob Wright <jacwright@gmail.com>
J. Ryan Stinnett <jryans@gmail.com>
unknown <Igen005@.upcorp.ad.uprr.com>
temp01 <temp01irc@gmail.com>
Heungsub Lee <h@subl.ee>
Colin Snover <github.com@zetafleet.com>
Ryan W Tenney <ryan@10e.us>
Pinhook <contact@pinhooklabs.com>
Ron Otten <r.j.g.otten@gmail.com>
Jephte Clain <Jephte.Clain@univ-reunion.fr>
Anton Matzneller <obhvsbypqghgc@gmail.com>
Alex Sexton <AlexSexton@gmail.com>
Dan Heberden <danheberden@gmail.com>
Henri Wiechers <hwiechers@gmail.com>
Russell Holbrook <russell.holbrook@patch.com>
Julian Aubourg <aubourg.julian@gmail.com>
Gianni Alessandro Chiappetta <gianni@runlevel6.org>
Scott Jehl <scottjehl@gmail.com>
James Burke <jrburke@gmail.com>
Jonas Pfenniger <jonas@pfenniger.name>
Xavi Ramirez <xavi.rmz@gmail.com>
Jared Grippe <jared@deadlyicon.com>
Sylvester Keil <sylvester@keil.or.at>
Brandon Sterne <bsterne@mozilla.com>
Mathias Bynens <mathias@qiwi.be>
Timmy Willison <timmywillisn@gmail.com>
Corey Frang <gnarf37@gmail.com>
Digitalxero <digitalxero>
Anton Kovalyov <anton@kovalyov.net>
David Murdoch <david@davidmurdoch.com>
Josh Varner <josh.varner@gmail.com>
Charles McNulty <cmcnulty@kznf.com>
Jordan Boesch <jboesch26@gmail.com>
Jess Thrysoee <jess@thrysoee.dk>
Michael Murray <m@murz.net>
Lee Carpenter <elcarpie@gmail.com>
Alexis Abril <me@alexisabril.com>
Rob Morgan <robbym@gmail.com>
John Firebaugh <john_firebaugh@bigfix.com>
Sam Bisbee <sam@sbisbee.com>
Gilmore Davidson <gilmoreorless@gmail.com>
Brian Brennan <me@brianlovesthings.com>
Xavier Montillet <xavierm02.net@gmail.com>
Daniel Pihlstrom <sciolist.se@gmail.com>
Sahab Yazdani <sahab.yazdani+github@gmail.com>
avaly <github-com@agachi.name>
Scott Hughes <hi@scott-hughes.me>
Mike Sherov <mike.sherov@gmail.com>
Greg Hazel <ghazel@gmail.com>
Schalk Neethling <schalk@ossreleasefeed.com>
Denis Knauf <Denis.Knauf@gmail.com>
Timo Tijhof <krinklemail@gmail.com>
Steen Nielsen <swinedk@gmail.com>
Anton Ryzhov <anton@ryzhov.me>
Shi Chuan <shichuanr@gmail.com>
Berker Peksag <berker.peksag@gmail.com>
Toby Brain <tobyb@freshview.com>
Matt Mueller <mattmuelle@gmail.com>
Justin <drakefjustin@gmail.com>
Daniel Herman <daniel.c.herman@gmail.com>
Oleg Gaidarenko <markelog@gmail.com>
Richard Gibson <richard.gibson@gmail.com>
Rafaël Blais Masson <rafbmasson@gmail.com>
cmc3cn <59194618@qq.com>
Joe Presbrey <presbrey@gmail.com>
Sindre Sorhus <sindresorhus@gmail.com>
Arne de Bree <arne@bukkie.nl>
Vladislav Zarakovsky <vlad.zar@gmail.com>
Andrew E Monat <amonat@gmail.com>
Oskari <admin@o-programs.com>
Joao Henrique de Andrade Bruni <joaohbruni@yahoo.com.br>
tsinha <tsinha@Anthonys-MacBook-Pro.local>
Matt Farmer <matt@frmr.me>
Trey Hunner <treyhunner@gmail.com>
Jason Moon <jmoon@socialcast.com>
Jeffery To <jeffery.to@gmail.com>
Kris Borchers <kris.borchers@gmail.com>
Vladimir Zhuravlev <private.face@gmail.com>
Jacob Thornton <jacobthornton@gmail.com>
Chad Killingsworth <chadkillingsworth@missouristate.edu>
Nowres Rafid <nowres.rafed@gmail.com>
David Benjamin <davidben@mit.edu>
Uri Gilad <antishok@gmail.com>
Chris Faulkner <thefaulkner@gmail.com>
Elijah Manor <elijah.manor@gmail.com>
Daniel Chatfield <chatfielddaniel@gmail.com>
Nikita Govorov <nikita.govorov@gmail.com>
Wesley Walser <waw325@gmail.com>
Mike Pennisi <mike@mikepennisi.com>
Markus Staab <markus.staab@redaxo.de>
Dave Riddle <david@joyvuu.com>
Callum Macrae <callum@lynxphp.com>
Benjamin Truyman <bentruyman@gmail.com>
James Huston <james@jameshuston.net>
Erick Ruiz de Chávez <erickrdch@gmail.com>
David Bonner <dbonner@cogolabs.com>
Akintayo Akinwunmi <aakinwunmi@judge.com>
MORGAN <morgan@morgangraphics.com>
Ismail Khair <ismail.khair@gmail.com>
Carl Danley <carldanley@gmail.com>
Mike Petrovich <michael.c.petrovich@gmail.com>
Greg Lavallee <greglavallee@wapolabs.com>
Daniel Gálvez <dgalvez@editablething.com>
Sai Lung Wong <sai.wong@huffingtonpost.com>
Tom H Fuertes <TomFuertes@gmail.com>
Roland Eckl <eckl.roland@googlemail.com>
Jay Merrifield <fracmak@gmail.com>
Allen J Schmidt Jr <cobrasoft@gmail.com>
Jonathan Sampson <jjdsampson@gmail.com>
Marcel Greter <marcel.greter@ocbnet.ch>
Matthias Jäggli <matthias.jaeggli@gmail.com>
David Fox <dfoxinator@gmail.com>
Yiming He <yiminghe@gmail.com>
Devin Cooper <cooper.semantics@gmail.com>
Paul Ramos <paul.b.ramos@gmail.com>
Rod Vagg <rod@vagg.org>
Bennett Sorbo <bsorbo@gmail.com>
Sebastian Burkhard <sebi.burkhard@gmail.com>
Zachary Adam Kaplan <razic@viralkitty.com>
nanto_vi <nanto@moon.email.ne.jp>
nanto <nanto@moon.email.ne.jp>
Danil Somsikov <danilasomsikov@gmail.com>
Ryunosuke SATO <tricknotes.rs@gmail.com>
Jean Boussier <jean.boussier@gmail.com>
Adam Coulombe <me@adam.co>
Andrew Plummer <plummer.andrew@gmail.com>
Mark Raddatz <mraddatz@gmail.com>
Isaac Z. Schlueter <i@izs.me>
Karl Sieburg <ksieburg@yahoo.com>
Pascal Borreli <pascal@borreli.com>
Nguyen Phuc Lam <ruado1987@gmail.com>
Dmitry Gusev <dmitry.gusev@gmail.com>
Michał Gołębiowski <m.goleb@gmail.com>
Li Xudong <istonelee@gmail.com>
Steven Benner <admin@stevenbenner.com>
Tom H Fuertes <tomfuertes@gmail.com>
Renato Oliveira dos Santos <ros3@cin.ufpe.br>
ros3cin <ros3@cin.ufpe.br>
Jason Bedard <jason+jquery@jbedard.ca>
Kyle Robinson Young <kyle@dontkry.com>
Chris Talkington <chris@talkingtontech.com>
Eddie Monge <eddie@eddiemonge.com>
Terry Jones <terry@jon.es>
Jason Merino <jasonmerino@gmail.com>
Jeremy Dunck <jdunck@gmail.com>
Chris Price <price.c@gmail.com>
Guy Bedford <guybedford@gmail.com>
Amey Sakhadeo <me@ameyms.com>
Mike Sidorov <mikes.ekb@gmail.com>
Anthony Ryan <anthonyryan1@gmail.com>
Dominik D. Geyer <dominik.geyer@gmail.com>
George Kats <katsgeorgeek@gmail.com>
Lihan Li <frankieteardrop@gmail.com>
Ronny Springer <springer.ronny@gmail.com>
Chris Antaki <ChrisAntaki@gmail.com>
Marian Sollmann <marian.sollmann@cargomedia.ch>
njhamann <njhamann@gmail.com>
Ilya Kantor <iliakan@gmail.com>
David Hong <d.hong@me.com>
John Paul <john@johnkpaul.com>
Jakob Stoeck <jakob@pokermania.de>
Christopher Jones <chris@cjqed.com>
Forbes Lindesay <forbes@lindesay.co.uk>
S. Andrew Sheppard <andrew@wq.io>
Leonardo Balter <leonardo.balter@gmail.com>
Roman Reiß <me@silverwind.io>
Benjy Cui <benjytrys@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
John Hoven <hovenj@gmail.com>
Philip Jägenstedt <philip@foolip.org>
Christian Kosmowski <ksmwsk@gmail.com>
Liang Peng <poppinlp@gmail.com>
TJ VanToll <tj.vantoll@gmail.com>
Senya Pugach <upisfree@outlook.com>
Aurelio De Rosa <aurelioderosa@gmail.com>
Nazar Mokrynskyi <nazar@mokrynskyi.com>
Amit Merchant <bullredeyes@gmail.com>
Jason Bedard <jason+github@jbedard.ca>
Arthur Verschaeve <contact@arthurverschaeve.be>
Dan Hart <danhart@notonthehighstreet.com>
Bin Xin <rhyzix@gmail.com>
David Corbacho <davidcorbacho@gmail.com>
Veaceslav Grimalschi <grimalschi@yandex.ru>
Daniel Husar <dano.husar@gmail.com>
Frederic Hemberger <mail@frederic-hemberger.de>
Ben Toews <mastahyeti@gmail.com>
Aditya Raghavan <araghavan3@gmail.com>
Victor Homyakov <vkhomyackov@gmail.com>
Shivaji Varma <contact@shivajivarma.com>
Nicolas HENRY <icewil@gmail.com>
Anne-Gaelle Colom <coloma@westminster.ac.uk>
George Mauer <gmauer@gmail.com>
Leonardo Braga <leonardo.braga@gmail.com>
Stephen Edgar <stephen@netweb.com.au>
Thomas Tortorini <thomastortorini@gmail.com>
Winston Howes <winstonhowes@gmail.com>
Jon Hester <jon.d.hester@gmail.com>
Alexander O'Mara <me@alexomara.com>
Bastian Buchholz <buchholz.bastian@googlemail.com>
Arthur Stolyar <nekr.fabula@gmail.com>
Calvin Metcalf <calvin.metcalf@gmail.com>
Mu Haibao <mhbseal@163.com>
Richard McDaniel <rm0026@uah.edu>
Chris Rebert <github@rebertia.com>
Gabriel Schulhof <gabriel.schulhof@intel.com>
Gilad Peleg <giladp007@gmail.com>
Martin Naumann <martin@geekonaut.de>
Marek Lewandowski <m.lewandowski@cksource.com>
Bruno Pérel <brunoperel@gmail.com>
Reed Loden <reed@reedloden.com>
Daniel Nill <daniellnill@gmail.com>
Yongwoo Jeon <yongwoo.jeon@navercorp.com>
Sean Henderson <seanh.za@gmail.com>
Richard Kraaijenhagen <stdin+git@riichard.com>
Connor Atherton <c.liam.atherton@gmail.com>
Gary Ye <garysye@gmail.com>
Christian Grete <webmaster@christiangrete.com>
Liza Ramo <liza.h.ramo@gmail.com>
Julian Alexander Murillo <julian.alexander.murillo@gmail.com>
Joelle Fleurantin <joasqueeniebee@gmail.com>
Jun Sun <klsforever@gmail.com>

View file

@ -0,0 +1,132 @@
# Contributing to jQuery
1. [Getting Involved](#getting-involved)
2. [Questions and Discussion](#questions-and-discussion)
3. [How To Report Bugs](#how-to-report-bugs)
4. [Tips for Bug Patching](#tips-for-bug-patching)
Note: This is the code development repository for *jQuery Core* only. Before opening an issue or making a pull request, be sure you're in the right place.
* jQuery plugin issues should be reported to the author of the plugin.
* jQuery Core API documentation issues can be filed [at the API repo](http://github.com/jquery/api.jquery.com/issues).
* Bugs or suggestions for other jQuery Foundation projects should be filed in [their respective repos](http://github.com/jquery/).
## Getting Involved
We've put together [a short guide with tips, tricks, and ideas on getting started](http://contribute.jquery.org/open-source/). We're always looking for help identifying bugs, writing and reducing test cases, and documentation.
More information on how to contribute to this and other jQuery Foundation projects is at [contribute.jquery.org](http://contribute.jquery.org). Please review our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/) for instructions on how to maintain a fork and submit patches. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla/).
## Questions and Discussion
### Forum and IRC
jQuery is so popular that many developers have knowledge of its capabilities and limitations. Most questions about using jQuery can be answered on popular forums such as [Stack Overflow](http://stackoverflow.com). Please start there when you have questions, even if you think you've found a bug.
The jQuery Core team watches the [jQuery Development Forum](http://forum.jquery.com/developing-jquery-core). If you have longer posts or questions that can't be answered in places such as Stack Overflow, please feel free to post them there. If you think you've found a bug, please [file it in the bug tracker](#how-to-report-bugs). The Core team can be found in the [#jquery-dev](http://webchat.freenode.net/?channels=jquery-dev) IRC channel on irc.freenode.net.
### Weekly Status Meetings
The jQuery Core team has a weekly meeting to discuss the progress of current work. The meeting is held in the [#jquery-meeting](http://webchat.freenode.net/?channels=jquery-meeting) IRC channel on irc.freenode.net at [Noon EST](http://www.timeanddate.com/worldclock/fixedtime.html?month=1&day=17&year=2011&hour=12&min=0&sec=0&p1=43) on Mondays.
[jQuery Core Meeting Notes](http://meetings.jquery.org/category/core/)
## How to Report Bugs
### Make sure it is a jQuery bug
Most bugs reported to our bug tracker are actually bugs in user code, not in jQuery code. Keep in mind that just because your code throws an error inside of jQuery, this does *not* mean the bug is a jQuery bug.
Ask for help first in the [Using jQuery Forum](http://forum.jquery.com/using-jquery) or another discussion forum like [Stack Overflow](http://stackoverflow.com/). You will get much quicker support, and you will help avoid tying up the jQuery team with invalid bug reports.
### Disable browser extensions
Make sure you have reproduced the bug with all browser extensions and add-ons disabled, as these can sometimes cause things to break in interesting and unpredictable ways. Try using incognito, stealth or anonymous browsing modes.
### Try the latest version of jQuery
Bugs in old versions of jQuery may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest build](http://code.jquery.com/jquery.js). We cannot fix bugs in older released files, if a bug has been fixed in a subsequent version of jQuery the site should upgrade.
### Simplify the test case
When experiencing a problem, [reduce your code](http://webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it *much* easier to isolate and fix the offending code. Bugs reported without reduced test cases take on average 9001% longer to fix than bugs that are submitted with them, so you really should try to do this if at all possible.
### Search for related or duplicate issues
Go to the [jQuery Core issue tracker](https://github.com/jquery/jquery/issues) and make sure the problem hasn't already been reported. If not, create a new issue there and include your test case.
## Tips For Bug Patching
We *love* when people contribute back to the project by patching the bugs they find. Since jQuery is used by so many people, we are cautious about the patches we accept and want to be sure they don't have a negative impact on the millions of people using jQuery each day. For that reason it can take a while for any suggested patch to work its way through the review and release process. The reward for you is knowing that the problem you fixed will improve things for millions of sites and billions of visits per day.
### Build a Local Copy of jQuery
Create a fork of the jQuery repo on github at http://github.com/jquery/jquery
Change directory to your web root directory, whatever that might be:
```bash
$ cd /path/to/your/www/root/
```
Clone your jQuery fork to work locally
```bash
$ git clone git@github.com:username/jquery.git
```
Change directory to the newly created dir jquery/
```bash
$ cd jquery
```
Add the jQuery master as a remote. I label mine "upstream"
```bash
$ git remote add upstream git://github.com/jquery/jquery.git
```
Get in the habit of pulling in the "upstream" master to stay up to date as jQuery receives new commits
```bash
$ git pull upstream master
```
Run the build script
```bash
$ npm run build
```
Run the Grunt tools:
```bash
$ grunt && grunt watch
```
Now open the jQuery test suite in a browser at http://localhost/test. If there is a port, be sure to include it.
Success! You just built and tested jQuery!
### Test Suite Tips...
During the process of writing your patch, you will run the test suite MANY times. You can speed up the process by narrowing the running test suite down to the module you are testing by either double clicking the title of the test or appending it to the url. The following examples assume you're working on a local repo, hosted on your localhost server.
Example:
http://localhost/test/?filter=css
This will only run the "css" module tests. This will significantly speed up your development and debugging.
**ALWAYS RUN THE FULL SUITE BEFORE COMMITTING AND PUSHING A PATCH!**
### Browser support
Remember that jQuery supports multiple browsers and their versions; any contributed code must work in all of them. You can refer to the [browser support page](http://jquery.com/browser-support/) for the current list of supported browsers.
Note that browser support differs depending on whether you are targeting the `master` or `compat` branch.

View file

@ -0,0 +1,212 @@
module.exports = function( grunt ) {
"use strict";
function readOptionalJSON( filepath ) {
var data = {};
try {
data = JSON.parse( stripJSONComments(
fs.readFileSync( filepath, { encoding: "utf8" } )
) );
} catch ( e ) {}
return data;
}
var fs = require( "fs" ),
stripJSONComments = require( "strip-json-comments" ),
gzip = require( "gzip-js" ),
srcHintOptions = readOptionalJSON( "src/.jshintrc" ),
newNode = !/^v0/.test( process.version ),
// Allow to skip jsdom-related tests in Node.js < 1.0.0
runJsdomTests = newNode || ( function() {
try {
require( "jsdom" );
return true;
} catch ( e ) {
return false;
}
} )();
// The concatenated file won't pass onevar
// But our modules can
delete srcHintOptions.onevar;
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
dst: readOptionalJSON( "dist/.destination.json" ),
"compare_size": {
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
options: {
compress: {
gz: function( contents ) {
return gzip.zip( contents, {} ).length;
}
},
cache: "build/.sizecache.json"
}
},
babel: {
options: {
sourceMap: "inline",
retainLines: true
},
nodeSmokeTests: {
files: {
"test/node_smoke_tests/lib/ensure_iterability.js":
"test/node_smoke_tests/lib/ensure_iterability_es6.js"
}
}
},
build: {
all: {
dest: "dist/jquery.js",
minimum: [
"core",
"selector"
],
// Exclude specified modules if the module matching the key is removed
removeWith: {
ajax: [ "manipulation/_evalUrl", "event/ajax" ],
callbacks: [ "deferred" ],
css: [ "effects", "dimensions", "offset" ],
sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
}
}
},
npmcopy: {
all: {
options: {
destPrefix: "external"
},
files: {
"sizzle/dist": "sizzle/dist",
"sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
"npo/npo.js": "native-promise-only/npo.js",
"qunit/qunit.js": "qunitjs/qunit/qunit.js",
"qunit/qunit.css": "qunitjs/qunit/qunit.css",
"qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
"qunit-assert-step/qunit-assert-step.js":
"qunit-assert-step/qunit-assert-step.js",
"qunit-assert-step/MIT-LICENSE.txt":
"qunit-assert-step/MIT-LICENSE.txt",
"requirejs/require.js": "requirejs/require.js",
"sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
"sinon/LICENSE.txt": "sinon/LICENSE"
}
}
},
jsonlint: {
pkg: {
src: [ "package.json" ]
}
},
jshint: {
all: {
src: [
"src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
],
options: {
jshintrc: true
}
},
dist: {
src: "dist/jquery.js",
options: srcHintOptions
}
},
jscs: {
src: "src",
gruntfile: "Gruntfile.js",
// Check parts of tests that pass
test: [
"test/data/testrunner.js",
"test/unit/basic.js",
"test/unit/wrap.js"
],
build: "build"
},
testswarm: {
tests: [
// A special module with basic tests, meant for
// not fully supported environments like Android 2.3,
// jsdom or PhantomJS. We run it everywhere, though,
// to make sure tests are not broken.
"basic",
"ajax",
"attributes",
"callbacks",
"core",
"css",
"data",
"deferred",
"deprecated",
"dimensions",
"effects",
"event",
"manipulation",
"offset",
"queue",
"selector",
"serialize",
"support",
"traversing"
]
},
watch: {
files: [ "<%= jshint.all.src %>" ],
tasks: [ "dev" ]
},
uglify: {
all: {
files: {
"dist/jquery.min.js": [ "dist/jquery.js" ]
},
options: {
preserveComments: false,
sourceMap: true,
sourceMapName: "dist/jquery.min.map",
report: "min",
beautify: {
"ascii_only": true
},
banner: "/*! jQuery v<%= pkg.version %> | " +
"(c) jQuery Foundation | jquery.org/license */",
compress: {
"hoist_funs": false,
loops: false,
unused: false
}
}
}
}
} );
// Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt );
// Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" );
grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
// Don't run Node-related tests in Node.js < 1.0.0 as they require an old
// jsdom version that needs compiling, making it harder for people to compile
// jQuery on Windows. (see gh-2519)
grunt.registerTask( "test_fast", runJsdomTests ? [ "node_smoke_tests" ] : [] );
grunt.registerTask( "test", [ "test_fast" ] );
// Short list as a high frequency watch task
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
};

View file

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

View file

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

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,5 @@
/*! Native Promise Only
v0.7.8-a (c) Kyle Simpson
MIT License: http://getify.mit-license.org
*/
!function(t,n,e){n[t]=n[t]||e(),"undefined"!=typeof module&&module.exports?module.exports=n[t]:"function"==typeof define&&define.amd&&define(function(){return n[t]})}("Promise","undefined"!=typeof global?global:this,function(){"use strict";function t(t,n){l.add(t,n),h||(h=y(l.drain))}function n(t){var n,e=typeof t;return null==t||"object"!=e&&"function"!=e||(n=t.then),"function"==typeof n?n:!1}function e(){for(var t=0;t<this.chain.length;t++)o(this,1===this.state?this.chain[t].success:this.chain[t].failure,this.chain[t]);this.chain.length=0}function o(t,e,o){var r,i;try{e===!1?o.reject(t.msg):(r=e===!0?t.msg:e.call(void 0,t.msg),r===o.promise?o.reject(TypeError("Promise-chain cycle")):(i=n(r))?i.call(r,o.resolve,o.reject):o.resolve(r))}catch(c){o.reject(c)}}function r(o){var c,u,a=this;if(!a.triggered){a.triggered=!0,a.def&&(a=a.def);try{(c=n(o))?(u=new f(a),c.call(o,function(){r.apply(u,arguments)},function(){i.apply(u,arguments)})):(a.msg=o,a.state=1,a.chain.length>0&&t(e,a))}catch(s){i.call(u||new f(a),s)}}}function i(n){var o=this;o.triggered||(o.triggered=!0,o.def&&(o=o.def),o.msg=n,o.state=2,o.chain.length>0&&t(e,o))}function c(t,n,e,o){for(var r=0;r<n.length;r++)!function(r){t.resolve(n[r]).then(function(t){e(r,t)},o)}(r)}function f(t){this.def=t,this.triggered=!1}function u(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function a(n){if("function"!=typeof n)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var o=new u(this);this.then=function(n,r){var i={success:"function"==typeof n?n:!0,failure:"function"==typeof r?r:!1};return i.promise=new this.constructor(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");i.resolve=t,i.reject=n}),o.chain.push(i),0!==o.state&&t(e,o),i.promise},this["catch"]=function(t){return this.then(void 0,t)};try{n.call(void 0,function(t){r.call(o,t)},function(t){i.call(o,t)})}catch(c){i.call(o,c)}}var s,h,l,p=Object.prototype.toString,y="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout;try{Object.defineProperty({},"x",{}),s=function(t,n,e,o){return Object.defineProperty(t,n,{value:e,writable:!0,configurable:o!==!1})}}catch(d){s=function(t,n,e){return t[n]=e,t}}l=function(){function t(t,n){this.fn=t,this.self=n,this.next=void 0}var n,e,o;return{add:function(r,i){o=new t(r,i),e?e.next=o:n=o,e=o,o=void 0},drain:function(){var t=n;for(n=e=h=void 0;t;)t.fn.call(t.self),t=t.next}}}();var g=s({},"constructor",a,!1);return a.prototype=g,s(g,"__NPO__",0,!1),s(a,"resolve",function(t){var n=this;return t&&"object"==typeof t&&1===t.__NPO__?t:new n(function(n,e){if("function"!=typeof n||"function"!=typeof e)throw TypeError("Not a function");n(t)})}),s(a,"reject",function(t){return new this(function(n,e){if("function"!=typeof n||"function"!=typeof e)throw TypeError("Not a function");e(t)})}),s(a,"all",function(t){var n=this;return"[object Array]"!=p.call(t)?n.reject(TypeError("Not an array")):0===t.length?n.resolve([]):new n(function(e,o){if("function"!=typeof e||"function"!=typeof o)throw TypeError("Not a function");var r=t.length,i=Array(r),f=0;c(n,t,function(t,n){i[t]=n,++f===r&&e(i)},o)})}),s(a,"race",function(t){var n=this;return"[object Array]"!=p.call(t)?n.reject(TypeError("Not an array")):new n(function(e,o){if("function"!=typeof e||"function"!=typeof o)throw TypeError("Not a function");c(n,t,function(t,n){e(n)},o)})}),a});

View file

@ -1,4 +1,4 @@
Copyright 2014 jQuery Foundation and other contributors Copyright jQuery Foundation and other contributors
http://jquery.com/ http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining

View file

@ -0,0 +1,26 @@
QUnit.extend( QUnit.assert, {
/**
* Check the sequence/order
*
* @example test('Example unit test', function(assert) { assert.step(1); setTimeout(function () { assert.step(3); start(); }, 100); assert.step(2); stop(); });
* @param Number expected The excepted step within the test()
* @param String message (optional)
*/
step: function (expected, message) {
// increment internal step counter.
QUnit.config.current.step++;
if (typeof message === "undefined") {
message = "step " + expected;
}
var actual = QUnit.config.current.step;
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
}
});
/**
* Reset the step counter for every test()
*/
QUnit.testStart(function () {
QUnit.config.current.step = 0;
});

View file

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/qunit
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

View file

@ -0,0 +1,21 @@
Copyright 2013 jQuery Foundation and other contributors
http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,280 @@
/*!
* QUnit 1.17.1
* http://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-01-20T19:39Z
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699A4;
background-color: #0D3349;
font-size: 1.5em;
line-height: 1em;
font-weight: 400;
border-radius: 5px 5px 0 0;
}
#qunit-header a {
text-decoration: none;
color: #C2CCD1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #FFF;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 0.5em 0 0.1em;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
background-color: #2B81AF;
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
padding: 0.2em;
}
.qunit-url-config {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
float: right;
margin-left: 1em;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #FFF;
border-radius: 5px;
}
.qunit-collapsed {
display: none;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: 0.2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 0.5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #E0F2BE;
color: #374E0C;
text-decoration: none;
}
#qunit-tests ins {
background-color: #FFCACA;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: #000; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #FFF;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #FFF;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
}
#qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
/** Result */
#qunit-testresult {
padding: 0.5em 1em 0.5em 1em;
color: #2B81AF;
background-color: #D2E0E6;
border-bottom: 1px solid #FFF;
}
#qunit-testresult .module-name {
font-weight: 700;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/sizzle
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

View file

@ -1,12 +1,12 @@
/*! /*!
* Sizzle CSS Selector Engine v2.2.0-pre * Sizzle CSS Selector Engine v2.2.1
* http://sizzlejs.com/ * http://sizzlejs.com/
* *
* Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-12-16 * Date: 2015-10-17
*/ */
(function( window ) { (function( window ) {
@ -74,25 +74,21 @@ var i,
// Regular expressions // Regular expressions
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace // http://www.w3.org/TR/css3-selectors/#whitespace
whitespace = "[\\x20\\t\\r\\n\\f]", whitespace = "[\\x20\\t\\r\\n\\f]",
// http://www.w3.org/TR/css3-syntax/#characters
characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
// Loosely modeled on CSS identifier characters // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
// An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
identifier = characterEncoding.replace( "w", "w#" ),
// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
// Operator (capture 2) // Operator (capture 2)
"*([*^$|!~]?=)" + whitespace + "*([*^$|!~]?=)" + whitespace +
// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
"*\\]", "*\\]",
pseudos = ":(" + characterEncoding + ")(?:\\((" + pseudos = ":(" + identifier + ")(?:\\((" +
// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
// 1. quoted (capture 3; capture 4 or capture 5) // 1. quoted (capture 3; capture 4 or capture 5)
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
@ -115,9 +111,9 @@ var i,
ridentifier = new RegExp( "^" + identifier + "$" ), ridentifier = new RegExp( "^" + identifier + "$" ),
matchExpr = { matchExpr = {
"ID": new RegExp( "^#(" + characterEncoding + ")" ), "ID": new RegExp( "^#(" + identifier + ")" ),
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), "TAG": new RegExp( "^(" + identifier + "|[*])" ),
"ATTR": new RegExp( "^" + attributes ), "ATTR": new RegExp( "^" + attributes ),
"PSEUDO": new RegExp( "^" + pseudos ), "PSEUDO": new RegExp( "^" + pseudos ),
"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
@ -195,103 +191,129 @@ try {
} }
function Sizzle( selector, context, results, seed ) { function Sizzle( selector, context, results, seed ) {
var match, elem, m, nodeType, var m, i, elem, nid, nidselect, match, groups, newSelector,
// QSA vars newContext = context && context.ownerDocument,
i, groups, old, nid, newContext, newSelector;
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { // nodeType defaults to 9, since context defaults to document
setDocument( context ); nodeType = context ? context.nodeType : 9;
}
context = context || document;
results = results || []; results = results || [];
nodeType = context.nodeType;
// Return early from calls with invalid selector or context
if ( typeof selector !== "string" || !selector || if ( typeof selector !== "string" || !selector ||
nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
return results; return results;
} }
if ( !seed && documentIsHTML ) { // Try to shortcut find operations (as opposed to filters) in HTML documents
if ( !seed ) {
if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
setDocument( context );
}
context = context || document;
if ( documentIsHTML ) {
// If the selector is sufficiently simple, try using a "get*By*" DOM method
// (excepting DocumentFragment context, where the methods don't exist)
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
// ID selector
if ( (m = match[1]) ) {
// Document context
if ( nodeType === 9 ) {
if ( (elem = context.getElementById( m )) ) {
// Support: IE, Opera, Webkit
// TODO: identify versions
// getElementById can match elements by name instead of ID
if ( elem.id === m ) {
results.push( elem );
return results;
}
} else {
return results;
}
// Element context
} else {
// Support: IE, Opera, Webkit
// TODO: identify versions
// getElementById can match elements by name instead of ID
if ( newContext && (elem = newContext.getElementById( m )) &&
contains( context, elem ) &&
elem.id === m ) {
// Try to shortcut find operations when possible (e.g., not under DocumentFragment)
if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
// Speed-up: Sizzle("#ID")
if ( (m = match[1]) ) {
if ( nodeType === 9 ) {
elem = context.getElementById( m );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document (jQuery #6963)
if ( elem && elem.parentNode ) {
// Handle the case where IE, Opera, and Webkit return items
// by name instead of ID
if ( elem.id === m ) {
results.push( elem ); results.push( elem );
return results; return results;
} }
} else {
return results;
} }
} else {
// Context is not a document
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
contains( context, elem ) && elem.id === m ) {
results.push( elem );
return results;
}
}
// Speed-up: Sizzle("TAG") // Type selector
} else if ( match[2] ) { } else if ( match[2] ) {
push.apply( results, context.getElementsByTagName( selector ) ); push.apply( results, context.getElementsByTagName( selector ) );
return results;
// Speed-up: Sizzle(".CLASS")
} else if ( (m = match[3]) && support.getElementsByClassName ) {
push.apply( results, context.getElementsByClassName( m ) );
return results;
}
}
// QSA path
if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
nid = old = expando;
newContext = context;
newSelector = nodeType !== 1 && selector;
// qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
groups = tokenize( selector );
if ( (old = context.getAttribute("id")) ) {
nid = old.replace( rescape, "\\$&" );
} else {
context.setAttribute( "id", nid );
}
nid = "[id='" + nid + "'] ";
i = groups.length;
while ( i-- ) {
groups[i] = nid + toSelector( groups[i] );
}
newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
newSelector = groups.join(",");
}
if ( newSelector ) {
try {
push.apply( results,
newContext.querySelectorAll( newSelector )
);
return results; return results;
} catch(qsaError) {
} finally { // Class selector
if ( !old ) { } else if ( (m = match[3]) && support.getElementsByClassName &&
context.removeAttribute("id"); context.getElementsByClassName ) {
push.apply( results, context.getElementsByClassName( m ) );
return results;
}
}
// Take advantage of querySelectorAll
if ( support.qsa &&
!compilerCache[ selector + " " ] &&
(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
if ( nodeType !== 1 ) {
newContext = context;
newSelector = selector;
// qSA looks outside Element context, which is not what we want
// Thanks to Andrew Dupont for this workaround technique
// Support: IE <=8
// Exclude object elements
} else if ( context.nodeName.toLowerCase() !== "object" ) {
// Capture the context ID, setting it first if necessary
if ( (nid = context.getAttribute( "id" )) ) {
nid = nid.replace( rescape, "\\$&" );
} else {
context.setAttribute( "id", (nid = expando) );
}
// Prefix every selector in the list
groups = tokenize( selector );
i = groups.length;
nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
while ( i-- ) {
groups[i] = nidselect + " " + toSelector( groups[i] );
}
newSelector = groups.join( "," );
// Expand context for sibling selectors
newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
context;
}
if ( newSelector ) {
try {
push.apply( results,
newContext.querySelectorAll( newSelector )
);
return results;
} catch ( qsaError ) {
} finally {
if ( nid === expando ) {
context.removeAttribute( "id" );
}
} }
} }
} }
@ -304,7 +326,7 @@ function Sizzle( selector, context, results, seed ) {
/** /**
* Create key-value caches of limited size * Create key-value caches of limited size
* @returns {Function(string, Object)} Returns the Object data after storing it on itself with * @returns {function(string, object)} Returns the Object data after storing it on itself with
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
* deleting the oldest entry * deleting the oldest entry
*/ */
@ -359,7 +381,7 @@ function assert( fn ) {
*/ */
function addHandle( attrs, handler ) { function addHandle( attrs, handler ) {
var arr = attrs.split("|"), var arr = attrs.split("|"),
i = attrs.length; i = arr.length;
while ( i-- ) { while ( i-- ) {
Expr.attrHandle[ arr[i] ] = handler; Expr.attrHandle[ arr[i] ] = handler;
@ -472,33 +494,29 @@ setDocument = Sizzle.setDocument = function( node ) {
var hasCompare, parent, var hasCompare, parent,
doc = node ? node.ownerDocument || node : preferredDoc; doc = node ? node.ownerDocument || node : preferredDoc;
// If no document and documentElement is available, return // Return early if doc is invalid or already selected
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
return document; return document;
} }
// Set our document // Update global variables
document = doc; document = doc;
docElem = doc.documentElement; docElem = document.documentElement;
parent = doc.defaultView; documentIsHTML = !isXML( document );
// Support: IE>8 // Support: IE 9-11, Edge
// If iframe document is assigned to "document" variable and if iframe has been reloaded, // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 if ( (parent = document.defaultView) && parent.top !== parent ) {
// IE6-8 do not support the defaultView property so parent will be undefined // Support: IE 11
if ( parent && parent !== parent.top ) {
// IE11 does not have attachEvent, so all must suffer
if ( parent.addEventListener ) { if ( parent.addEventListener ) {
parent.addEventListener( "unload", unloadHandler, false ); parent.addEventListener( "unload", unloadHandler, false );
// Support: IE 9 - 10 only
} else if ( parent.attachEvent ) { } else if ( parent.attachEvent ) {
parent.attachEvent( "onunload", unloadHandler ); parent.attachEvent( "onunload", unloadHandler );
} }
} }
/* Support tests
---------------------------------------------------------------------- */
documentIsHTML = !isXML( doc );
/* Attributes /* Attributes
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
@ -515,12 +533,12 @@ setDocument = Sizzle.setDocument = function( node ) {
// Check if getElementsByTagName("*") returns only elements // Check if getElementsByTagName("*") returns only elements
support.getElementsByTagName = assert(function( div ) { support.getElementsByTagName = assert(function( div ) {
div.appendChild( doc.createComment("") ); div.appendChild( document.createComment("") );
return !div.getElementsByTagName("*").length; return !div.getElementsByTagName("*").length;
}); });
// Support: IE<9 // Support: IE<9
support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); support.getElementsByClassName = rnative.test( document.getElementsByClassName );
// Support: IE<10 // Support: IE<10
// Check if getElementById returns elements by name // Check if getElementById returns elements by name
@ -528,7 +546,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// so use a roundabout getElementsByName test // so use a roundabout getElementsByName test
support.getById = assert(function( div ) { support.getById = assert(function( div ) {
docElem.appendChild( div ).id = expando; docElem.appendChild( div ).id = expando;
return !doc.getElementsByName || !doc.getElementsByName( expando ).length; return !document.getElementsByName || !document.getElementsByName( expando ).length;
}); });
// ID find and filter // ID find and filter
@ -536,9 +554,7 @@ setDocument = Sizzle.setDocument = function( node ) {
Expr.find["ID"] = function( id, context ) { Expr.find["ID"] = function( id, context ) {
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
var m = context.getElementById( id ); var m = context.getElementById( id );
// Check parentNode to catch when Blackberry 4.6 returns return m ? [ m ] : [];
// nodes that are no longer in the document #6963
return m && m.parentNode ? [ m ] : [];
} }
}; };
Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
@ -555,7 +571,8 @@ setDocument = Sizzle.setDocument = function( node ) {
Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
var attrId = id.replace( runescape, funescape ); var attrId = id.replace( runescape, funescape );
return function( elem ) { return function( elem ) {
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); var node = typeof elem.getAttributeNode !== "undefined" &&
elem.getAttributeNode("id");
return node && node.value === attrId; return node && node.value === attrId;
}; };
}; };
@ -595,7 +612,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// Class // Class
Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
if ( documentIsHTML ) { if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
return context.getElementsByClassName( className ); return context.getElementsByClassName( className );
} }
}; };
@ -615,7 +632,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// See http://bugs.jquery.com/ticket/13378 // See http://bugs.jquery.com/ticket/13378
rbuggyQSA = []; rbuggyQSA = [];
if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
// Build QSA regex // Build QSA regex
// Regex strategy adopted from Diego Perini // Regex strategy adopted from Diego Perini
assert(function( div ) { assert(function( div ) {
@ -625,7 +642,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// since its presence should be enough // since its presence should be enough
// http://bugs.jquery.com/ticket/12359 // http://bugs.jquery.com/ticket/12359
docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
"<select id='" + expando + "-\f]' msallowcapture=''>" + "<select id='" + expando + "-\r\\' msallowcapture=''>" +
"<option selected=''></option></select>"; "<option selected=''></option></select>";
// Support: IE8, Opera 11-12.16 // Support: IE8, Opera 11-12.16
@ -642,7 +659,7 @@ setDocument = Sizzle.setDocument = function( node ) {
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
} }
// Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
rbuggyQSA.push("~="); rbuggyQSA.push("~=");
} }
@ -665,7 +682,7 @@ setDocument = Sizzle.setDocument = function( node ) {
assert(function( div ) { assert(function( div ) {
// Support: Windows 8 Native Apps // Support: Windows 8 Native Apps
// The type and name attributes are restricted during .innerHTML assignment // The type and name attributes are restricted during .innerHTML assignment
var input = doc.createElement("input"); var input = document.createElement("input");
input.setAttribute( "type", "hidden" ); input.setAttribute( "type", "hidden" );
div.appendChild( input ).setAttribute( "name", "D" ); div.appendChild( input ).setAttribute( "name", "D" );
@ -713,7 +730,7 @@ setDocument = Sizzle.setDocument = function( node ) {
hasCompare = rnative.test( docElem.compareDocumentPosition ); hasCompare = rnative.test( docElem.compareDocumentPosition );
// Element contains another // Element contains another
// Purposefully does not implement inclusive descendent // Purposefully self-exclusive
// As in, an element does not contain itself // As in, an element does not contain itself
contains = hasCompare || rnative.test( docElem.contains ) ? contains = hasCompare || rnative.test( docElem.contains ) ?
function( a, b ) { function( a, b ) {
@ -767,10 +784,10 @@ setDocument = Sizzle.setDocument = function( node ) {
(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
// Choose the first element that is related to our preferred document // Choose the first element that is related to our preferred document
if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
return -1; return -1;
} }
if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
return 1; return 1;
} }
@ -798,8 +815,8 @@ setDocument = Sizzle.setDocument = function( node ) {
// Parentless nodes are either documents or disconnected // Parentless nodes are either documents or disconnected
if ( !aup || !bup ) { if ( !aup || !bup ) {
return a === doc ? -1 : return a === document ? -1 :
b === doc ? 1 : b === document ? 1 :
aup ? -1 : aup ? -1 :
bup ? 1 : bup ? 1 :
sortInput ? sortInput ?
@ -836,7 +853,7 @@ setDocument = Sizzle.setDocument = function( node ) {
0; 0;
}; };
return doc; return document;
}; };
Sizzle.matches = function( expr, elements ) { Sizzle.matches = function( expr, elements ) {
@ -853,6 +870,7 @@ Sizzle.matchesSelector = function( elem, expr ) {
expr = expr.replace( rattributeQuotes, "='$1']" ); expr = expr.replace( rattributeQuotes, "='$1']" );
if ( support.matchesSelector && documentIsHTML && if ( support.matchesSelector && documentIsHTML &&
!compilerCache[ expr + " " ] &&
( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
@ -1126,11 +1144,12 @@ Expr = Sizzle.selectors = {
} : } :
function( elem, context, xml ) { function( elem, context, xml ) {
var cache, outerCache, node, diff, nodeIndex, start, var cache, uniqueCache, outerCache, node, nodeIndex, start,
dir = simple !== forward ? "nextSibling" : "previousSibling", dir = simple !== forward ? "nextSibling" : "previousSibling",
parent = elem.parentNode, parent = elem.parentNode,
name = ofType && elem.nodeName.toLowerCase(), name = ofType && elem.nodeName.toLowerCase(),
useCache = !xml && !ofType; useCache = !xml && !ofType,
diff = false;
if ( parent ) { if ( parent ) {
@ -1139,7 +1158,10 @@ Expr = Sizzle.selectors = {
while ( dir ) { while ( dir ) {
node = elem; node = elem;
while ( (node = node[ dir ]) ) { while ( (node = node[ dir ]) ) {
if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { if ( ofType ?
node.nodeName.toLowerCase() === name :
node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -1153,11 +1175,21 @@ Expr = Sizzle.selectors = {
// non-xml :nth-child(...) stores cache data on `parent` // non-xml :nth-child(...) stores cache data on `parent`
if ( forward && useCache ) { if ( forward && useCache ) {
// Seek `elem` from a previously-cached index // Seek `elem` from a previously-cached index
outerCache = parent[ expando ] || (parent[ expando ] = {});
cache = outerCache[ type ] || []; // ...in a gzip-friendly way
nodeIndex = cache[0] === dirruns && cache[1]; node = parent;
diff = cache[0] === dirruns && cache[2]; outerCache = node[ expando ] || (node[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ node.uniqueID ] ||
(outerCache[ node.uniqueID ] = {});
cache = uniqueCache[ type ] || [];
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
diff = nodeIndex && cache[ 2 ];
node = nodeIndex && parent.childNodes[ nodeIndex ]; node = nodeIndex && parent.childNodes[ nodeIndex ];
while ( (node = ++nodeIndex && node && node[ dir ] || while ( (node = ++nodeIndex && node && node[ dir ] ||
@ -1167,29 +1199,55 @@ Expr = Sizzle.selectors = {
// When found, cache indexes on `parent` and break // When found, cache indexes on `parent` and break
if ( node.nodeType === 1 && ++diff && node === elem ) { if ( node.nodeType === 1 && ++diff && node === elem ) {
outerCache[ type ] = [ dirruns, nodeIndex, diff ]; uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
break; break;
} }
} }
// Use previously-cached element index if available
} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
diff = cache[1];
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
} else { } else {
// Use the same loop as above to seek `elem` from the start // Use previously-cached element index if available
while ( (node = ++nodeIndex && node && node[ dir ] || if ( useCache ) {
(diff = nodeIndex = 0) || start.pop()) ) { // ...in a gzip-friendly way
node = elem;
outerCache = node[ expando ] || (node[ expando ] = {});
if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { // Support: IE <9 only
// Cache the index of each encountered element // Defend against cloned attroperties (jQuery gh-1709)
if ( useCache ) { uniqueCache = outerCache[ node.uniqueID ] ||
(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; (outerCache[ node.uniqueID ] = {});
}
if ( node === elem ) { cache = uniqueCache[ type ] || [];
break; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
diff = nodeIndex;
}
// xml :nth-child(...)
// or :nth-last-child(...) or :nth(-last)?-of-type(...)
if ( diff === false ) {
// Use the same loop as above to seek `elem` from the start
while ( (node = ++nodeIndex && node && node[ dir ] ||
(diff = nodeIndex = 0) || start.pop()) ) {
if ( ( ofType ?
node.nodeName.toLowerCase() === name :
node.nodeType === 1 ) &&
++diff ) {
// Cache the index of each encountered element
if ( useCache ) {
outerCache = node[ expando ] || (node[ expando ] = {});
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ node.uniqueID ] ||
(outerCache[ node.uniqueID ] = {});
uniqueCache[ type ] = [ dirruns, diff ];
}
if ( node === elem ) {
break;
}
} }
} }
} }
@ -1551,10 +1609,10 @@ function addCombinator( matcher, combinator, base ) {
// Check against all ancestor/preceding elements // Check against all ancestor/preceding elements
function( elem, context, xml ) { function( elem, context, xml ) {
var oldCache, outerCache, var oldCache, uniqueCache, outerCache,
newCache = [ dirruns, doneName ]; newCache = [ dirruns, doneName ];
// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
if ( xml ) { if ( xml ) {
while ( (elem = elem[ dir ]) ) { while ( (elem = elem[ dir ]) ) {
if ( elem.nodeType === 1 || checkNonElements ) { if ( elem.nodeType === 1 || checkNonElements ) {
@ -1567,14 +1625,19 @@ function addCombinator( matcher, combinator, base ) {
while ( (elem = elem[ dir ]) ) { while ( (elem = elem[ dir ]) ) {
if ( elem.nodeType === 1 || checkNonElements ) { if ( elem.nodeType === 1 || checkNonElements ) {
outerCache = elem[ expando ] || (elem[ expando ] = {}); outerCache = elem[ expando ] || (elem[ expando ] = {});
if ( (oldCache = outerCache[ dir ]) &&
// Support: IE <9 only
// Defend against cloned attroperties (jQuery gh-1709)
uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
if ( (oldCache = uniqueCache[ dir ]) &&
oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
// Assign to newCache so results back-propagate to previous elements // Assign to newCache so results back-propagate to previous elements
return (newCache[ 2 ] = oldCache[ 2 ]); return (newCache[ 2 ] = oldCache[ 2 ]);
} else { } else {
// Reuse newcache so results back-propagate to previous elements // Reuse newcache so results back-propagate to previous elements
outerCache[ dir ] = newCache; uniqueCache[ dir ] = newCache;
// A match means we're done; a fail means we have to keep checking // A match means we're done; a fail means we have to keep checking
if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
@ -1799,18 +1862,21 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
len = elems.length; len = elems.length;
if ( outermost ) { if ( outermost ) {
outermostContext = context !== document && context; outermostContext = context === document || context || outermost;
} }
// Add elements passing elementMatchers directly to results // Add elements passing elementMatchers directly to results
// Keep `i` a string if there are no elements so `matchedCount` will be "00" below
// Support: IE<9, Safari // Support: IE<9, Safari
// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
for ( ; i !== len && (elem = elems[i]) != null; i++ ) { for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
if ( byElement && elem ) { if ( byElement && elem ) {
j = 0; j = 0;
if ( !context && elem.ownerDocument !== document ) {
setDocument( elem );
xml = !documentIsHTML;
}
while ( (matcher = elementMatchers[j++]) ) { while ( (matcher = elementMatchers[j++]) ) {
if ( matcher( elem, context, xml ) ) { if ( matcher( elem, context || document, xml) ) {
results.push( elem ); results.push( elem );
break; break;
} }
@ -1834,8 +1900,17 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
} }
} }
// Apply set filters to unmatched elements // `i` is now the count of elements visited above, and adding it to `matchedCount`
// makes the latter nonnegative.
matchedCount += i; matchedCount += i;
// Apply set filters to unmatched elements
// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
// no element matchers and no seed.
// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
// case, which will result in a "00" `matchedCount` that differs from `i` but is also
// numerically zero.
if ( bySet && i !== matchedCount ) { if ( bySet && i !== matchedCount ) {
j = 0; j = 0;
while ( (matcher = setMatchers[j++]) ) { while ( (matcher = setMatchers[j++]) ) {
@ -1927,10 +2002,11 @@ select = Sizzle.select = function( selector, context, results, seed ) {
results = results || []; results = results || [];
// Try to minimize operations if there is no seed and only one group // Try to minimize operations if there is only one selector in the list and no seed
// (the latter of which guarantees us context)
if ( match.length === 1 ) { if ( match.length === 1 ) {
// Take a shortcut and set the context if the root selector is an ID // Reduce context if the leading compound selector is an ID
tokens = match[0] = match[0].slice( 0 ); tokens = match[0] = match[0].slice( 0 );
if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
support.getById && context.nodeType === 9 && documentIsHTML && support.getById && context.nodeType === 9 && documentIsHTML &&
@ -1985,7 +2061,7 @@ select = Sizzle.select = function( selector, context, results, seed ) {
context, context,
!documentIsHTML, !documentIsHTML,
results, results,
rsibling.test( selector ) && testContext( context.parentNode ) || context !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
); );
return results; return results;
}; };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,84 @@
{
"name": "jquery",
"title": "jQuery",
"description": "JavaScript library for DOM operations",
"version": "2.2.0",
"main": "dist/jquery.js",
"homepage": "http://jquery.com",
"author": {
"name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery/blob/2.2.0/AUTHORS.txt"
},
"repository": {
"type": "git",
"url": "https://github.com/jquery/jquery.git"
},
"keywords": [
"jquery",
"javascript",
"browser",
"library"
],
"bugs": {
"url": "https://github.com/jquery/jquery/issues"
},
"license": "MIT",
"dependencies": {},
"devDependencies": {
"commitplease": "2.0.0",
"core-js": "0.9.17",
"grunt": "0.4.5",
"grunt-babel": "5.0.1",
"grunt-cli": "0.1.13",
"grunt-compare-size": "0.4.0",
"grunt-contrib-jshint": "0.11.2",
"grunt-contrib-uglify": "0.9.2",
"grunt-contrib-watch": "0.6.1",
"grunt-git-authors": "2.0.1",
"grunt-jscs": "2.1.0",
"grunt-jsonlint": "1.0.4",
"grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2",
"jsdom": "5.6.1",
"load-grunt-tasks": "1.0.0",
"qunitjs": "1.17.1",
"qunit-assert-step": "1.0.3",
"requirejs": "2.1.17",
"sinon": "1.10.3",
"sizzle": "2.2.1",
"strip-json-comments": "1.0.3",
"testswarm": "1.1.0",
"win-spawn": "2.0.0"
},
"scripts": {
"build": "npm install && grunt",
"start": "grunt watch",
"test": "grunt && grunt test"
},
"commitplease": {
"components": [
"Docs",
"Tests",
"Build",
"Release",
"Core",
"Ajax",
"Attributes",
"Callbacks",
"CSS",
"Data",
"Deferred",
"Deprecated",
"Dimensions",
"Effects",
"Event",
"Manipulation",
"Offset",
"Queue",
"Selector",
"Serialize",
"Traversing",
"Wrap"
]
}
}

View file

@ -0,0 +1,29 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"quotmark": "double",
"undef": true,
"unused": true,
"sub": true,
// Support: IE < 10, Android < 4.1
// The above browsers are failing a lot of tests in the ES5
// test suite at http://test262.ecmascript.org.
"es3": true,
"globals": {
"window": true,
"JSON": false,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
}
}

View file

@ -1,23 +1,27 @@
define([ define( [
"./core", "./core",
"./var/document",
"./var/rnotwhite", "./var/rnotwhite",
"./ajax/var/location",
"./ajax/var/nonce", "./ajax/var/nonce",
"./ajax/var/rquery", "./ajax/var/rquery",
"./core/init", "./core/init",
"./ajax/parseJSON", "./ajax/parseJSON",
"./ajax/parseXML", "./ajax/parseXML",
"./event/trigger",
"./deferred" "./deferred"
], function( jQuery, rnotwhite, nonce, rquery ) { ], function( jQuery, document, rnotwhite, location, nonce, rquery ) {
var var
rhash = /#.*$/, rhash = /#.*$/,
rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
// #7653, #8125, #8152: local protocol detection // #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent = /^(?:GET|HEAD)$/, rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//, rprotocol = /^\/\//,
rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
/* Prefilters /* Prefilters
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
@ -40,11 +44,9 @@ var
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = "*/".concat( "*" ), allTypes = "*/".concat( "*" ),
// Document location // Anchor tag for parsing the document origin
ajaxLocation = window.location.href, originAnchor = document.createElement( "a" );
originAnchor.href = location.href;
// Segment location into parts
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) { function addToPrefiltersOrTransports( structure ) {
@ -62,16 +64,18 @@ function addToPrefiltersOrTransports( structure ) {
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
if ( jQuery.isFunction( func ) ) { if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression // For each dataType in the dataTypeExpression
while ( (dataType = dataTypes[i++]) ) { while ( ( dataType = dataTypes[ i++ ] ) ) {
// Prepend if requested // Prepend if requested
if ( dataType[0] === "+" ) { if ( dataType[ 0 ] === "+" ) {
dataType = dataType.slice( 1 ) || "*"; dataType = dataType.slice( 1 ) || "*";
(structure[ dataType ] = structure[ dataType ] || []).unshift( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
// Otherwise append // Otherwise append
} else { } else {
(structure[ dataType ] = structure[ dataType ] || []).push( func ); ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
} }
} }
} }
@ -89,14 +93,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
inspected[ dataType ] = true; inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) { if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport ); options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport ); inspect( dataTypeOrTransport );
return false; return false;
} else if ( seekingTransport ) { } else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport ); return !( selected = dataTypeOrTransport );
} }
}); } );
return selected; return selected;
} }
@ -112,7 +118,7 @@ function ajaxExtend( target, src ) {
for ( key in src ) { for ( key in src ) {
if ( src[ key ] !== undefined ) { if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ]; ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
} }
} }
if ( deep ) { if ( deep ) {
@ -136,7 +142,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
while ( dataTypes[ 0 ] === "*" ) { while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift(); dataTypes.shift();
if ( ct === undefined ) { if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
} }
} }
@ -154,9 +160,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
if ( dataTypes[ 0 ] in responses ) { if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ]; finalDataType = dataTypes[ 0 ];
} else { } else {
// Try convertible dataTypes // Try convertible dataTypes
for ( type in responses ) { for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type; finalDataType = type;
break; break;
} }
@ -164,6 +171,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
firstDataType = type; firstDataType = type;
} }
} }
// Or just use first one // Or just use first one
finalDataType = finalDataType || firstDataType; finalDataType = finalDataType || firstDataType;
} }
@ -185,6 +193,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
function ajaxConvert( s, response, jqXHR, isSuccess ) { function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev, var conv2, current, conv, tmp, prev,
converters = {}, converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion // Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice(); dataTypes = s.dataTypes.slice();
@ -237,6 +246,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
conv = converters[ prev + " " + tmp[ 0 ] ] || conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ]; converters[ "* " + tmp[ 0 ] ];
if ( conv ) { if ( conv ) {
// Condense equivalence converters // Condense equivalence converters
if ( conv === true ) { if ( conv === true ) {
conv = converters[ conv2 ]; conv = converters[ conv2 ];
@ -256,13 +266,16 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( conv !== true ) { if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them // Unless errors are allowed to bubble, catch and return them
if ( conv && s[ "throws" ] ) { if ( conv && s.throws ) {
response = conv( response ); response = conv( response );
} else { } else {
try { try {
response = conv( response ); response = conv( response );
} catch ( e ) { } catch ( e ) {
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; return {
state: "parsererror",
error: conv ? e : "No conversion from " + prev + " to " + current
};
} }
} }
} }
@ -273,7 +286,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
return { state: "success", data: response }; return { state: "success", data: response };
} }
jQuery.extend({ jQuery.extend( {
// Counter for holding the number of active queries // Counter for holding the number of active queries
active: 0, active: 0,
@ -283,9 +296,9 @@ jQuery.extend({
etag: {}, etag: {},
ajaxSettings: { ajaxSettings: {
url: ajaxLocation, url: location.href,
type: "GET", type: "GET",
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), isLocal: rlocalProtocol.test( location.protocol ),
global: true, global: true,
processData: true, processData: true,
async: true, async: true,
@ -311,9 +324,9 @@ jQuery.extend({
}, },
contents: { contents: {
xml: /xml/, xml: /\bxml\b/,
html: /html/, html: /\bhtml/,
json: /json/ json: /\bjson\b/
}, },
responseFields: { responseFields: {
@ -378,39 +391,55 @@ jQuery.extend({
options = options || {}; options = options || {};
var transport, var transport,
// URL without anti-cache param // URL without anti-cache param
cacheURL, cacheURL,
// Response headers // Response headers
responseHeadersString, responseHeadersString,
responseHeaders, responseHeaders,
// timeout handle // timeout handle
timeoutTimer, timeoutTimer,
// Cross-domain detection vars
parts, // Url cleanup var
urlAnchor,
// To know if global events are to be dispatched // To know if global events are to be dispatched
fireGlobals, fireGlobals,
// Loop variable // Loop variable
i, i,
// Create the final options object // Create the final options object
s = jQuery.ajaxSetup( {}, options ), s = jQuery.ajaxSetup( {}, options ),
// Callbacks context // Callbacks context
callbackContext = s.context || s, callbackContext = s.context || s,
// Context for global events is callbackContext if it is a DOM node or jQuery collection // Context for global events is callbackContext if it is a DOM node or jQuery collection
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ? globalEventContext = s.context &&
jQuery( callbackContext ) : ( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery.event, jQuery( callbackContext ) :
jQuery.event,
// Deferreds // Deferreds
deferred = jQuery.Deferred(), deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks("once memory"), completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks // Status-dependent callbacks
statusCode = s.statusCode || {}, statusCode = s.statusCode || {},
// Headers (they are sent all at once) // Headers (they are sent all at once)
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {}, requestHeadersNames = {},
// The jqXHR state // The jqXHR state
state = 0, state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
readyState: 0, readyState: 0,
@ -421,8 +450,8 @@ jQuery.extend({
if ( state === 2 ) { if ( state === 2 ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( (match = rheaders.exec( responseHeadersString )) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
} }
} }
match = responseHeaders[ key.toLowerCase() ]; match = responseHeaders[ key.toLowerCase() ];
@ -459,10 +488,12 @@ jQuery.extend({
if ( map ) { if ( map ) {
if ( state < 2 ) { if ( state < 2 ) {
for ( code in map ) { for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones // Lazy-add the new callback in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
} }
} else { } else {
// Execute the appropriate callbacks // Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] ); jqXHR.always( map[ jqXHR.status ] );
} }
@ -490,8 +521,8 @@ jQuery.extend({
// Add protocol if not provided (prefilters might expect it) // Add protocol if not provided (prefilters might expect it)
// Handle falsy url in the settings object (#10093: consistency with old signature) // Handle falsy url in the settings object (#10093: consistency with old signature)
// We also use the url parameter if available // We also use the url parameter if available
s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ) s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" )
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); .replace( rprotocol, location.protocol + "//" );
// Alias method option to type as per ticket #12004 // Alias method option to type as per ticket #12004
s.type = options.method || options.type || s.method || s.type; s.type = options.method || options.type || s.method || s.type;
@ -499,14 +530,26 @@ jQuery.extend({
// Extract dataTypes list // Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
// A cross-domain request is in order when we have a protocol:host:port mismatch // A cross-domain request is in order when the origin doesn't match the current origin.
if ( s.crossDomain == null ) { if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() ); urlAnchor = document.createElement( "a" );
s.crossDomain = !!( parts &&
( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] || // Support: IE8-11+
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !== // IE throws exception if url is malformed, e.g. http://example.com:80x/
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) ) try {
); urlAnchor.href = s.url;
// Support: IE8-11+
// Anchor's host property isn't correctly set when s.url is relative
urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) {
// If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid
s.crossDomain = true;
}
} }
// Convert data if not already a string // Convert data if not already a string
@ -528,7 +571,7 @@ jQuery.extend({
// Watch for a new set of requests // Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) { if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger("ajaxStart"); jQuery.event.trigger( "ajaxStart" );
} }
// Uppercase the type // Uppercase the type
@ -547,6 +590,7 @@ jQuery.extend({
// If data is available, append data to url // If data is available, append data to url
if ( s.data ) { if ( s.data ) {
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
// #9682: remove data so that it's not used in an eventual retry // #9682: remove data so that it's not used in an eventual retry
delete s.data; delete s.data;
} }
@ -581,8 +625,9 @@ jQuery.extend({
// Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader( jqXHR.setRequestHeader(
"Accept", "Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ] s.accepts[ "*" ]
); );
@ -592,7 +637,9 @@ jQuery.extend({
} }
// Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { if ( s.beforeSend &&
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
// Abort if not done already and return // Abort if not done already and return
return jqXHR.abort(); return jqXHR.abort();
} }
@ -618,10 +665,16 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
} }
// If request was aborted inside ajaxSend, stop there
if ( state === 2 ) {
return jqXHR;
}
// Timeout // Timeout
if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
timeoutTimer = setTimeout(function() { timeoutTimer = window.setTimeout( function() {
jqXHR.abort("timeout"); jqXHR.abort( "timeout" );
}, s.timeout ); }, s.timeout );
} }
@ -629,9 +682,11 @@ jQuery.extend({
state = 1; state = 1;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Propagate exception as error if not done // Propagate exception as error if not done
if ( state < 2 ) { if ( state < 2 ) {
done( -1, e ); done( -1, e );
// Simply rethrow otherwise // Simply rethrow otherwise
} else { } else {
throw e; throw e;
@ -654,7 +709,7 @@ jQuery.extend({
// Clear timeout if it exists // Clear timeout if it exists
if ( timeoutTimer ) { if ( timeoutTimer ) {
clearTimeout( timeoutTimer ); window.clearTimeout( timeoutTimer );
} }
// Dereference transport for early garbage collection // Dereference transport for early garbage collection
@ -683,11 +738,11 @@ jQuery.extend({
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) { if ( s.ifModified ) {
modified = jqXHR.getResponseHeader("Last-Modified"); modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) { if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified; jQuery.lastModified[ cacheURL ] = modified;
} }
modified = jqXHR.getResponseHeader("etag"); modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) { if ( modified ) {
jQuery.etag[ cacheURL ] = modified; jQuery.etag[ cacheURL ] = modified;
} }
@ -709,6 +764,7 @@ jQuery.extend({
isSuccess = !error; isSuccess = !error;
} }
} else { } else {
// Extract error from statusText and normalize for non-aborts // Extract error from statusText and normalize for non-aborts
error = statusText; error = statusText;
if ( status || !statusText ) { if ( status || !statusText ) {
@ -744,9 +800,10 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter // Handle the global AJAX counter
if ( !( --jQuery.active ) ) { if ( !( --jQuery.active ) ) {
jQuery.event.trigger("ajaxStop"); jQuery.event.trigger( "ajaxStop" );
} }
} }
} }
@ -761,10 +818,11 @@ jQuery.extend({
getScript: function( url, callback ) { getScript: function( url, callback ) {
return jQuery.get( url, undefined, callback, "script" ); return jQuery.get( url, undefined, callback, "script" );
} }
}); } );
jQuery.each( [ "get", "post" ], function( i, method ) { jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) { jQuery[ method ] = function( url, data, callback, type ) {
// Shift arguments if data argument was omitted // Shift arguments if data argument was omitted
if ( jQuery.isFunction( data ) ) { if ( jQuery.isFunction( data ) ) {
type = type || callback; type = type || callback;
@ -772,15 +830,16 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
data = undefined; data = undefined;
} }
return jQuery.ajax({ // The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend( {
url: url, url: url,
type: method, type: method,
dataType: type, dataType: type,
data: data, data: data,
success: callback success: callback
}); }, jQuery.isPlainObject( url ) && url ) );
}; };
}); } );
return jQuery; return jQuery;
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"./var/nonce", "./var/nonce",
"./var/rquery", "./var/rquery",
@ -9,14 +9,14 @@ var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/; rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings // Default jsonp settings
jQuery.ajaxSetup({ jQuery.ajaxSetup( {
jsonp: "callback", jsonp: "callback",
jsonpCallback: function() { jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true; this[ callback ] = true;
return callback; return callback;
} }
}); } );
// Detect, normalize options and install callbacks for jsonp requests // Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
@ -24,7 +24,10 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer, var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" : "url" :
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" typeof s.data === "string" &&
( s.contentType || "" )
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
); );
// Handle iff the expected data type is "jsonp" or we have a parameter to set // Handle iff the expected data type is "jsonp" or we have a parameter to set
@ -43,14 +46,14 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
} }
// Use data converter to retrieve json after script execution // Use data converter to retrieve json after script execution
s.converters["script json"] = function() { s.converters[ "script json" ] = function() {
if ( !responseContainer ) { if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" ); jQuery.error( callbackName + " was not called" );
} }
return responseContainer[ 0 ]; return responseContainer[ 0 ];
}; };
// force json dataType // Force json dataType
s.dataTypes[ 0 ] = "json"; s.dataTypes[ 0 ] = "json";
// Install callback // Install callback
@ -60,16 +63,24 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}; };
// Clean-up function (fires after converters) // Clean-up function (fires after converters)
jqXHR.always(function() { jqXHR.always( function() {
// Restore preexisting value
window[ callbackName ] = overwritten; // If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
// Otherwise restore preexisting value
} else {
window[ callbackName ] = overwritten;
}
// Save back as free // Save back as free
if ( s[ callbackName ] ) { if ( s[ callbackName ] ) {
// make sure that re-using the options doesn't screw things around
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback; s.jsonpCallback = originalSettings.jsonpCallback;
// save the callback name for future use // Save the callback name for future use
oldCallbacks.push( callbackName ); oldCallbacks.push( callbackName );
} }
@ -79,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
} }
responseContainer = overwritten = undefined; responseContainer = overwritten = undefined;
}); } );
// Delegate to script // Delegate to script
return "script"; return "script";
} }
}); } );
}); } );

View file

@ -1,10 +1,11 @@
define([ define( [
"../core", "../core",
"../core/parseHTML", "../core/parseHTML",
"../ajax", "../ajax",
"../traversing", "../traversing",
"../manipulation", "../manipulation",
"../selector", "../selector",
// Optional event/alias dependency // Optional event/alias dependency
"../event/alias" "../event/alias"
], function( jQuery ) { ], function( jQuery ) {
@ -22,9 +23,9 @@ jQuery.fn.load = function( url, params, callback ) {
var selector, type, response, var selector, type, response,
self = this, self = this,
off = url.indexOf(" "); off = url.indexOf( " " );
if ( off >= 0 ) { if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) ); selector = jQuery.trim( url.slice( off ) );
url = url.slice( 0, off ); url = url.slice( 0, off );
} }
@ -43,14 +44,16 @@ jQuery.fn.load = function( url, params, callback ) {
// If we have elements to modify, make the request // If we have elements to modify, make the request
if ( self.length > 0 ) { if ( self.length > 0 ) {
jQuery.ajax({ jQuery.ajax( {
url: url, url: url,
// if "type" variable is undefined, then "GET" method will be used // If "type" variable is undefined, then "GET" method will be used.
type: type, // Make value of this field explicit since
// user can override it through ajaxSetup method
type: type || "GET",
dataType: "html", dataType: "html",
data: params data: params
}).done(function( responseText ) { } ).done( function( responseText ) {
// Save response for use in complete callback // Save response for use in complete callback
response = arguments; response = arguments;
@ -59,17 +62,22 @@ jQuery.fn.load = function( url, params, callback ) {
// If a selector was specified, locate the right elements in a dummy div // If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors // Exclude scripts to avoid IE 'Permission Denied' errors
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result // Otherwise use the full result
responseText ); responseText );
}).complete( callback && function( jqXHR, status ) { // If the request succeeds, this function gets "data", "status", "jqXHR"
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); // but they are ignored because response was set above.
}); // If it fails, this function gets "jqXHR", "status", "error"
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
} }
return this; return this;
}; };
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
@ -10,4 +10,4 @@ jQuery.parseJSON = function( data ) {
return jQuery.parseJSON; return jQuery.parseJSON;
}); } );

View file

@ -1,18 +1,17 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// Cross-browser xml parsing // Cross-browser xml parsing
jQuery.parseXML = function( data ) { jQuery.parseXML = function( data ) {
var xml, tmp; var xml;
if ( !data || typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
return null; return null;
} }
// Support: IE9 // Support: IE9
try { try {
tmp = new DOMParser(); xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
xml = tmp.parseFromString( data, "text/xml" );
} catch ( e ) { } catch ( e ) {
xml = undefined; xml = undefined;
} }
@ -25,4 +24,4 @@ jQuery.parseXML = function( data ) {
return jQuery.parseXML; return jQuery.parseXML;
}); } );

View file

@ -1,15 +1,17 @@
define([ define( [
"../core", "../core",
"../var/document",
"../ajax" "../ajax"
], function( jQuery ) { ], function( jQuery, document ) {
// Install script dataType // Install script dataType
jQuery.ajaxSetup({ jQuery.ajaxSetup( {
accepts: { accepts: {
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
}, },
contents: { contents: {
script: /(?:java|ecma)script/ script: /\b(?:java|ecma)script\b/
}, },
converters: { converters: {
"text script": function( text ) { "text script": function( text ) {
@ -17,7 +19,7 @@ jQuery.ajaxSetup({
return text; return text;
} }
} }
}); } );
// Handle cache's special case and crossDomain // Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) { jQuery.ajaxPrefilter( "script", function( s ) {
@ -27,20 +29,20 @@ jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.crossDomain ) { if ( s.crossDomain ) {
s.type = "GET"; s.type = "GET";
} }
}); } );
// Bind script tag hack transport // Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) { jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain requests // This transport only deals with cross domain requests
if ( s.crossDomain ) { if ( s.crossDomain ) {
var script, callback; var script, callback;
return { return {
send: function( _, complete ) { send: function( _, complete ) {
script = jQuery("<script>").prop({ script = jQuery( "<script>" ).prop( {
async: true,
charset: s.scriptCharset, charset: s.scriptCharset,
src: s.url src: s.url
}).on( } ).on(
"load error", "load error",
callback = function( evt ) { callback = function( evt ) {
script.remove(); script.remove();
@ -50,6 +52,8 @@ jQuery.ajaxTransport( "script", function( s ) {
} }
} }
); );
// Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] ); document.head.appendChild( script[ 0 ] );
}, },
abort: function() { abort: function() {
@ -59,6 +63,6 @@ jQuery.ajaxTransport( "script", function( s ) {
} }
}; };
} }
}); } );
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/support", "../var/support",
"../ajax" "../ajax"
@ -6,47 +6,41 @@ define([
jQuery.ajaxSettings.xhr = function() { jQuery.ajaxSettings.xhr = function() {
try { try {
return new XMLHttpRequest(); return new window.XMLHttpRequest();
} catch( e ) {} } catch ( e ) {}
}; };
var xhrId = 0, var xhrSuccessStatus = {
xhrCallbacks = {},
xhrSuccessStatus = { // File protocol always yields status code 0, assume 200
// file protocol always yields status code 0, assume 200
0: 200, 0: 200,
// Support: IE9 // Support: IE9
// #1450: sometimes IE returns 1223 when it should be 204 // #1450: sometimes IE returns 1223 when it should be 204
1223: 204 1223: 204
}, },
xhrSupported = jQuery.ajaxSettings.xhr(); xhrSupported = jQuery.ajaxSettings.xhr();
// Support: IE9
// Open requests must be manually aborted on unload (#5280)
// See https://support.microsoft.com/kb/2856746 for more info
if ( window.attachEvent ) {
window.attachEvent( "onunload", function() {
for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]();
}
});
}
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported; support.ajax = xhrSupported = !!xhrSupported;
jQuery.ajaxTransport(function( options ) { jQuery.ajaxTransport( function( options ) {
var callback; var callback, errorCallback;
// Cross domain only allowed if supported through XMLHttpRequest // Cross domain only allowed if supported through XMLHttpRequest
if ( support.cors || xhrSupported && !options.crossDomain ) { if ( support.cors || xhrSupported && !options.crossDomain ) {
return { return {
send: function( headers, complete ) { send: function( headers, complete ) {
var i, var i,
xhr = options.xhr(), xhr = options.xhr();
id = ++xhrId;
xhr.open( options.type, options.url, options.async, options.username, options.password ); xhr.open(
options.type,
options.url,
options.async,
options.username,
options.password
);
// Apply custom fields if provided // Apply custom fields if provided
if ( options.xhrFields ) { if ( options.xhrFields ) {
@ -65,8 +59,8 @@ jQuery.ajaxTransport(function( options ) {
// akin to a jigsaw puzzle, we simply never set it to be sure. // akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup) // (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided. // For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers["X-Requested-With"] ) { if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers["X-Requested-With"] = "XMLHttpRequest"; headers[ "X-Requested-With" ] = "XMLHttpRequest";
} }
// Set headers // Set headers
@ -78,27 +72,38 @@ jQuery.ajaxTransport(function( options ) {
callback = function( type ) { callback = function( type ) {
return function() { return function() {
if ( callback ) { if ( callback ) {
delete xhrCallbacks[ id ]; callback = errorCallback = xhr.onload =
callback = xhr.onload = xhr.onerror = null; xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
if ( type === "abort" ) { if ( type === "abort" ) {
xhr.abort(); xhr.abort();
} else if ( type === "error" ) { } else if ( type === "error" ) {
complete(
// file: protocol always yields status 0; see #8605, #14207 // Support: IE9
xhr.status, // On a manual native abort, IE9 throws
xhr.statusText // errors on any property access that is not readyState
); if ( typeof xhr.status !== "number" ) {
complete( 0, "error" );
} else {
complete(
// File: protocol always yields status 0; see #8605, #14207
xhr.status,
xhr.statusText
);
}
} else { } else {
complete( complete(
xhrSuccessStatus[ xhr.status ] || xhr.status, xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText, xhr.statusText,
// Support: IE9
// Accessing binary-data responseText throws an exception // Support: IE9 only
// (#11426) // IE9 has no XHR2 but throws on binary (trac-11426)
typeof xhr.responseText === "string" ? { // For XHR2 non-text, let the caller handle it (gh-2498)
text: xhr.responseText ( xhr.responseType || "text" ) !== "text" ||
} : undefined, typeof xhr.responseText !== "string" ?
{ binary: xhr.response } :
{ text: xhr.responseText },
xhr.getAllResponseHeaders() xhr.getAllResponseHeaders()
); );
} }
@ -108,15 +113,41 @@ jQuery.ajaxTransport(function( options ) {
// Listen to events // Listen to events
xhr.onload = callback(); xhr.onload = callback();
xhr.onerror = callback("error"); errorCallback = xhr.onerror = callback( "error" );
// Support: IE9
// Use onreadystatechange to replace onabort
// to handle uncaught aborts
if ( xhr.onabort !== undefined ) {
xhr.onabort = errorCallback;
} else {
xhr.onreadystatechange = function() {
// Check readyState before timeout as it changes
if ( xhr.readyState === 4 ) {
// Allow onerror to be called first,
// but that will not handle a native abort
// Also, save errorCallback to a variable
// as xhr.onerror cannot be accessed
window.setTimeout( function() {
if ( callback ) {
errorCallback();
}
} );
}
};
}
// Create the abort callback // Create the abort callback
callback = xhrCallbacks[ id ] = callback("abort"); callback = callback( "abort" );
try { try {
// Do send the request (this may raise an exception) // Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null ); xhr.send( options.hasContent && options.data || null );
} catch ( e ) { } catch ( e ) {
// #14683: Only rethrow if this hasn't been notified as an error yet // #14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) { if ( callback ) {
throw e; throw e;
@ -131,6 +162,6 @@ jQuery.ajaxTransport(function( options ) {
} }
}; };
} }
}); } );
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./attributes/attr", "./attributes/attr",
"./attributes/prop", "./attributes/prop",
@ -8,4 +8,4 @@ define([
// Return jQuery for attributes-only inclusion // Return jQuery for attributes-only inclusion
return jQuery; return jQuery;
}); } );

View file

@ -1,39 +1,38 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite",
"../var/strundefined",
"../core/access", "../core/access",
"./support", "./support",
"../var/rnotwhite",
"../selector" "../selector"
], function( jQuery, rnotwhite, strundefined, access, support ) { ], function( jQuery, access, support, rnotwhite ) {
var nodeHook, boolHook, var boolHook,
attrHandle = jQuery.expr.attrHandle; attrHandle = jQuery.expr.attrHandle;
jQuery.fn.extend({ jQuery.fn.extend( {
attr: function( name, value ) { attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 ); return access( this, jQuery.attr, name, value, arguments.length > 1 );
}, },
removeAttr: function( name ) { removeAttr: function( name ) {
return this.each(function() { return this.each( function() {
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); } );
} }
}); } );
jQuery.extend({ jQuery.extend( {
attr: function( elem, name, value ) { attr: function( elem, name, value ) {
var hooks, ret, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // Don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
return; return;
} }
// Fallback to prop when attributes are not supported // Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === strundefined ) { if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value ); return jQuery.prop( elem, name, value );
} }
@ -42,53 +41,32 @@ jQuery.extend({
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
name = name.toLowerCase(); name = name.toLowerCase();
hooks = jQuery.attrHooks[ name ] || hooks = jQuery.attrHooks[ name ] ||
( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
} }
if ( value !== undefined ) { if ( value !== undefined ) {
if ( value === null ) { if ( value === null ) {
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
return;
}
} else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret; return ret;
} else {
elem.setAttribute( name, value + "" );
return value;
} }
} else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { elem.setAttribute( name, value + "" );
return value;
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret; return ret;
} else {
ret = jQuery.find.attr( elem, name );
// Non-existent attributes return null, we normalize to undefined
return ret == null ?
undefined :
ret;
} }
},
removeAttr: function( elem, value ) { ret = jQuery.find.attr( elem, name );
var name, propName,
i = 0,
attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) { // Non-existent attributes return null, we normalize to undefined
while ( (name = attrNames[i++]) ) { return ret == null ? undefined : ret;
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false
elem[ propName ] = false;
}
elem.removeAttribute( name );
}
}
}, },
attrHooks: { attrHooks: {
@ -105,13 +83,35 @@ jQuery.extend({
} }
} }
} }
},
removeAttr: function( elem, value ) {
var name, propName,
i = 0,
attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) {
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( jQuery.expr.match.bool.test( name ) ) {
// Set corresponding property to false
elem[ propName ] = false;
}
elem.removeAttribute( name );
}
}
} }
}); } );
// Hooks for boolean attributes // Hooks for boolean attributes
boolHook = { boolHook = {
set: function( elem, value, name ) { set: function( elem, value, name ) {
if ( value === false ) { if ( value === false ) {
// Remove boolean attributes when set to false // Remove boolean attributes when set to false
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
} else { } else {
@ -126,6 +126,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
attrHandle[ name ] = function( elem, name, isXML ) { attrHandle[ name ] = function( elem, name, isXML ) {
var ret, handle; var ret, handle;
if ( !isXML ) { if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter // Avoid an infinite loop by temporarily removing this function from the getter
handle = attrHandle[ name ]; handle = attrHandle[ name ];
attrHandle[ name ] = ret; attrHandle[ name ] = ret;
@ -136,6 +137,6 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
} }
return ret; return ret;
}; };
}); } );
}); } );

View file

@ -1,49 +1,47 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite", "../var/rnotwhite",
"../var/strundefined", "../data/var/dataPriv",
"../data/var/data_priv",
"../core/init" "../core/init"
], function( jQuery, rnotwhite, strundefined, data_priv ) { ], function( jQuery, rnotwhite, dataPriv ) {
var rclass = /[\t\r\n\f]/g; var rclass = /[\t\r\n\f]/g;
jQuery.fn.extend({ function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
jQuery.fn.extend( {
addClass: function( value ) { addClass: function( value ) {
var classes, elem, cur, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
proceed = typeof value === "string" && value, i = 0;
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, this.className ) ); jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) { if ( typeof value === "string" && value ) {
// The disjunction here is for better compressibility (see removeClass) classes = value.match( rnotwhite ) || [];
classes = ( value || "" ).match( rnotwhite ) || [];
for ( ; i < len; i++ ) { while ( ( elem = this[ i++ ] ) ) {
elem = this[ i ]; curValue = getClass( elem );
cur = elem.nodeType === 1 && ( elem.className ? cur = elem.nodeType === 1 &&
( " " + elem.className + " " ).replace( rclass, " " ) : ( " " + curValue + " " ).replace( rclass, " " );
" "
);
if ( cur ) { if ( cur ) {
j = 0; j = 0;
while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " "; cur += clazz + " ";
} }
} }
// only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = jQuery.trim( cur ); finalValue = jQuery.trim( cur );
if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
elem.className = finalValue; elem.setAttribute( "class", finalValue );
} }
} }
} }
@ -53,40 +51,43 @@ jQuery.fn.extend({
}, },
removeClass: function( value ) { removeClass: function( value ) {
var classes, elem, cur, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
proceed = arguments.length === 0 || typeof value === "string" && value, i = 0;
i = 0,
len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, this.className ) ); jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) {
classes = ( value || "" ).match( rnotwhite ) || [];
for ( ; i < len; i++ ) { if ( !arguments.length ) {
elem = this[ i ]; return this.attr( "class", "" );
}
if ( typeof value === "string" && value ) {
classes = value.match( rnotwhite ) || [];
while ( ( elem = this[ i++ ] ) ) {
curValue = getClass( elem );
// This expression is here for better compressibility (see addClass) // This expression is here for better compressibility (see addClass)
cur = elem.nodeType === 1 && ( elem.className ? cur = elem.nodeType === 1 &&
( " " + elem.className + " " ).replace( rclass, " " ) : ( " " + curValue + " " ).replace( rclass, " " );
""
);
if ( cur ) { if ( cur ) {
j = 0; j = 0;
while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances // Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " ); cur = cur.replace( " " + clazz + " ", " " );
} }
} }
// Only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = value ? jQuery.trim( cur ) : ""; finalValue = jQuery.trim( cur );
if ( elem.className !== finalValue ) { if ( curValue !== finalValue ) {
elem.className = finalValue; elem.setAttribute( "class", finalValue );
} }
} }
} }
@ -103,20 +104,26 @@ jQuery.fn.extend({
} }
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( i ) { return this.each( function( i ) {
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); jQuery( this ).toggleClass(
}); value.call( this, i, getClass( this ), stateVal ),
stateVal
);
} );
} }
return this.each(function() { return this.each( function() {
if ( type === "string" ) { var className, i, self, classNames;
// Toggle individual class names
var className, if ( type === "string" ) {
i = 0,
self = jQuery( this ), // Toggle individual class names
classNames = value.match( rnotwhite ) || []; i = 0;
self = jQuery( this );
classNames = value.match( rnotwhite ) || [];
while ( ( className = classNames[ i++ ] ) ) {
while ( (className = classNames[ i++ ]) ) {
// Check each className given, space separated list // Check each className given, space separated list
if ( self.hasClass( className ) ) { if ( self.hasClass( className ) ) {
self.removeClass( className ); self.removeClass( className );
@ -126,33 +133,45 @@ jQuery.fn.extend({
} }
// Toggle whole class name // Toggle whole class name
} else if ( type === strundefined || type === "boolean" ) { } else if ( value === undefined || type === "boolean" ) {
if ( this.className ) { className = getClass( this );
// store className if set if ( className ) {
data_priv.set( this, "__className__", this.className );
// Store className if set
dataPriv.set( this, "__className__", className );
} }
// If the element has a class name or if we're passed `false`, // If the element has a class name or if we're passed `false`,
// then remove the whole classname (if there was one, the above saved it). // then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything), // Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored. // falling back to the empty string if nothing was stored.
this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; if ( this.setAttribute ) {
this.setAttribute( "class",
className || value === false ?
"" :
dataPriv.get( this, "__className__" ) || ""
);
}
} }
}); } );
}, },
hasClass: function( selector ) { hasClass: function( selector ) {
var className = " " + selector + " ", var className, elem,
i = 0, i = 0;
l = this.length;
for ( ; i < l; i++ ) { className = " " + selector + " ";
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { while ( ( elem = this[ i++ ] ) ) {
if ( elem.nodeType === 1 &&
( " " + getClass( elem ) + " " ).replace( rclass, " " )
.indexOf( className ) > -1
) {
return true; return true;
} }
} }
return false; return false;
} }
}); } );
}); } );

View file

@ -1,68 +1,83 @@
define([ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support" "./support",
"../selector"
], function( jQuery, access, support ) { ], function( jQuery, access, support ) {
var rfocusable = /^(?:input|select|textarea|button)$/i; var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
jQuery.fn.extend({ jQuery.fn.extend( {
prop: function( name, value ) { prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 ); return access( this, jQuery.prop, name, value, arguments.length > 1 );
}, },
removeProp: function( name ) { removeProp: function( name ) {
return this.each(function() { return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ]; delete this[ jQuery.propFix[ name ] || name ];
}); } );
} }
}); } );
jQuery.extend({
propFix: {
"for": "htmlFor",
"class": "className"
},
jQuery.extend( {
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var ret, hooks, notxml, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes // Don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( nType === 3 || nType === 8 || nType === 2 ) {
return; return;
} }
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
if ( notxml ) {
// Fix name and attach hooks // Fix name and attach hooks
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ]; hooks = jQuery.propHooks[ name ];
} }
if ( value !== undefined ) { if ( value !== undefined ) {
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? if ( hooks && "set" in hooks &&
ret : ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
( elem[ name ] = value ); return ret;
}
} else { return ( elem[ name ] = value );
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
ret :
elem[ name ];
} }
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
return elem[ name ];
}, },
propHooks: { propHooks: {
tabIndex: { tabIndex: {
get: function( elem ) { get: function( elem ) {
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
elem.tabIndex : // elem.tabIndex doesn't always return the
-1; // correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
// Use proper attribute retrieval(#12072)
var tabindex = jQuery.find.attr( elem, "tabindex" );
return tabindex ?
parseInt( tabindex, 10 ) :
rfocusable.test( elem.nodeName ) ||
rclickable.test( elem.nodeName ) && elem.href ?
0 :
-1;
} }
} }
},
propFix: {
"for": "htmlFor",
"class": "className"
} }
}); } );
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
@ -76,7 +91,7 @@ if ( !support.optSelected ) {
}; };
} }
jQuery.each([ jQuery.each( [
"tabIndex", "tabIndex",
"readOnly", "readOnly",
"maxLength", "maxLength",
@ -89,6 +104,6 @@ jQuery.each([
"contentEditable" "contentEditable"
], function() { ], function() {
jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
}); } );
}); } );

View file

@ -1,8 +1,9 @@
define([ define( [
"../var/document",
"../var/support" "../var/support"
], function( support ) { ], function( document, support ) {
(function() { ( function() {
var input = document.createElement( "input" ), var input = document.createElement( "input" ),
select = document.createElement( "select" ), select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) ); opt = select.appendChild( document.createElement( "option" ) );
@ -28,8 +29,8 @@ define([
input.value = "t"; input.value = "t";
input.type = "radio"; input.type = "radio";
support.radioValue = input.value === "t"; support.radioValue = input.value === "t";
})(); } )();
return support; return support;
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"./support", "./support",
"../core/init" "../core/init"
@ -6,24 +6,30 @@ define([
var rreturn = /\r/g; var rreturn = /\r/g;
jQuery.fn.extend({ jQuery.fn.extend( {
val: function( value ) { val: function( value ) {
var hooks, ret, isFunction, var hooks, ret, isFunction,
elem = this[0]; elem = this[ 0 ];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { if ( hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret; return ret;
} }
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// Handle most common string cases // Handle most common string cases
ret.replace(rreturn, "") : ret.replace( rreturn, "" ) :
// Handle cases where value is null/undef or number // Handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
@ -33,7 +39,7 @@ jQuery.fn.extend({
isFunction = jQuery.isFunction( value ); isFunction = jQuery.isFunction( value );
return this.each(function( i ) { return this.each( function( i ) {
var val; var val;
if ( this.nodeType !== 1 ) { if ( this.nodeType !== 1 ) {
@ -56,29 +62,27 @@ jQuery.fn.extend({
} else if ( jQuery.isArray( val ) ) { } else if ( jQuery.isArray( val ) ) {
val = jQuery.map( val, function( value ) { val = jQuery.map( val, function( value ) {
return value == null ? "" : value + ""; return value == null ? "" : value + "";
}); } );
} }
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting // If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val; this.value = val;
} }
}); } );
} }
}); } );
jQuery.extend({ jQuery.extend( {
valHooks: { valHooks: {
option: { option: {
get: function( elem ) { get: function( elem ) {
var val = jQuery.find.attr( elem, "value" );
return val != null ? // Support: IE<11
val : // option.value not trimmed (#14858)
// Support: IE10-11+ return jQuery.trim( elem.value );
// option.text throws exceptions (#14686, #14858)
jQuery.trim( jQuery.text( elem ) );
} }
}, },
select: { select: {
@ -97,11 +101,14 @@ jQuery.extend({
for ( ; i < max; i++ ) { for ( ; i < max; i++ ) {
option = options[ i ]; option = options[ i ];
// IE6-9 doesn't update selected after form reset (#2551) // IE8-9 doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) && if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup // Don't return options that are disabled or in a disabled optgroup
( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) && ( support.optDisabled ?
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { !option.disabled : option.getAttribute( "disabled" ) === null ) &&
( !option.parentNode.disabled ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option // Get the specific value for the option
value = jQuery( option ).val(); value = jQuery( option ).val();
@ -127,7 +134,9 @@ jQuery.extend({
while ( i-- ) { while ( i-- ) {
option = options[ i ]; option = options[ i ];
if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true; optionSet = true;
} }
} }
@ -140,22 +149,22 @@ jQuery.extend({
} }
} }
} }
}); } );
// Radios and checkboxes getter/setter // Radios and checkboxes getter/setter
jQuery.each([ "radio", "checkbox" ], function() { jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = { jQuery.valHooks[ this ] = {
set: function( elem, value ) { set: function( elem, value ) {
if ( jQuery.isArray( value ) ) { if ( jQuery.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
} }
} }
}; };
if ( !support.checkOn ) { if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) { jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute("value") === null ? "on" : elem.value; return elem.getAttribute( "value" ) === null ? "on" : elem.value;
}; };
} }
}); } );
}); } );

View file

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

View file

@ -1,5 +1,6 @@
define([ define( [
"./var/arr", "./var/arr",
"./var/document",
"./var/slice", "./var/slice",
"./var/concat", "./var/concat",
"./var/push", "./var/push",
@ -8,16 +9,14 @@ define([
"./var/toString", "./var/toString",
"./var/hasOwn", "./var/hasOwn",
"./var/support" "./var/support"
], function( arr, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { ], function( arr, document, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
var var
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
version = "@VERSION", version = "@VERSION",
// Define a local copy of jQuery // Define a local copy of jQuery
jQuery = function( selector, context ) { jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced' // The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included) // Need init if jQuery is called (just allow error to be thrown if not included)
return new jQuery.fn.init( selector, context ); return new jQuery.fn.init( selector, context );
@ -37,6 +36,7 @@ var
}; };
jQuery.fn = jQuery.prototype = { jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used // The current version of jQuery being used
jquery: version, jquery: version,
@ -80,16 +80,14 @@ jQuery.fn = jQuery.prototype = {
}, },
// Execute a callback for every element in the matched set. // Execute a callback for every element in the matched set.
// (You can seed the arguments with an array of args, but this is each: function( callback ) {
// only used internally.) return jQuery.each( this, callback );
each: function( callback, args ) {
return jQuery.each( this, callback, args );
}, },
map: function( callback ) { map: function( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) { return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem ); return callback.call( elem, i, elem );
})); } ) );
}, },
slice: function() { slice: function() {
@ -107,11 +105,11 @@ jQuery.fn = jQuery.prototype = {
eq: function( i ) { eq: function( i ) {
var len = this.length, var len = this.length,
j = +i + ( i < 0 ? len : 0 ); j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
}, },
end: function() { end: function() {
return this.prevObject || this.constructor(null); return this.prevObject || this.constructor();
}, },
// For internal use only. // For internal use only.
@ -123,7 +121,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.extend = jQuery.fn.extend = function() { jQuery.extend = jQuery.fn.extend = function() {
var options, name, src, copy, copyIsArray, clone, var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {}, target = arguments[ 0 ] || {},
i = 1, i = 1,
length = arguments.length, length = arguments.length,
deep = false; deep = false;
@ -138,7 +136,7 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
// Handle case when target is a string or something (possible in deep copy) // Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
target = {}; target = {};
} }
@ -149,8 +147,10 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values // Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) { if ( ( options = arguments[ i ] ) != null ) {
// Extend the base object // Extend the base object
for ( name in options ) { for ( name in options ) {
src = target[ name ]; src = target[ name ];
@ -162,13 +162,15 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
// Recurse if we're merging plain objects or arrays // Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
( copyIsArray = jQuery.isArray( copy ) ) ) ) {
if ( copyIsArray ) { if ( copyIsArray ) {
copyIsArray = false; copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : []; clone = src && jQuery.isArray( src ) ? src : [];
} else { } else {
clone = src && jQuery.isPlainObject(src) ? src : {}; clone = src && jQuery.isPlainObject( src ) ? src : {};
} }
// Never move original objects, clone them // Never move original objects, clone them
@ -186,7 +188,8 @@ jQuery.extend = jQuery.fn.extend = function() {
return target; return target;
}; };
jQuery.extend({ jQuery.extend( {
// Unique for each copy of jQuery on the page // Unique for each copy of jQuery on the page
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
@ -200,7 +203,7 @@ jQuery.extend({
noop: function() {}, noop: function() {},
isFunction: function( obj ) { isFunction: function( obj ) {
return jQuery.type(obj) === "function"; return jQuery.type( obj ) === "function";
}, },
isArray: Array.isArray, isArray: Array.isArray,
@ -210,14 +213,17 @@ jQuery.extend({
}, },
isNumeric: function( obj ) { isNumeric: function( obj ) {
// parseFloat NaNs numeric-cast false positives (null|true|false|"") // parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...") // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN // subtraction forces infinities to NaN
// adding 1 corrects loss of precision from parseFloat (#15100) // adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; var realStringObj = obj && obj.toString();
return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
}, },
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
// Not plain objects: // Not plain objects:
// - Any object or value whose internal [[Class]] property is not "[object Object]" // - Any object or value whose internal [[Class]] property is not "[object Object]"
// - DOM nodes // - DOM nodes
@ -248,9 +254,10 @@ jQuery.extend({
if ( obj == null ) { if ( obj == null ) {
return obj + ""; return obj + "";
} }
// Support: Android<4.0, iOS<6 (functionish RegExp) // Support: Android<4.0, iOS<6 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" : class2type[ toString.call( obj ) ] || "object" :
typeof obj; typeof obj;
}, },
@ -262,16 +269,19 @@ jQuery.extend({
code = jQuery.trim( code ); code = jQuery.trim( code );
if ( code ) { if ( code ) {
// If the code includes a valid, prologue position // If the code includes a valid, prologue position
// strict mode pragma, execute code by injecting a // strict mode pragma, execute code by injecting a
// script tag into the document. // script tag into the document.
if ( code.indexOf("use strict") === 1 ) { if ( code.indexOf( "use strict" ) === 1 ) {
script = document.createElement("script"); script = document.createElement( "script" );
script.text = code; script.text = code;
document.head.appendChild( script ).parentNode.removeChild( script ); document.head.appendChild( script ).parentNode.removeChild( script );
} else { } else {
// Otherwise, avoid the DOM node creation, insertion
// and removal by using an indirect global eval // Otherwise, avoid the DOM node creation, insertion
// and removal by using an indirect global eval
indirect( code ); indirect( code );
} }
} }
@ -288,49 +298,20 @@ jQuery.extend({
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
}, },
// args is for internal usage only each: function( obj, callback ) {
each: function( obj, callback, args ) { var length, i = 0;
var value,
i = 0,
length = obj.length,
isArray = isArraylike( obj );
if ( args ) { if ( isArrayLike( obj ) ) {
if ( isArray ) { length = obj.length;
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
value = callback.apply( obj[ i ], args ); if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
break;
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.apply( obj[ i ], args );
if ( value === false ) {
break;
}
} }
} }
// A special, fast, case for the most common use of each
} else { } else {
if ( isArray ) { for ( i in obj ) {
for ( ; i < length; i++ ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
value = callback.call( obj[ i ], i, obj[ i ] ); break;
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.call( obj[ i ], i, obj[ i ] );
if ( value === false ) {
break;
}
} }
} }
} }
@ -350,7 +331,7 @@ jQuery.extend({
var ret = results || []; var ret = results || [];
if ( arr != null ) { if ( arr != null ) {
if ( isArraylike( Object(arr) ) ) { if ( isArrayLike( Object( arr ) ) ) {
jQuery.merge( ret, jQuery.merge( ret,
typeof arr === "string" ? typeof arr === "string" ?
[ arr ] : arr [ arr ] : arr
@ -402,14 +383,13 @@ jQuery.extend({
// arg is for internal usage only // arg is for internal usage only
map: function( elems, callback, arg ) { map: function( elems, callback, arg ) {
var value, var length, value,
i = 0, i = 0,
length = elems.length,
isArray = isArraylike( elems ),
ret = []; ret = [];
// Go through the array, translating each of the items to their new values // Go through the array, translating each of the items to their new values
if ( isArray ) { if ( isArrayLike( elems ) ) {
length = elems.length;
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg ); value = callback( elems[ i ], i, arg );
@ -470,33 +450,40 @@ jQuery.extend({
// jQuery.support is not used in Core but other projects attach their // jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist. // properties to it so it needs to exist.
support: support support: support
}); } );
// JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global
// unguarded in another place, it seems safer to just disable JSHint for these
// three lines.
/* jshint ignore: start */
if ( typeof Symbol === "function" ) {
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
}
/* jshint ignore: end */
// Populate the class2type map // Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
function( i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase(); class2type[ "[object " + name + "]" ] = name.toLowerCase();
}); } );
function isArraylike( obj ) { function isArrayLike( obj ) {
// Support: iOS 8.2 (not reproducible in simulator) // Support: iOS 8.2 (not reproducible in simulator)
// `in` check used to prevent JIT error (gh-2145) // `in` check used to prevent JIT error (gh-2145)
// hasOwn isn't used here due to false negatives // hasOwn isn't used here due to false negatives
// regarding Nodelist length in IE // regarding Nodelist length in IE
var length = "length" in obj && obj.length, var length = !!obj && "length" in obj && obj.length,
type = jQuery.type( obj ); type = jQuery.type( obj );
if ( type === "function" || jQuery.isWindow( obj ) ) { if ( type === "function" || jQuery.isWindow( obj ) ) {
return false; return false;
} }
if ( obj.nodeType === 1 && length ) {
return true;
}
return type === "array" || length === 0 || return type === "array" || length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj; typeof length === "number" && length > 0 && ( length - 1 ) in obj;
} }
return jQuery; return jQuery;
}); } );

View file

@ -1,10 +1,10 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
// Multifunctional method to get and set values of a collection // Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function // The value/s can optionally be executed if it's a function
var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0, var i = 0,
len = elems.length, len = elems.length,
bulk = key == null; bulk = key == null;
@ -13,7 +13,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
if ( jQuery.type( key ) === "object" ) { if ( jQuery.type( key ) === "object" ) {
chainable = true; chainable = true;
for ( i in key ) { for ( i in key ) {
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); access( elems, fn, i, key[ i ], true, emptyGet, raw );
} }
// Sets one value // Sets one value
@ -25,6 +25,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
} }
if ( bulk ) { if ( bulk ) {
// Bulk operations run against the entire set // Bulk operations run against the entire set
if ( raw ) { if ( raw ) {
fn.call( elems, value ); fn.call( elems, value );
@ -41,7 +42,11 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
if ( fn ) { if ( fn ) {
for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); fn(
elems[ i ], key, raw ?
value :
value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
} }
} }
} }
@ -52,9 +57,9 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe
// Gets // Gets
bulk ? bulk ?
fn.call( elems ) : fn.call( elems ) :
len ? fn( elems[0], key ) : emptyGet; len ? fn( elems[ 0 ], key ) : emptyGet;
}; };
return access; return access;
}); } );

View file

@ -1,9 +1,10 @@
// Initialize a jQuery object // Initialize a jQuery object
define([ define( [
"../core", "../core",
"../var/document",
"./var/rsingleTag", "./var/rsingleTag",
"../traversing/findFilter" "../traversing/findFilter"
], function( jQuery, rsingleTag ) { ], function( jQuery, document, rsingleTag ) {
// A central reference to the root jQuery(document) // A central reference to the root jQuery(document)
var rootjQuery, var rootjQuery,
@ -13,7 +14,7 @@ var rootjQuery,
// Strict HTML recognition (#11290: must start with <) // Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
init = jQuery.fn.init = function( selector, context ) { init = jQuery.fn.init = function( selector, context, root ) {
var match, elem; var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false) // HANDLE: $(""), $(null), $(undefined), $(false)
@ -21,9 +22,16 @@ var rootjQuery,
return this; return this;
} }
// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
// Handle HTML strings // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
selector.length >= 3 ) {
// Assume that strings that start and end with <> are HTML and skip the regex check // Assume that strings that start and end with <> are HTML and skip the regex check
match = [ null, selector, null ]; match = [ null, selector, null ];
@ -32,23 +40,24 @@ var rootjQuery,
} }
// Match html or make sure no context is specified for #id // Match html or make sure no context is specified for #id
if ( match && (match[1] || !context) ) { if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array) // HANDLE: $(html) -> $(array)
if ( match[1] ) { if ( match[ 1 ] ) {
context = context instanceof jQuery ? context[0] : context; context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat // Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present // Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML( jQuery.merge( this, jQuery.parseHTML(
match[1], match[ 1 ],
context && context.nodeType ? context.ownerDocument || context : document, context && context.nodeType ? context.ownerDocument || context : document,
true true
) ); ) );
// HANDLE: $(html, props) // HANDLE: $(html, props)
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) { for ( match in context ) {
// Properties of context are called as methods if possible // Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) { if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] ); this[ match ]( context[ match ] );
@ -64,14 +73,15 @@ var rootjQuery,
// HANDLE: $(#id) // HANDLE: $(#id)
} else { } else {
elem = document.getElementById( match[2] ); elem = document.getElementById( match[ 2 ] );
// Support: Blackberry 4.6 // Support: Blackberry 4.6
// gEBID returns nodes no longer in the document (#6963) // gEBID returns nodes no longer in the document (#6963)
if ( elem && elem.parentNode ) { if ( elem && elem.parentNode ) {
// Inject the element directly into the jQuery object // Inject the element directly into the jQuery object
this.length = 1; this.length = 1;
this[0] = elem; this[ 0 ] = elem;
} }
this.context = document; this.context = document;
@ -81,7 +91,7 @@ var rootjQuery,
// HANDLE: $(expr, $(...)) // HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) { } else if ( !context || context.jquery ) {
return ( context || rootjQuery ).find( selector ); return ( context || root ).find( selector );
// HANDLE: $(expr, context) // HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr) // (which is just equivalent to: $(context).find(expr)
@ -91,15 +101,16 @@ var rootjQuery,
// HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
} else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
this.context = this[0] = selector; this.context = this[ 0 ] = selector;
this.length = 1; this.length = 1;
return this; return this;
// HANDLE: $(function) // HANDLE: $(function)
// Shortcut for document ready // Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) { } else if ( jQuery.isFunction( selector ) ) {
return typeof rootjQuery.ready !== "undefined" ? return root.ready !== undefined ?
rootjQuery.ready( selector ) : root.ready( selector ) :
// Execute immediately if ready is not present // Execute immediately if ready is not present
selector( jQuery ); selector( jQuery );
} }
@ -120,4 +131,4 @@ rootjQuery = jQuery( document );
return init; return init;
}); } );

View file

@ -1,11 +1,16 @@
define([ define( [
"../core", "../core",
"../var/document",
"./var/rsingleTag", "./var/rsingleTag",
"../manipulation" // buildFragment "../manipulation/buildFragment",
], function( jQuery, rsingleTag ) {
// data: string of html // This is the only module that needs core/support
// context (optional): If specified, the fragment will be created in this context, defaults to document "./support"
], function( jQuery, document, rsingleTag, buildFragment, support ) {
// Argument "data" should be string of html
// context (optional): If specified, the fragment will be created in this context,
// defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
jQuery.parseHTML = function( data, context, keepScripts ) { jQuery.parseHTML = function( data, context, keepScripts ) {
if ( !data || typeof data !== "string" ) { if ( !data || typeof data !== "string" ) {
@ -15,17 +20,22 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
keepScripts = context; keepScripts = context;
context = false; context = false;
} }
context = context || document;
// Stop scripts or inline event handlers from being executed immediately
// by using document.implementation
context = context || ( support.createHTMLDocument ?
document.implementation.createHTMLDocument( "" ) :
document );
var parsed = rsingleTag.exec( data ), var parsed = rsingleTag.exec( data ),
scripts = !keepScripts && []; scripts = !keepScripts && [];
// Single tag // Single tag
if ( parsed ) { if ( parsed ) {
return [ context.createElement( parsed[1] ) ]; return [ context.createElement( parsed[ 1 ] ) ];
} }
parsed = jQuery.buildFragment( [ data ], context, scripts ); parsed = buildFragment( [ data ], context, scripts );
if ( scripts && scripts.length ) { if ( scripts && scripts.length ) {
jQuery( scripts ).remove(); jQuery( scripts ).remove();
@ -36,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
return jQuery.parseHTML; return jQuery.parseHTML;
}); } );

View file

@ -1,20 +1,23 @@
define([ define( [
"../core", "../core",
"../var/document",
"../core/init", "../core/init",
"../deferred" "../deferred"
], function( jQuery ) { ], function( jQuery, document ) {
// The deferred used on DOM ready // The deferred used on DOM ready
var readyList; var readyList;
jQuery.fn.ready = function( fn ) { jQuery.fn.ready = function( fn ) {
// Add the callback // Add the callback
jQuery.ready.promise().done( fn ); jQuery.ready.promise().done( fn );
return this; return this;
}; };
jQuery.extend({ jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs. // Is the DOM ready to be used? Set to true once it occurs.
isReady: false, isReady: false,
@ -56,14 +59,14 @@ jQuery.extend({
jQuery( document ).off( "ready" ); jQuery( document ).off( "ready" );
} }
} }
}); } );
/** /**
* The ready event handler and self cleanup method * The ready event handler and self cleanup method
*/ */
function completed() { function completed() {
document.removeEventListener( "DOMContentLoaded", completed, false ); document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed, false ); window.removeEventListener( "load", completed );
jQuery.ready(); jQuery.ready();
} }
@ -72,20 +75,23 @@ jQuery.ready.promise = function( obj ) {
readyList = jQuery.Deferred(); readyList = jQuery.Deferred();
// Catch cases where $(document).ready() is called after the browser event has already occurred. // Catch cases where $(document).ready() is called
// We once tried to use readyState "interactive" here, but it caused issues like the one // after the browser event has already occurred.
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 // Support: IE9-10 only
if ( document.readyState === "complete" ) { // Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready ); window.setTimeout( jQuery.ready );
} else { } else {
// Use the handy event callback // Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed, false ); document.addEventListener( "DOMContentLoaded", completed );
// A fallback to window.onload, that will always work // A fallback to window.onload, that will always work
window.addEventListener( "load", completed, false ); window.addEventListener( "load", completed );
} }
} }
return readyList.promise( obj ); return readyList.promise( obj );
@ -94,4 +100,4 @@ jQuery.ready.promise = function( obj ) {
// Kick off the DOM ready check even if the user does not // Kick off the DOM ready check even if the user does not
jQuery.ready.promise(); jQuery.ready.promise();
}); } );

View file

@ -0,0 +1,18 @@
define( [
"../var/document",
"../var/support"
], function( document, support ) {
// Support: Safari 8+
// In Safari 8 documents created via document.implementation.createHTMLDocument
// collapse sibling forms: the second one becomes a child of the first one.
// Because of that, this security measure has to be disabled in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = ( function() {
var body = document.implementation.createHTMLDocument( "" ).body;
body.innerHTML = "<form></form><form></form>";
return body.childNodes.length === 2;
} )();
return support;
} );

View file

@ -1,31 +1,34 @@
define([ define( [
"./core", "./core",
"./var/pnum", "./var/pnum",
"./core/access", "./core/access",
"./css/var/rmargin", "./css/var/rmargin",
"./var/document",
"./var/rcssNum",
"./css/var/rnumnonpx", "./css/var/rnumnonpx",
"./css/var/cssExpand", "./css/var/cssExpand",
"./css/var/isHidden", "./css/var/isHidden",
"./css/var/getStyles", "./css/var/getStyles",
"./css/var/swap",
"./css/curCSS", "./css/curCSS",
"./css/adjustCSS",
"./css/defaultDisplay", "./css/defaultDisplay",
"./css/addGetHookIf", "./css/addGetHookIf",
"./css/support", "./css/support",
"./data/var/data_priv", "./data/var/dataPriv",
"./core/init", "./core/init",
"./css/swap",
"./core/ready", "./core/ready",
"./selector" // contains "./selector" // contains
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden, ], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, isHidden,
getStyles, curCSS, defaultDisplay, addGetHookIf, support, data_priv ) { getStyles, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support, dataPriv ) {
var var
// Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// Swappable if display is none or starts with table
// except "table", "table-cell", or "table-caption"
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/, rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = { cssNormalTransform = {
@ -33,55 +36,61 @@ var
fontWeight: "400" fontWeight: "400"
}, },
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style;
// Return a css property mapped to a potentially vendor prefixed property // Return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) { function vendorPropName( name ) {
// Shortcut for names that are not vendor prefixed // Shortcut for names that are not vendor prefixed
if ( name in style ) { if ( name in emptyStyle ) {
return name; return name;
} }
// Check for vendor prefixed names // Check for vendor prefixed names
var capName = name[0].toUpperCase() + name.slice(1), var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
origName = name,
i = cssPrefixes.length; i = cssPrefixes.length;
while ( i-- ) { while ( i-- ) {
name = cssPrefixes[ i ] + capName; name = cssPrefixes[ i ] + capName;
if ( name in style ) { if ( name in emptyStyle ) {
return name; return name;
} }
} }
return origName;
} }
function setPositiveNumber( elem, value, subtract ) { function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value );
// Any relative (+/-) values have already been
// normalized at this point
var matches = rcssNum.exec( value );
return matches ? return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks // Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
value; value;
} }
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ? var i = extra === ( isBorderBox ? "border" : "content" ) ?
// If we already have the right measurement, avoid augmentation // If we already have the right measurement, avoid augmentation
4 : 4 :
// Otherwise initialize for horizontal or vertical properties // Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0, name === "width" ? 1 : 0,
val = 0; val = 0;
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// Both box models exclude margin, so add it if we want it // Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
} }
if ( isBorderBox ) { if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content // border-box includes padding, so remove it if we want content
if ( extra === "content" ) { if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
@ -92,6 +101,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
} else { } else {
// At this point, extra isn't content, so add padding // At this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
@ -113,10 +123,24 @@ function getWidthOrHeight( elem, name, extra ) {
styles = getStyles( elem ), styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// Support: IE11 only
// In IE 11 fullscreen elements inside of an iframe have
// 100x too small dimensions (gh-1764).
if ( document.msFullscreenElement && window.top !== window ) {
// Support: IE11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
}
// Some non-html elements return undefined for offsetWidth, so check for null/undefined // Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) { if ( val <= 0 || val == null ) {
// Fall back to computed then uncomputed css if necessary // Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
@ -124,7 +148,7 @@ function getWidthOrHeight( elem, name, extra ) {
} }
// Computed unit is not pixels. Stop here and return. // Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) { if ( rnumnonpx.test( val ) ) {
return val; return val;
} }
@ -161,9 +185,10 @@ function showHide( elements, show ) {
continue; continue;
} }
values[ index ] = data_priv.get( elem, "olddisplay" ); values[ index ] = dataPriv.get( elem, "olddisplay" );
display = elem.style.display; display = elem.style.display;
if ( show ) { if ( show ) {
// Reset the inline display of this element to learn if it is // Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not // being hidden by cascaded rules or not
if ( !values[ index ] && display === "none" ) { if ( !values[ index ] && display === "none" ) {
@ -174,13 +199,21 @@ function showHide( elements, show ) {
// in a stylesheet to whatever the default browser style is // in a stylesheet to whatever the default browser style is
// for such an element // for such an element
if ( elem.style.display === "" && isHidden( elem ) ) { if ( elem.style.display === "" && isHidden( elem ) ) {
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) ); values[ index ] = dataPriv.access(
elem,
"olddisplay",
defaultDisplay( elem.nodeName )
);
} }
} else { } else {
hidden = isHidden( elem ); hidden = isHidden( elem );
if ( display !== "none" || !hidden ) { if ( display !== "none" || !hidden ) {
data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); dataPriv.set(
elem,
"olddisplay",
hidden ? display : jQuery.css( elem, "display" )
);
} }
} }
} }
@ -200,7 +233,7 @@ function showHide( elements, show ) {
return elements; return elements;
} }
jQuery.extend({ jQuery.extend( {
// Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
// behavior of getting and setting a style property // behavior of getting and setting a style property
@ -219,6 +252,7 @@ jQuery.extend({
// Don't automatically add "px" to these possibly-unitless properties // Don't automatically add "px" to these possibly-unitless properties
cssNumber: { cssNumber: {
"animationIterationCount": true,
"columnCount": true, "columnCount": true,
"fillOpacity": true, "fillOpacity": true,
"flexGrow": true, "flexGrow": true,
@ -252,7 +286,8 @@ jQuery.extend({
origName = jQuery.camelCase( name ), origName = jQuery.camelCase( name ),
style = elem.style; style = elem.style;
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
// Gets hook for the prefixed version, then unprefixed version // Gets hook for the prefixed version, then unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
@ -262,8 +297,9 @@ jQuery.extend({
type = typeof value; type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345) // Convert "+=" or "-=" to relative numbers (#7345)
if ( type === "string" && (ret = rrelNum.exec( value )) ) { if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); value = adjustCSS( elem, name, ret );
// Fixes bug #9237 // Fixes bug #9237
type = "number"; type = "number";
} }
@ -273,9 +309,9 @@ jQuery.extend({
return; return;
} }
// If a number, add 'px' to the (except for certain CSS properties) // If a number was passed in, add the unit (except for certain CSS properties)
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { if ( type === "number" ) {
value += "px"; value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
} }
// Support: IE9-11+ // Support: IE9-11+
@ -285,13 +321,18 @@ jQuery.extend({
} }
// If a hook was provided, use that value, otherwise just set the specified value // If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { if ( !hooks || !( "set" in hooks ) ||
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
style[ name ] = value; style[ name ] = value;
} }
} else { } else {
// If a hook was provided get the non-computed value from there // If a hook was provided get the non-computed value from there
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { if ( hooks && "get" in hooks &&
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret; return ret;
} }
@ -305,7 +346,8 @@ jQuery.extend({
origName = jQuery.camelCase( name ); origName = jQuery.camelCase( name );
// Make sure that we're working with the right name // Make sure that we're working with the right name
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
// Try prefixed name followed by the unprefixed name // Try prefixed name followed by the unprefixed name
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
@ -328,54 +370,77 @@ jQuery.extend({
// Make numeric if forced or a qualifier was provided and val looks numeric // Make numeric if forced or a qualifier was provided and val looks numeric
if ( extra === "" || extra ) { if ( extra === "" || extra ) {
num = parseFloat( val ); num = parseFloat( val );
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; return extra === true || isFinite( num ) ? num || 0 : val;
} }
return val; return val;
} }
}); } );
jQuery.each([ "height", "width" ], function( i, name ) { jQuery.each( [ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
if ( computed ) { if ( computed ) {
// Certain elements can have dimension info if we invisibly show them // Certain elements can have dimension info if we invisibly show them
// but it must have a current display style that would benefit // but it must have a current display style that would benefit
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
jQuery.swap( elem, cssShow, function() { elem.offsetWidth === 0 ?
return getWidthOrHeight( elem, name, extra ); swap( elem, cssShow, function() {
}) : return getWidthOrHeight( elem, name, extra );
getWidthOrHeight( elem, name, extra ); } ) :
getWidthOrHeight( elem, name, extra );
} }
}, },
set: function( elem, value, extra ) { set: function( elem, value, extra ) {
var styles = extra && getStyles( elem ); var matches,
return setPositiveNumber( elem, value, extra ? styles = extra && getStyles( elem ),
augmentWidthOrHeight( subtract = extra && augmentWidthOrHeight(
elem, elem,
name, name,
extra, extra,
jQuery.css( elem, "boxSizing", false, styles ) === "border-box", jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles styles
) : 0 );
);
// Convert to pixels if value adjustment is needed
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
( matches[ 3 ] || "px" ) !== "px" ) {
elem.style[ name ] = value;
value = jQuery.css( elem, name );
}
return setPositiveNumber( elem, value, subtract );
} }
}; };
}); } );
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
function( elem, computed ) {
if ( computed ) {
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
elem.getBoundingClientRect().left -
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left;
} )
) + "px";
}
}
);
// Support: Android 2.3 // Support: Android 2.3
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
return jQuery.swap( elem, { "display": "inline-block" }, return swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] ); curCSS, [ elem, "marginRight" ] );
} }
} }
); );
// These hooks are used by animate to expand properties // These hooks are used by animate to expand properties
jQuery.each({ jQuery.each( {
margin: "", margin: "",
padding: "", padding: "",
border: "Width" border: "Width"
@ -386,7 +451,7 @@ jQuery.each({
expanded = {}, expanded = {},
// Assumes a single number if not a string // Assumes a single number if not a string
parts = typeof value === "string" ? value.split(" ") : [ value ]; parts = typeof value === "string" ? value.split( " " ) : [ value ];
for ( ; i < 4; i++ ) { for ( ; i < 4; i++ ) {
expanded[ prefix + cssExpand[ i ] + suffix ] = expanded[ prefix + cssExpand[ i ] + suffix ] =
@ -400,9 +465,9 @@ jQuery.each({
if ( !rmargin.test( prefix ) ) { if ( !rmargin.test( prefix ) ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
css: function( name, value ) { css: function( name, value ) {
return access( this, function( elem, name, value ) { return access( this, function( elem, name, value ) {
var styles, len, var styles, len,
@ -436,15 +501,15 @@ jQuery.fn.extend({
return state ? this.show() : this.hide(); return state ? this.show() : this.hide();
} }
return this.each(function() { return this.each( function() {
if ( isHidden( this ) ) { if ( isHidden( this ) ) {
jQuery( this ).show(); jQuery( this ).show();
} else { } else {
jQuery( this ).hide(); jQuery( this ).hide();
} }
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );

View file

@ -1,10 +1,12 @@
define(function() { define( function() {
function addGetHookIf( conditionFn, hookFn ) { function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed. // Define the hook, we'll check on the first run if it's really needed.
return { return {
get: function() { get: function() {
if ( conditionFn() ) { if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due // Hook not needed (or it's not possible to use it due
// to missing dependency), remove it. // to missing dependency), remove it.
delete this.get; delete this.get;
@ -12,11 +14,11 @@ function addGetHookIf( conditionFn, hookFn ) {
} }
// Hook needed; redefine it so that the support test is not executed again. // Hook needed; redefine it so that the support test is not executed again.
return (this.get = hookFn).apply( this, arguments ); return ( this.get = hookFn ).apply( this, arguments );
} }
}; };
} }
return addGetHookIf; return addGetHookIf;
}); } );

View file

@ -0,0 +1,65 @@
define( [
"../core",
"../var/rcssNum"
], function( jQuery, rcssNum ) {
function adjustCSS( elem, prop, valueParts, tween ) {
var adjusted,
scale = 1,
maxIterations = 20,
currentValue = tween ?
function() { return tween.cur(); } :
function() { return jQuery.css( elem, prop, "" ); },
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
// Make sure we update the tween properties later on
valueParts = valueParts || [];
// Iteratively approximate from a nonzero starting point
initialInUnit = +initial || 1;
do {
// If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5";
// Adjust and apply
initialInUnit = initialInUnit / scale;
jQuery.style( elem, prop, initialInUnit + unit );
// Update scale, tolerating zero or NaN from tween.cur()
// Break the loop if scale is unchanged or perfect, or if we've just had enough.
} while (
scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
);
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+valueParts[ 2 ];
if ( tween ) {
tween.unit = unit;
tween.start = initialInUnit;
tween.end = adjusted;
}
}
return adjusted;
}
return adjustCSS;
} );

View file

@ -1,10 +1,11 @@
define([ define( [
"../core", "../core",
"./var/rnumnonpx", "./var/rnumnonpx",
"./var/rmargin", "./var/rmargin",
"./var/getStyles", "./var/getStyles",
"../selector" // contains "./support",
], function( jQuery, rnumnonpx, rmargin, getStyles ) { "../selector" // Get jQuery.contains
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) {
function curCSS( elem, name, computed ) { function curCSS( elem, name, computed ) {
var width, minWidth, maxWidth, ret, var width, minWidth, maxWidth, ret,
@ -16,19 +17,17 @@ function curCSS( elem, name, computed ) {
// getPropertyValue is only needed for .css('filter') (#12537) // getPropertyValue is only needed for .css('filter') (#12537)
if ( computed ) { if ( computed ) {
ret = computed.getPropertyValue( name ) || computed[ name ]; ret = computed.getPropertyValue( name ) || computed[ name ];
}
if ( computed ) {
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
ret = jQuery.style( elem, name ); ret = jQuery.style( elem, name );
} }
// Support: iOS < 6
// A tribute to the "awesome hack by Dean Edwards" // A tribute to the "awesome hack by Dean Edwards"
// iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels // Android Browser returns percentage for some values,
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values // but width seems to be reliably pixels.
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { // This is against the CSSOM draft spec:
// http://dev.w3.org/csswg/cssom/#resolved-values
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
// Remember the original values // Remember the original values
width = style.width; width = style.width;
@ -47,11 +46,12 @@ function curCSS( elem, name, computed ) {
} }
return ret !== undefined ? return ret !== undefined ?
// Support: IE
// Support: IE9-11+
// IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
ret + "" : ret + "" :
ret; ret;
} }
return curCSS; return curCSS;
}); } );

View file

@ -1,27 +1,29 @@
define([ define( [
"../core", "../core",
"../var/document",
"../manipulation" // appendTo "../manipulation" // appendTo
], function( jQuery ) { ], function( jQuery, document ) {
var iframe, var iframe,
elemdisplay = {}; elemdisplay = {
// Support: Firefox
// We have to pre-define these values for FF (#10227)
HTML: "block",
BODY: "block"
};
/** /**
* Retrieve the actual display of a element * Retrieve the actual display of a element
* @param {String} name nodeName of the element * @param {String} name nodeName of the element
* @param {Object} doc Document object * @param {Object} doc Document object
*/ */
// Called only from within defaultDisplay // Called only from within defaultDisplay
function actualDisplay( name, doc ) { function actualDisplay( name, doc ) {
var style, var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
// getDefaultComputedStyle might be reliably used only on attached element display = jQuery.css( elem[ 0 ], "display" );
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
// Use of this method is a temporary fix (more like optimization) until something better comes along,
// since it was removed from specification and supported only in FF
style.display : jQuery.css( elem[ 0 ], "display" );
// We don't have any data stored on the element, // We don't have any data stored on the element,
// so use "detach" method as fast way to get rid of the element // so use "detach" method as fast way to get rid of the element
@ -45,7 +47,8 @@ function defaultDisplay( nodeName ) {
if ( display === "none" || !display ) { if ( display === "none" || !display ) {
// Use the already-created iframe if possible // Use the already-created iframe if possible
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement ); iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
.appendTo( doc.documentElement );
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
doc = iframe[ 0 ].contentDocument; doc = iframe[ 0 ].contentDocument;
@ -66,5 +69,4 @@ function defaultDisplay( nodeName ) {
} }
return defaultDisplay; return defaultDisplay;
} );
});

View file

@ -1,15 +1,18 @@
define([ define( [
"../core", "../core",
"../selector" "../selector"
], function( jQuery ) { ], function( jQuery ) {
jQuery.expr.filters.hidden = function( elem ) { jQuery.expr.filters.hidden = function( elem ) {
// Support: Opera <= 12.12 return !jQuery.expr.filters.visible( elem );
// Opera reports offsetWidths and offsetHeights less than zero on some elements
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
}; };
jQuery.expr.filters.visible = function( elem ) { jQuery.expr.filters.visible = function( elem ) {
return !jQuery.expr.filters.hidden( elem );
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements
// Use OR instead of AND as the element is not visible if either is true
// See tickets #10406 and #13132
return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0;
}; };
}); } );

View file

@ -0,0 +1,48 @@
define( [
"../data/var/dataPriv"
], function( dataPriv ) {
function showHide( elements, show ) {
var display, elem,
values = [],
index = 0,
length = elements.length;
// Determine new display value for elements that need to change
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
display = elem.style.display;
if ( show ) {
if ( display === "none" ) {
// Restore a pre-hide() value if we have one
values[ index ] = dataPriv.get( elem, "display" ) || "";
}
} else {
if ( display !== "none" ) {
values[ index ] = "none";
// Remember the value we're replacing
dataPriv.set( elem, "display", display );
}
}
}
// Set the display of the elements in a second loop
// to avoid the constant reflow
for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ];
}
}
return elements;
}
return showHide;
} );

View file

@ -1,14 +1,16 @@
define([ define( [
"../core", "../core",
"../var/document",
"../var/documentElement",
"../var/support" "../var/support"
], function( jQuery, support ) { ], function( jQuery, document, documentElement, support ) {
(function() { ( function() {
var pixelPositionVal, boxSizingReliableVal, var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
docElem = document.documentElement,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
// Finish early in limited (non-browser) environments
if ( !div.style ) { if ( !div.style ) {
return; return;
} }
@ -19,78 +21,101 @@ define([
div.cloneNode( true ).style.backgroundClip = ""; div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box"; support.clearCloneStyle = div.style.backgroundClip === "content-box";
container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" + container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
"position:absolute"; "padding:0;margin-top:1px;position:absolute";
container.appendChild( div ); container.appendChild( div );
// Executing both pixelPosition & boxSizingReliable tests require only one layout // Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation. // so they're executed at the same time to save the second computation.
function computePixelPositionAndBoxSizingReliable() { function computeStyleTests() {
div.style.cssText = div.style.cssText =
// Support: Firefox<29, Android 2.3 // Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing // Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" + "position:relative;display:block;" +
"border:1px;padding:1px;width:4px;position:absolute"; "margin:auto;border:1px;padding:1px;" +
"top:1%;width:50%";
div.innerHTML = ""; div.innerHTML = "";
docElem.appendChild( container ); documentElement.appendChild( container );
var divStyle = window.getComputedStyle( div, null ); var divStyle = window.getComputedStyle( div );
pixelPositionVal = divStyle.top !== "1%"; pixelPositionVal = divStyle.top !== "1%";
reliableMarginLeftVal = divStyle.marginLeft === "2px";
boxSizingReliableVal = divStyle.width === "4px"; boxSizingReliableVal = divStyle.width === "4px";
docElem.removeChild( container ); // Support: Android 4.0 - 4.3 only
// Some styles come back with percentage values, even though they shouldn't
div.style.marginRight = "50%";
pixelMarginRightVal = divStyle.marginRight === "4px";
documentElement.removeChild( container );
} }
// Support: node.js jsdom jQuery.extend( support, {
// Don't assume that getComputedStyle is a property of the global object pixelPosition: function() {
if ( window.getComputedStyle ) {
jQuery.extend( support, {
pixelPosition: function() {
// This test is executed only once but we still do memoizing // This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing. // since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though. // No need to check if the test was already performed, though.
computePixelPositionAndBoxSizingReliable(); computeStyleTests();
return pixelPositionVal; return pixelPositionVal;
}, },
boxSizingReliable: function() { boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) { if ( boxSizingReliableVal == null ) {
computePixelPositionAndBoxSizingReliable(); computeStyleTests();
} }
return boxSizingReliableVal; return boxSizingReliableVal;
}, },
reliableMarginRight: function() { pixelMarginRight: function() {
// Support: Android 4.0-4.3
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
// since that compresses better and they're computed together anyway.
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return pixelMarginRightVal;
},
reliableMarginLeft: function() {
// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return reliableMarginLeftVal;
},
reliableMarginRight: function() {
// Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// This support function is only executed once so no memoizing is needed.
var ret,
marginDiv = div.appendChild( document.createElement( "div" ) );
// Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText =
// Support: Android 2.3 // Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly // Vendor-prefix box-sizing
// gets computed margin-right based on width of container. (#3333) "-webkit-box-sizing:content-box;box-sizing:content-box;" +
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right "display:block;margin:0;border:0;padding:0";
// This support function is only executed once so no memoizing is needed. marginDiv.style.marginRight = marginDiv.style.width = "0";
var ret, div.style.width = "1px";
marginDiv = div.appendChild( document.createElement( "div" ) ); documentElement.appendChild( container );
// Reset CSS: box-sizing; display; margin; border; padding ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );
marginDiv.style.cssText = div.style.cssText =
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
docElem.appendChild( container );
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); documentElement.removeChild( container );
div.removeChild( marginDiv );
docElem.removeChild( container ); return ret;
div.removeChild( marginDiv ); }
} );
return ret; } )();
}
});
}
})();
return support; return support;
}); } );

View file

@ -1,28 +0,0 @@
define([
"../core"
], function( jQuery ) {
// A method for quickly swapping in/out CSS properties to get correct calculations.
jQuery.swap = function( elem, options, callback, args ) {
var ret, name,
old = {};
// Remember the old values, and insert the new ones
for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
ret = callback.apply( elem, args || [] );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
return ret;
};
return jQuery.swap;
});

View file

@ -1,10 +1,9 @@
define([ define( [
"./core", "./core",
"./var/rnotwhite",
"./core/access", "./core/access",
"./data/var/data_priv", "./data/var/dataPriv",
"./data/var/data_user" "./data/var/dataUser"
], function( jQuery, rnotwhite, access, data_priv, data_user ) { ], function( jQuery, access, dataPriv, dataUser ) {
// Implementation Summary // Implementation Summary
// //
@ -17,7 +16,7 @@ define([
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g; rmultiDash = /[A-Z]/g;
function dataAttr( elem, key, data ) { function dataAttr( elem, key, data ) {
var name; var name;
@ -25,7 +24,7 @@ function dataAttr( elem, key, data ) {
// If nothing was found internally, try to fetch any // If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute // data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) { if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
data = elem.getAttribute( name ); data = elem.getAttribute( name );
if ( typeof data === "string" ) { if ( typeof data === "string" ) {
@ -33,14 +32,15 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true : data = data === "true" ? true :
data === "false" ? false : data === "false" ? false :
data === "null" ? null : data === "null" ? null :
// Only convert to a number if it doesn't change the string // Only convert to a number if it doesn't change the string
+data + "" === data ? +data : +data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) : rbrace.test( data ) ? jQuery.parseJSON( data ) :
data; data;
} catch( e ) {} } catch ( e ) {}
// Make sure we set the data so it isn't changed later // Make sure we set the data so it isn't changed later
data_user.set( elem, key, data ); dataUser.set( elem, key, data );
} else { } else {
data = undefined; data = undefined;
} }
@ -48,31 +48,31 @@ function dataAttr( elem, key, data ) {
return data; return data;
} }
jQuery.extend({ jQuery.extend( {
hasData: function( elem ) { hasData: function( elem ) {
return data_user.hasData( elem ) || data_priv.hasData( elem ); return dataUser.hasData( elem ) || dataPriv.hasData( elem );
}, },
data: function( elem, name, data ) { data: function( elem, name, data ) {
return data_user.access( elem, name, data ); return dataUser.access( elem, name, data );
}, },
removeData: function( elem, name ) { removeData: function( elem, name ) {
data_user.remove( elem, name ); dataUser.remove( elem, name );
}, },
// TODO: Now that all calls to _data and _removeData have been replaced // TODO: Now that all calls to _data and _removeData have been replaced
// with direct calls to data_priv methods, these can be deprecated. // with direct calls to dataPriv methods, these can be deprecated.
_data: function( elem, name, data ) { _data: function( elem, name, data ) {
return data_priv.access( elem, name, data ); return dataPriv.access( elem, name, data );
}, },
_removeData: function( elem, name ) { _removeData: function( elem, name ) {
data_priv.remove( elem, name ); dataPriv.remove( elem, name );
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
data: function( key, value ) { data: function( key, value ) {
var i, name, data, var i, name, data,
elem = this[ 0 ], elem = this[ 0 ],
@ -81,9 +81,9 @@ jQuery.fn.extend({
// Gets all values // Gets all values
if ( key === undefined ) { if ( key === undefined ) {
if ( this.length ) { if ( this.length ) {
data = data_user.get( elem ); data = dataUser.get( elem );
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
i = attrs.length; i = attrs.length;
while ( i-- ) { while ( i-- ) {
@ -92,12 +92,12 @@ jQuery.fn.extend({
if ( attrs[ i ] ) { if ( attrs[ i ] ) {
name = attrs[ i ].name; name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) { if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.slice(5) ); name = jQuery.camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] ); dataAttr( elem, name, data[ name ] );
} }
} }
} }
data_priv.set( elem, "hasDataAttrs", true ); dataPriv.set( elem, "hasDataAttrs", true );
} }
} }
@ -106,14 +106,13 @@ jQuery.fn.extend({
// Sets multiple values // Sets multiple values
if ( typeof key === "object" ) { if ( typeof key === "object" ) {
return this.each(function() { return this.each( function() {
data_user.set( this, key ); dataUser.set( this, key );
}); } );
} }
return access( this, function( value ) { return access( this, function( value ) {
var data, var data, camelKey;
camelKey = jQuery.camelCase( key );
// The calling jQuery object (element matches) is not empty // The calling jQuery object (element matches) is not empty
// (and therefore has an element appears at this[ 0 ]) and the // (and therefore has an element appears at this[ 0 ]) and the
@ -121,16 +120,24 @@ jQuery.fn.extend({
// will result in `undefined` for elem = this[ 0 ] which will // will result in `undefined` for elem = this[ 0 ] which will
// throw an exception if an attempt to read a data cache is made. // throw an exception if an attempt to read a data cache is made.
if ( elem && value === undefined ) { if ( elem && value === undefined ) {
// Attempt to get data from the cache // Attempt to get data from the cache
// with the key as-is // with the key as-is
data = data_user.get( elem, key ); data = dataUser.get( elem, key ) ||
// Try to find dashed key if it exists (gh-2779)
// This is for 2.2.x only
dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
camelKey = jQuery.camelCase( key );
// Attempt to get data from the cache // Attempt to get data from the cache
// with the key camelized // with the key camelized
data = data_user.get( elem, camelKey ); data = dataUser.get( elem, camelKey );
if ( data !== undefined ) { if ( data !== undefined ) {
return data; return data;
} }
@ -147,32 +154,34 @@ jQuery.fn.extend({
} }
// Set the data... // Set the data...
this.each(function() { camelKey = jQuery.camelCase( key );
this.each( function() {
// First, attempt to store a copy or reference of any // First, attempt to store a copy or reference of any
// data that might've been store with a camelCased key. // data that might've been store with a camelCased key.
var data = data_user.get( this, camelKey ); var data = dataUser.get( this, camelKey );
// For HTML5 data-* attribute interop, we have to // For HTML5 data-* attribute interop, we have to
// store property names with dashes in a camelCase form. // store property names with dashes in a camelCase form.
// This might not apply to all properties...* // This might not apply to all properties...*
data_user.set( this, camelKey, value ); dataUser.set( this, camelKey, value );
// *... In the case of properties that might _actually_ // *... In the case of properties that might _actually_
// have dashes, we need to also store a copy of that // have dashes, we need to also store a copy of that
// unchanged property. // unchanged property.
if ( key.indexOf("-") !== -1 && data !== undefined ) { if ( key.indexOf( "-" ) > -1 && data !== undefined ) {
data_user.set( this, key, value ); dataUser.set( this, key, value );
} }
}); } );
}, null, value, arguments.length > 1, null, true ); }, null, value, arguments.length > 1, null, true );
}, },
removeData: function( key ) { removeData: function( key ) {
return this.each(function() { return this.each( function() {
data_user.remove( this, key ); dataUser.remove( this, key );
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );

View file

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

View file

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

View file

@ -1,17 +1,18 @@
define([ define( [
"./core", "./core",
"./var/slice", "./var/slice",
"./callbacks" "./callbacks"
], function( jQuery, slice ) { ], function( jQuery, slice ) {
jQuery.extend({ jQuery.extend( {
Deferred: function( func ) { Deferred: function( func ) {
var tuples = [ var tuples = [
// action, add listener, listener list, final state // action, add listener, listener list, final state
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
[ "notify", "progress", jQuery.Callbacks("memory") ] [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
], ],
state = "pending", state = "pending",
promise = { promise = {
@ -24,25 +25,30 @@ jQuery.extend({
}, },
then: function( /* fnDone, fnFail, fnProgress */ ) { then: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments; var fns = arguments;
return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// deferred[ done | fail | progress ] for forwarding actions to newDefer // deferred[ done | fail | progress ] for forwarding actions to newDefer
deferred[ tuple[1] ](function() { deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments ); var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) { if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise() returned.promise()
.progress( newDefer.notify )
.done( newDefer.resolve ) .done( newDefer.resolve )
.fail( newDefer.reject ) .fail( newDefer.reject );
.progress( newDefer.notify );
} else { } else {
newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); newDefer[ tuple[ 0 ] + "With" ](
this === promise ? newDefer.promise() : this,
fn ? [ returned ] : arguments
);
} }
}); } );
}); } );
fns = null; fns = null;
}).promise(); } ).promise();
}, },
// Get a promise for this deferred // Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object // If obj is provided, the promise aspect is added to the object
promise: function( obj ) { promise: function( obj ) {
@ -60,11 +66,12 @@ jQuery.extend({
stateString = tuple[ 3 ]; stateString = tuple[ 3 ];
// promise[ done | fail | progress ] = list.add // promise[ done | fail | progress ] = list.add
promise[ tuple[1] ] = list.add; promise[ tuple[ 1 ] ] = list.add;
// Handle state // Handle state
if ( stateString ) { if ( stateString ) {
list.add(function() { list.add( function() {
// state = [ resolved | rejected ] // state = [ resolved | rejected ]
state = stateString; state = stateString;
@ -73,12 +80,12 @@ jQuery.extend({
} }
// deferred[ resolve | reject | notify ] // deferred[ resolve | reject | notify ]
deferred[ tuple[0] ] = function() { deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
return this; return this;
}; };
deferred[ tuple[0] + "With" ] = list.fireWith; deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
}); } );
// Make the deferred a promise // Make the deferred a promise
promise.promise( deferred ); promise.promise( deferred );
@ -99,9 +106,11 @@ jQuery.extend({
length = resolveValues.length, length = resolveValues.length,
// the count of uncompleted subordinates // the count of uncompleted subordinates
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, remaining = length !== 1 ||
( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. // the master Deferred.
// If resolveValues consist of only a single Deferred, just use that.
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
// Update function for both resolve and progress values // Update function for both resolve and progress values
@ -127,9 +136,9 @@ jQuery.extend({
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
resolveValues[ i ].promise() resolveValues[ i ].promise()
.progress( updateFunc( i, progressContexts, progressValues ) )
.done( updateFunc( i, resolveContexts, resolveValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( deferred.reject ) .fail( deferred.reject );
.progress( updateFunc( i, progressContexts, progressValues ) );
} else { } else {
--remaining; --remaining;
} }
@ -143,7 +152,7 @@ jQuery.extend({
return deferred.promise(); return deferred.promise();
} }
}); } );
return jQuery; return jQuery;
}); } );

View file

@ -1,13 +1,32 @@
define([ define( [
"./core", "./core"
"./traversing"
], function( jQuery ) { ], function( jQuery ) {
// The number of elements contained in the matched element set jQuery.fn.extend( {
jQuery.fn.size = function() {
return this.length; bind: function( types, data, fn ) {
}; return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
},
size: function() {
return this.length;
}
} );
jQuery.fn.andSelf = jQuery.fn.addBack; jQuery.fn.andSelf = jQuery.fn.addBack;
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./css" "./css"
@ -6,7 +6,9 @@ define([
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) {
// Margin is only for outerHeight, outerWidth // Margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) { jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
@ -16,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
var doc; var doc;
if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
// isn't a whole lot we can do. See pull request at this URL for discussion: // isn't a whole lot we can do. See pull request at this URL for discussion:
// https://github.com/jquery/jquery/pull/764 // https://github.com/jquery/jquery/pull/764
@ -36,6 +39,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
} }
return value === undefined ? return value === undefined ?
// Get width or height on the element, requesting but not forcing parseFloat // Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) : jQuery.css( elem, type, extra ) :
@ -43,8 +47,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable, null ); }, type, chainable ? margin : undefined, chainable, null );
}; };
}); } );
}); } );
return jQuery; return jQuery;
}); } );

View file

@ -1,10 +1,13 @@
define([ define( [
"./core", "./core",
"./var/pnum", "./var/document",
"./var/rcssNum",
"./css/var/cssExpand", "./css/var/cssExpand",
"./var/rnotwhite",
"./css/var/isHidden", "./css/var/isHidden",
"./css/adjustCSS",
"./css/defaultDisplay", "./css/defaultDisplay",
"./data/var/data_priv", "./data/var/dataPriv",
"./core/init", "./core/init",
"./effects/Tween", "./effects/Tween",
@ -12,70 +15,19 @@ define([
"./css", "./css",
"./deferred", "./deferred",
"./traversing" "./traversing"
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) { ], function( jQuery, document, rcssNum, cssExpand, rnotwhite,
isHidden, adjustCSS, defaultDisplay, dataPriv ) {
var var
fxNow, timerId, fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), rrun = /queueHooks$/;
rrun = /queueHooks$/,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [ function( prop, value ) {
var tween = this.createTween( prop, value ),
target = tween.cur(),
parts = rfxnum.exec( value ),
unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
rfxnum.exec( jQuery.css( tween.elem, prop ) ),
scale = 1,
maxIterations = 20;
if ( start && start[ 3 ] !== unit ) {
// Trust units reported by jQuery.css
unit = unit || start[ 3 ];
// Make sure we update the tween properties later on
parts = parts || [];
// Iteratively approximate from a nonzero starting point
start = +target || 1;
do {
// If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5";
// Adjust and apply
start = start / scale;
jQuery.style( tween.elem, prop, start + unit );
// Update scale, tolerating zero or NaN from tween.cur(),
// break the loop if scale is unchanged or perfect, or if we've just had enough
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
}
// Update tween properties
if ( parts ) {
start = tween.start = +start || +target || 0;
tween.unit = unit;
// If a +=/-= token was provided, we're doing a relative animation
tween.end = parts[ 1 ] ?
start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
+parts[ 2 ];
}
return tween;
} ]
};
// Animations created synchronously will run synchronously // Animations created synchronously will run synchronously
function createFxNow() { function createFxNow() {
setTimeout(function() { window.setTimeout( function() {
fxNow = undefined; fxNow = undefined;
}); } );
return ( fxNow = jQuery.now() ); return ( fxNow = jQuery.now() );
} }
@ -102,11 +54,11 @@ function genFx( type, includeWidth ) {
function createTween( value, prop, animation ) { function createTween( value, prop, animation ) {
var tween, var tween,
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
index = 0, index = 0,
length = collection.length; length = collection.length;
for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
if ( (tween = collection[ index ].call( animation, prop, value )) ) { if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// We're done with this property // We're done with this property
return tween; return tween;
@ -121,7 +73,7 @@ function defaultPrefilter( elem, props, opts ) {
orig = {}, orig = {},
style = elem.style, style = elem.style,
hidden = elem.nodeType && isHidden( elem ), hidden = elem.nodeType && isHidden( elem ),
dataShow = data_priv.get( elem, "fxshow" ); dataShow = dataPriv.get( elem, "fxshow" );
// Handle queue: false promises // Handle queue: false promises
if ( !opts.queue ) { if ( !opts.queue ) {
@ -137,19 +89,21 @@ function defaultPrefilter( elem, props, opts ) {
} }
hooks.unqueued++; hooks.unqueued++;
anim.always(function() { anim.always( function() {
// Ensure the complete handler is called before this completes // Ensure the complete handler is called before this completes
anim.always(function() { anim.always( function() {
hooks.unqueued--; hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire(); hooks.empty.fire();
} }
}); } );
}); } );
} }
// Height/width overflow pass // Height/width overflow pass
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out // Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE9-10 do not // Record all 3 overflow attributes because IE9-10 do not
// change the overflow attribute when overflowX and // change the overflow attribute when overflowX and
@ -162,7 +116,7 @@ function defaultPrefilter( elem, props, opts ) {
// Test default display if display is currently "none" // Test default display if display is currently "none"
checkDisplay = display === "none" ? checkDisplay = display === "none" ?
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
style.display = "inline-block"; style.display = "inline-block";
@ -171,11 +125,11 @@ function defaultPrefilter( elem, props, opts ) {
if ( opts.overflow ) { if ( opts.overflow ) {
style.overflow = "hidden"; style.overflow = "hidden";
anim.always(function() { anim.always( function() {
style.overflow = opts.overflow[ 0 ]; style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ]; style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ]; style.overflowY = opts.overflow[ 2 ];
}); } );
} }
// show/hide pass // show/hide pass
@ -186,7 +140,8 @@ function defaultPrefilter( elem, props, opts ) {
toggle = toggle || value === "toggle"; toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) { if ( value === ( hidden ? "hide" : "show" ) ) {
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden // If there is dataShow left over from a stopped hide or show
// and we are going to proceed with show, we should pretend to be hidden
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true; hidden = true;
} else { } else {
@ -207,7 +162,7 @@ function defaultPrefilter( elem, props, opts ) {
hidden = dataShow.hidden; hidden = dataShow.hidden;
} }
} else { } else {
dataShow = data_priv.access( elem, "fxshow", {} ); dataShow = dataPriv.access( elem, "fxshow", {} );
} }
// Store state if its toggle - enables .stop().toggle() to "reverse" // Store state if its toggle - enables .stop().toggle() to "reverse"
@ -217,18 +172,18 @@ function defaultPrefilter( elem, props, opts ) {
if ( hidden ) { if ( hidden ) {
jQuery( elem ).show(); jQuery( elem ).show();
} else { } else {
anim.done(function() { anim.done( function() {
jQuery( elem ).hide(); jQuery( elem ).hide();
}); } );
} }
anim.done(function() { anim.done( function() {
var prop; var prop;
data_priv.remove( elem, "fxshow" ); dataPriv.remove( elem, "fxshow" );
for ( prop in orig ) { for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] ); jQuery.style( elem, prop, orig[ prop ] );
} }
}); } );
for ( prop in orig ) { for ( prop in orig ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
@ -242,7 +197,7 @@ function defaultPrefilter( elem, props, opts ) {
} }
// If this is a noop like .hide().hide(), restore an overwritten display value // If this is a noop like .hide().hide(), restore an overwritten display value
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
style.display = display; style.display = display;
} }
} }
@ -288,17 +243,19 @@ function Animation( elem, properties, options ) {
var result, var result,
stopped, stopped,
index = 0, index = 0,
length = animationPrefilters.length, length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() { deferred = jQuery.Deferred().always( function() {
// Don't match elem in the :animated selector // Don't match elem in the :animated selector
delete tick.elem; delete tick.elem;
}), } ),
tick = function() { tick = function() {
if ( stopped ) { if ( stopped ) {
return false; return false;
} }
var currentTime = fxNow || createFxNow(), var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 // Support: Android 2.3
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
@ -310,7 +267,7 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
} }
deferred.notifyWith( elem, [ animation, percent, remaining ]); deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) { if ( percent < 1 && length ) {
return remaining; return remaining;
@ -319,10 +276,13 @@ function Animation( elem, properties, options ) {
return false; return false;
} }
}, },
animation = deferred.promise({ animation = deferred.promise( {
elem: elem, elem: elem,
props: jQuery.extend( {}, properties ), props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, { specialEasing: {} }, options ), opts: jQuery.extend( true, {
specialEasing: {},
easing: jQuery.easing._default
}, options ),
originalProperties: properties, originalProperties: properties,
originalOptions: options, originalOptions: options,
startTime: fxNow || createFxNow(), startTime: fxNow || createFxNow(),
@ -336,6 +296,7 @@ function Animation( elem, properties, options ) {
}, },
stop: function( gotoEnd ) { stop: function( gotoEnd ) {
var index = 0, var index = 0,
// If we are going to the end, we want to run all the tweens // If we are going to the end, we want to run all the tweens
// otherwise we skip this part // otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0; length = gotoEnd ? animation.tweens.length : 0;
@ -349,20 +310,25 @@ function Animation( elem, properties, options ) {
// Resolve when we played the last frame; otherwise, reject // Resolve when we played the last frame; otherwise, reject
if ( gotoEnd ) { if ( gotoEnd ) {
deferred.notifyWith( elem, [ animation, 1, 0 ] );
deferred.resolveWith( elem, [ animation, gotoEnd ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else { } else {
deferred.rejectWith( elem, [ animation, gotoEnd ] ); deferred.rejectWith( elem, [ animation, gotoEnd ] );
} }
return this; return this;
} }
}), } ),
props = animation.props; props = animation.props;
propFilter( props, animation.opts.specialEasing ); propFilter( props, animation.opts.specialEasing );
for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
if ( result ) { if ( result ) {
if ( jQuery.isFunction( result.stop ) ) {
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
jQuery.proxy( result.stop, result );
}
return result; return result;
} }
} }
@ -378,7 +344,7 @@ function Animation( elem, properties, options ) {
elem: elem, elem: elem,
anim: animation, anim: animation,
queue: animation.opts.queue queue: animation.opts.queue
}) } )
); );
// attach callbacks from options // attach callbacks from options
@ -389,13 +355,20 @@ function Animation( elem, properties, options ) {
} }
jQuery.Animation = jQuery.extend( Animation, { jQuery.Animation = jQuery.extend( Animation, {
tweeners: {
"*": [ function( prop, value ) {
var tween = this.createTween( prop, value );
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
return tween;
} ]
},
tweener: function( props, callback ) { tweener: function( props, callback ) {
if ( jQuery.isFunction( props ) ) { if ( jQuery.isFunction( props ) ) {
callback = props; callback = props;
props = [ "*" ]; props = [ "*" ];
} else { } else {
props = props.split(" "); props = props.match( rnotwhite );
} }
var prop, var prop,
@ -404,19 +377,21 @@ jQuery.Animation = jQuery.extend( Animation, {
for ( ; index < length ; index++ ) { for ( ; index < length ; index++ ) {
prop = props[ index ]; prop = props[ index ];
tweeners[ prop ] = tweeners[ prop ] || []; Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
tweeners[ prop ].unshift( callback ); Animation.tweeners[ prop ].unshift( callback );
} }
}, },
prefilters: [ defaultPrefilter ],
prefilter: function( callback, prepend ) { prefilter: function( callback, prepend ) {
if ( prepend ) { if ( prepend ) {
animationPrefilters.unshift( callback ); Animation.prefilters.unshift( callback );
} else { } else {
animationPrefilters.push( callback ); Animation.prefilters.push( callback );
} }
} }
}); } );
jQuery.speed = function( speed, easing, fn ) { jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
@ -426,8 +401,9 @@ jQuery.speed = function( speed, easing, fn ) {
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
}; };
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ?
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; opt.duration : opt.duration in jQuery.fx.speeds ?
jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
// Normalize opt.queue - true/undefined/null -> "fx" // Normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) { if ( opt.queue == null || opt.queue === true ) {
@ -450,24 +426,25 @@ jQuery.speed = function( speed, easing, fn ) {
return opt; return opt;
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
fadeTo: function( speed, to, easing, callback ) { fadeTo: function( speed, to, easing, callback ) {
// Show any hidden elements after setting opacity to 0 // Show any hidden elements after setting opacity to 0
return this.filter( isHidden ).css( "opacity", 0 ).show() return this.filter( isHidden ).css( "opacity", 0 ).show()
// Animate to the value specified // Animate to the value specified
.end().animate({ opacity: to }, speed, easing, callback ); .end().animate( { opacity: to }, speed, easing, callback );
}, },
animate: function( prop, speed, easing, callback ) { animate: function( prop, speed, easing, callback ) {
var empty = jQuery.isEmptyObject( prop ), var empty = jQuery.isEmptyObject( prop ),
optall = jQuery.speed( speed, easing, callback ), optall = jQuery.speed( speed, easing, callback ),
doAnimation = function() { doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost // Operate on a copy of prop so per-property easing won't be lost
var anim = Animation( this, jQuery.extend( {}, prop ), optall ); var anim = Animation( this, jQuery.extend( {}, prop ), optall );
// Empty animations, or finishing resolves immediately // Empty animations, or finishing resolves immediately
if ( empty || data_priv.get( this, "finish" ) ) { if ( empty || dataPriv.get( this, "finish" ) ) {
anim.stop( true ); anim.stop( true );
} }
}; };
@ -493,11 +470,11 @@ jQuery.fn.extend({
this.queue( type || "fx", [] ); this.queue( type || "fx", [] );
} }
return this.each(function() { return this.each( function() {
var dequeue = true, var dequeue = true,
index = type != null && type + "queueHooks", index = type != null && type + "queueHooks",
timers = jQuery.timers, timers = jQuery.timers,
data = data_priv.get( this ); data = dataPriv.get( this );
if ( index ) { if ( index ) {
if ( data[ index ] && data[ index ].stop ) { if ( data[ index ] && data[ index ].stop ) {
@ -512,7 +489,9 @@ jQuery.fn.extend({
} }
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { if ( timers[ index ].elem === this &&
( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd ); timers[ index ].anim.stop( gotoEnd );
dequeue = false; dequeue = false;
timers.splice( index, 1 ); timers.splice( index, 1 );
@ -525,15 +504,15 @@ jQuery.fn.extend({
if ( dequeue || !gotoEnd ) { if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
} }
}); } );
}, },
finish: function( type ) { finish: function( type ) {
if ( type !== false ) { if ( type !== false ) {
type = type || "fx"; type = type || "fx";
} }
return this.each(function() { return this.each( function() {
var index, var index,
data = data_priv.get( this ), data = dataPriv.get( this ),
queue = data[ type + "queue" ], queue = data[ type + "queue" ],
hooks = data[ type + "queueHooks" ], hooks = data[ type + "queueHooks" ],
timers = jQuery.timers, timers = jQuery.timers,
@ -566,24 +545,24 @@ jQuery.fn.extend({
// Turn off finishing flag // Turn off finishing flag
delete data.finish; delete data.finish;
}); } );
} }
}); } );
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ]; var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
return speed == null || typeof speed === "boolean" ? return speed == null || typeof speed === "boolean" ?
cssFn.apply( this, arguments ) : cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback ); this.animate( genFx( name, true ), speed, easing, callback );
}; };
}); } );
// Generate shortcuts for custom animations // Generate shortcuts for custom animations
jQuery.each({ jQuery.each( {
slideDown: genFx("show"), slideDown: genFx( "show" ),
slideUp: genFx("hide"), slideUp: genFx( "hide" ),
slideToggle: genFx("toggle"), slideToggle: genFx( "toggle" ),
fadeIn: { opacity: "show" }, fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" }, fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" } fadeToggle: { opacity: "toggle" }
@ -591,7 +570,7 @@ jQuery.each({
jQuery.fn[ name ] = function( speed, easing, callback ) { jQuery.fn[ name ] = function( speed, easing, callback ) {
return this.animate( props, speed, easing, callback ); return this.animate( props, speed, easing, callback );
}; };
}); } );
jQuery.timers = []; jQuery.timers = [];
jQuery.fx.tick = function() { jQuery.fx.tick = function() {
@ -603,6 +582,7 @@ jQuery.fx.tick = function() {
for ( ; i < timers.length; i++ ) { for ( ; i < timers.length; i++ ) {
timer = timers[ i ]; timer = timers[ i ];
// Checks the timer has not already been removed // Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) { if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 ); timers.splice( i--, 1 );
@ -625,24 +605,25 @@ jQuery.fx.timer = function( timer ) {
}; };
jQuery.fx.interval = 13; jQuery.fx.interval = 13;
jQuery.fx.start = function() { jQuery.fx.start = function() {
if ( !timerId ) { if ( !timerId ) {
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
} }
}; };
jQuery.fx.stop = function() { jQuery.fx.stop = function() {
clearInterval( timerId ); window.clearInterval( timerId );
timerId = null; timerId = null;
}; };
jQuery.fx.speeds = { jQuery.fx.speeds = {
slow: 600, slow: 600,
fast: 200, fast: 200,
// Default speed // Default speed
_default: 400 _default: 400
}; };
return jQuery; return jQuery;
}); } );

View file

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../css" "../css"
], function( jQuery ) { ], function( jQuery ) {
@ -13,7 +13,7 @@ Tween.prototype = {
init: function( elem, options, prop, end, easing, unit ) { init: function( elem, options, prop, end, easing, unit ) {
this.elem = elem; this.elem = elem;
this.prop = prop; this.prop = prop;
this.easing = easing || "swing"; this.easing = easing || jQuery.easing._default;
this.options = options; this.options = options;
this.start = this.now = this.cur(); this.start = this.now = this.cur();
this.end = end; this.end = end;
@ -59,8 +59,10 @@ Tween.propHooks = {
get: function( tween ) { get: function( tween ) {
var result; var result;
if ( tween.elem[ tween.prop ] != null && // Use a property on the element directly when it is not a DOM element,
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { // or when there is no matching style property that exists.
if ( tween.elem.nodeType !== 1 ||
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
return tween.elem[ tween.prop ]; return tween.elem[ tween.prop ];
} }
@ -69,16 +71,20 @@ Tween.propHooks = {
// Simple values such as "10px" are parsed to Float; // Simple values such as "10px" are parsed to Float;
// complex values such as "rotate(1rad)" are returned as-is. // complex values such as "rotate(1rad)" are returned as-is.
result = jQuery.css( tween.elem, tween.prop, "" ); result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0. // Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result; return !result || result === "auto" ? 0 : result;
}, },
set: function( tween ) { set: function( tween ) {
// Use step hook for back compat. // Use step hook for back compat.
// Use cssHook if its there. // Use cssHook if its there.
// Use .style if available and use plain properties where available. // Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) { if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween ); jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { } else if ( tween.elem.nodeType === 1 &&
( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
jQuery.cssHooks[ tween.prop ] ) ) {
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
} else { } else {
tween.elem[ tween.prop ] = tween.now; tween.elem[ tween.prop ] = tween.now;
@ -103,7 +109,8 @@ jQuery.easing = {
}, },
swing: function( p ) { swing: function( p ) {
return 0.5 - Math.cos( p * Math.PI ) / 2; return 0.5 - Math.cos( p * Math.PI ) / 2;
} },
_default: "swing"
}; };
jQuery.fx = Tween.prototype.init; jQuery.fx = Tween.prototype.init;
@ -111,4 +118,4 @@ jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point // Back Compat <1.8 extension point
jQuery.fx.step = {}; jQuery.fx.step = {};
}); } );

View file

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

View file

@ -1,22 +1,18 @@
define([ define( [
"./core", "./core",
"./var/strundefined", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
"./var/hasOwn",
"./var/slice", "./var/slice",
"./event/support", "./data/var/dataPriv",
"./data/var/data_priv",
"./core/init", "./core/init",
"./data/accepts",
"./selector" "./selector"
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) { ], function( jQuery, document, rnotwhite, slice, dataPriv ) {
var var
rkeyEvent = /^key/, rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
function returnTrue() { function returnTrue() {
return true; return true;
@ -26,12 +22,75 @@ function returnFalse() {
return false; return false;
} }
// Support: IE9
// See #13393 for more info
function safeActiveElement() { function safeActiveElement() {
try { try {
return document.activeElement; return document.activeElement;
} catch ( err ) { } } catch ( err ) { }
} }
function on( elem, types, selector, data, fn, one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
on( elem, type, selector, data, types[ type ], one );
}
return elem;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return this;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
} );
}
/* /*
* Helper functions for managing events -- not part of the public interface. * Helper functions for managing events -- not part of the public interface.
* Props to Dean Edwards' addEvent library for many of the ideas. * Props to Dean Edwards' addEvent library for many of the ideas.
@ -45,7 +104,7 @@ jQuery.event = {
var handleObjIn, eventHandle, tmp, var handleObjIn, eventHandle, tmp,
events, t, handleObj, events, t, handleObj,
special, handlers, type, namespaces, origType, special, handlers, type, namespaces, origType,
elemData = data_priv.get( elem ); elemData = dataPriv.get( elem );
// Don't attach events to noData or text/comment nodes (but allow plain objects) // Don't attach events to noData or text/comment nodes (but allow plain objects)
if ( !elemData ) { if ( !elemData ) {
@ -65,14 +124,15 @@ jQuery.event = {
} }
// Init the element's event structure and main handler, if this is the first // Init the element's event structure and main handler, if this is the first
if ( !(events = elemData.events) ) { if ( !( events = elemData.events ) ) {
events = elemData.events = {}; events = elemData.events = {};
} }
if ( !(eventHandle = elemData.handle) ) { if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) { eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and // Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded // when an event is called after a page has unloaded
return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
jQuery.event.dispatch.apply( elem, arguments ) : undefined; jQuery.event.dispatch.apply( elem, arguments ) : undefined;
}; };
} }
@ -81,9 +141,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length; t = types.length;
while ( t-- ) { while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[1]; type = origType = tmp[ 1 ];
namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// There *must* be a type, no attaching namespace-only handlers // There *must* be a type, no attaching namespace-only handlers
if ( !type ) { if ( !type ) {
@ -100,7 +160,7 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers // handleObj is passed to all event handlers
handleObj = jQuery.extend({ handleObj = jQuery.extend( {
type: type, type: type,
origType: origType, origType: origType,
data: data, data: data,
@ -108,18 +168,20 @@ jQuery.event = {
guid: handler.guid, guid: handler.guid,
selector: selector, selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ), needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".") namespace: namespaces.join( "." )
}, handleObjIn ); }, handleObjIn );
// Init the event handler queue if we're the first // Init the event handler queue if we're the first
if ( !(handlers = events[ type ]) ) { if ( !( handlers = events[ type ] ) ) {
handlers = events[ type ] = []; handlers = events[ type ] = [];
handlers.delegateCount = 0; handlers.delegateCount = 0;
// Only use addEventListener if the special events handler returns false // Only use addEventListener if the special events handler returns false
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { if ( !special.setup ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
if ( elem.addEventListener ) { if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle, false ); elem.addEventListener( type, eventHandle );
} }
} }
} }
@ -151,9 +213,9 @@ jQuery.event = {
var j, origCount, tmp, var j, origCount, tmp,
events, t, handleObj, events, t, handleObj,
special, handlers, type, namespaces, origType, special, handlers, type, namespaces, origType,
elemData = data_priv.hasData( elem ) && data_priv.get( elem ); elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
if ( !elemData || !(events = elemData.events) ) { if ( !elemData || !( events = elemData.events ) ) {
return; return;
} }
@ -161,9 +223,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length; t = types.length;
while ( t-- ) { while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[1]; type = origType = tmp[ 1 ];
namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element // Unbind all events (on this namespace, if provided) for the element
if ( !type ) { if ( !type ) {
@ -176,7 +238,8 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type; type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || []; handlers = events[ type ] || [];
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
// Remove matching events // Remove matching events
origCount = j = handlers.length; origCount = j = handlers.length;
@ -186,7 +249,8 @@ jQuery.event = {
if ( ( mappedTypes || origType === handleObj.origType ) && if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) && ( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) && ( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { ( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
handlers.splice( j, 1 ); handlers.splice( j, 1 );
if ( handleObj.selector ) { if ( handleObj.selector ) {
@ -201,7 +265,9 @@ jQuery.event = {
// Remove generic event handler if we removed something and no more handlers exist // Remove generic event handler if we removed something and no more handlers exist
// (avoids potential for endless recursion during removal of special event handlers) // (avoids potential for endless recursion during removal of special event handlers)
if ( origCount && !handlers.length ) { if ( origCount && !handlers.length ) {
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { if ( !special.teardown ||
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
jQuery.removeEvent( elem, type, elemData.handle ); jQuery.removeEvent( elem, type, elemData.handle );
} }
@ -209,145 +275,12 @@ jQuery.event = {
} }
} }
// Remove the expando if it's no longer used // Remove data and the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) { if ( jQuery.isEmptyObject( events ) ) {
delete elemData.handle; dataPriv.remove( elem, "handle events" );
data_priv.remove( elem, "events" );
} }
}, },
trigger: function( event, data, elem, onlyHandlers ) {
var i, cur, tmp, bubbleType, ontype, handle, special,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
cur = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf(".") >= 0 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf(":") < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join(".");
event.namespace_re = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (#9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === (elem.ownerDocument || document) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
}
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
jQuery.acceptData( elem ) ) {
// Call a native DOM method on the target with the same name name as the event.
// Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
elem[ type ]();
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
}
return event.result;
},
dispatch: function( event ) { dispatch: function( event ) {
// Make a writable jQuery.Event from the native event object // Make a writable jQuery.Event from the native event object
@ -356,11 +289,11 @@ jQuery.event = {
var i, j, ret, matched, handleObj, var i, j, ret, matched, handleObj,
handlerQueue = [], handlerQueue = [],
args = slice.call( arguments ), args = slice.call( arguments ),
handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {}; special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event // Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event; args[ 0 ] = event;
event.delegateTarget = this; event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired // Call the preDispatch hook for the mapped type, and let it bail if desired
@ -373,24 +306,25 @@ jQuery.event = {
// Run delegates first; they may want to stop propagation beneath us // Run delegates first; they may want to stop propagation beneath us
i = 0; i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem; event.currentTarget = matched.elem;
j = 0; j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or 2) have namespace(s) // Triggered event must either 1) have no namespace, or 2) have namespace(s)
// a subset or equal to those in the bound event (both can have no namespace). // a subset or equal to those in the bound event (both can have no namespace).
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
event.handleObj = handleObj; event.handleObj = handleObj;
event.data = handleObj.data; event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
.apply( matched.elem, args ); handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) { if ( ret !== undefined ) {
if ( (event.result = ret) === false ) { if ( ( event.result = ret ) === false ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
@ -413,15 +347,20 @@ jQuery.event = {
delegateCount = handlers.delegateCount, delegateCount = handlers.delegateCount,
cur = event.target; cur = event.target;
// Support (at least): Chrome, IE9
// Find delegate handlers // Find delegate handlers
// Black-hole SVG <use> instance trees (#13180) // Black-hole SVG <use> instance trees (#13180)
// Avoid non-left-click bubbling in Firefox (#3861) //
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { // Support: Firefox<=42+
// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
if ( delegateCount && cur.nodeType &&
( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
for ( ; cur !== this; cur = cur.parentNode || this ) { for ( ; cur !== this; cur = cur.parentNode || this ) {
// Don't check non-elements (#13208)
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
if ( cur.disabled !== true || event.type !== "click" ) { if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
matches = []; matches = [];
for ( i = 0; i < delegateCount; i++ ) { for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ]; handleObj = handlers[ i ];
@ -431,7 +370,7 @@ jQuery.event = {
if ( matches[ sel ] === undefined ) { if ( matches[ sel ] === undefined ) {
matches[ sel ] = handleObj.needsContext ? matches[ sel ] = handleObj.needsContext ?
jQuery( sel, this ).index( cur ) >= 0 : jQuery( sel, this ).index( cur ) > -1 :
jQuery.find( sel, this, null, [ cur ] ).length; jQuery.find( sel, this, null, [ cur ] ).length;
} }
if ( matches[ sel ] ) { if ( matches[ sel ] ) {
@ -439,7 +378,7 @@ jQuery.event = {
} }
} }
if ( matches.length ) { if ( matches.length ) {
handlerQueue.push({ elem: cur, handlers: matches }); handlerQueue.push( { elem: cur, handlers: matches } );
} }
} }
} }
@ -447,19 +386,20 @@ jQuery.event = {
// Add the remaining (directly-bound) handlers // Add the remaining (directly-bound) handlers
if ( delegateCount < handlers.length ) { if ( delegateCount < handlers.length ) {
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
} }
return handlerQueue; return handlerQueue;
}, },
// Includes some event props shared by KeyEvent and MouseEvent // Includes some event props shared by KeyEvent and MouseEvent
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
fixHooks: {}, fixHooks: {},
keyHooks: { keyHooks: {
props: "char charCode key keyCode".split(" "), props: "char charCode key keyCode".split( " " ),
filter: function( event, original ) { filter: function( event, original ) {
// Add which for key events // Add which for key events
@ -472,7 +412,8 @@ jQuery.event = {
}, },
mouseHooks: { mouseHooks: {
props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " +
"screenX screenY toElement" ).split( " " ),
filter: function( event, original ) { filter: function( event, original ) {
var eventDoc, doc, body, var eventDoc, doc, body,
button = original.button; button = original.button;
@ -483,8 +424,12 @@ jQuery.event = {
doc = eventDoc.documentElement; doc = eventDoc.documentElement;
body = eventDoc.body; body = eventDoc.body;
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); event.pageX = original.clientX +
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
( doc && doc.clientLeft || body && body.clientLeft || 0 );
event.pageY = original.clientY +
( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
( doc && doc.clientTop || body && body.clientTop || 0 );
} }
// Add which for click: 1 === left; 2 === middle; 3 === right // Add which for click: 1 === left; 2 === middle; 3 === right
@ -541,10 +486,12 @@ jQuery.event = {
special: { special: {
load: { load: {
// Prevent triggered image.load events from bubbling to window.load // Prevent triggered image.load events from bubbling to window.load
noBubble: true noBubble: true
}, },
focus: { focus: {
// Fire native event if possible so blur/focus sequence is correct // Fire native event if possible so blur/focus sequence is correct
trigger: function() { trigger: function() {
if ( this !== safeActiveElement() && this.focus ) { if ( this !== safeActiveElement() && this.focus ) {
@ -564,6 +511,7 @@ jQuery.event = {
delegateType: "focusout" delegateType: "focusout"
}, },
click: { click: {
// For checkbox, fire native event so checked state will be right // For checkbox, fire native event so checked state will be right
trigger: function() { trigger: function() {
if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
@ -588,41 +536,21 @@ jQuery.event = {
} }
} }
} }
},
simulate: function( type, elem, event, bubble ) {
// Piggyback on a donor event to simulate a different one.
// Fake originalEvent to avoid donor's stopPropagation, but if the
// simulated event prevents default then we do the same on the donor.
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true,
originalEvent: {}
}
);
if ( bubble ) {
jQuery.event.trigger( e, null, elem );
} else {
jQuery.event.dispatch.call( elem, e );
}
if ( e.isDefaultPrevented() ) {
event.preventDefault();
}
} }
}; };
jQuery.removeEvent = function( elem, type, handle ) { jQuery.removeEvent = function( elem, type, handle ) {
// This "if" is needed for plain objects
if ( elem.removeEventListener ) { if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle, false ); elem.removeEventListener( type, handle );
} }
}; };
jQuery.Event = function( src, props ) { jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword // Allow instantiation without the 'new' keyword
if ( !(this instanceof jQuery.Event) ) { if ( !( this instanceof jQuery.Event ) ) {
return new jQuery.Event( src, props ); return new jQuery.Event( src, props );
} }
@ -635,6 +563,7 @@ jQuery.Event = function( src, props ) {
// by a handler lower down the tree; reflect the correct value. // by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented || this.isDefaultPrevented = src.defaultPrevented ||
src.defaultPrevented === undefined && src.defaultPrevented === undefined &&
// Support: Android<4.0 // Support: Android<4.0
src.returnValue === false ? src.returnValue === false ?
returnTrue : returnTrue :
@ -660,6 +589,7 @@ jQuery.Event = function( src, props ) {
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = { jQuery.Event.prototype = {
constructor: jQuery.Event,
isDefaultPrevented: returnFalse, isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse, isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse, isImmediatePropagationStopped: returnFalse,
@ -669,7 +599,7 @@ jQuery.Event.prototype = {
this.isDefaultPrevented = returnTrue; this.isDefaultPrevented = returnTrue;
if ( e && e.preventDefault ) { if ( e ) {
e.preventDefault(); e.preventDefault();
} }
}, },
@ -678,7 +608,7 @@ jQuery.Event.prototype = {
this.isPropagationStopped = returnTrue; this.isPropagationStopped = returnTrue;
if ( e && e.stopPropagation ) { if ( e ) {
e.stopPropagation(); e.stopPropagation();
} }
}, },
@ -687,7 +617,7 @@ jQuery.Event.prototype = {
this.isImmediatePropagationStopped = returnTrue; this.isImmediatePropagationStopped = returnTrue;
if ( e && e.stopImmediatePropagation ) { if ( e ) {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
} }
@ -696,8 +626,14 @@ jQuery.Event.prototype = {
}; };
// Create mouseenter/leave events using mouseover/out and event-time checks // Create mouseenter/leave events using mouseover/out and event-time checks
// Support: Chrome 15+ // so that event delegation works in jQuery.
jQuery.each({ // Do the same for pointerenter/pointerleave and pointerover/pointerout
//
// Support: Safari 7 only
// Safari sends mouseenter too often; see:
// https://code.google.com/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well).
jQuery.each( {
mouseenter: "mouseover", mouseenter: "mouseover",
mouseleave: "mouseout", mouseleave: "mouseout",
pointerenter: "pointerover", pointerenter: "pointerover",
@ -713,9 +649,9 @@ jQuery.each({
related = event.relatedTarget, related = event.relatedTarget,
handleObj = event.handleObj; handleObj = event.handleObj;
// For mousenter/leave call the handler if related is outside the target. // For mouseenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window // NB: No relatedTarget if the mouse left/entered the browser window
if ( !related || (related !== target && !jQuery.contains( target, related )) ) { if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
event.type = handleObj.origType; event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments ); ret = handleObj.handler.apply( this, arguments );
event.type = fix; event.type = fix;
@ -723,115 +659,32 @@ jQuery.each({
return ret; return ret;
} }
}; };
}); } );
// Support: Firefox, Chrome, Safari jQuery.fn.extend( {
// Create "bubbling" focus and blur events on: function( types, selector, data, fn ) {
if ( !support.focusinBubbles ) { return on( this, types, selector, data, fn );
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
};
jQuery.event.special[ fix ] = {
setup: function() {
var doc = this.ownerDocument || this,
attaches = data_priv.access( doc, fix );
if ( !attaches ) {
doc.addEventListener( orig, handler, true );
}
data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
var doc = this.ownerDocument || this,
attaches = data_priv.access( doc, fix ) - 1;
if ( !attaches ) {
doc.removeEventListener( orig, handler, true );
data_priv.remove( doc, fix );
} else {
data_priv.access( doc, fix, attaches );
}
}
};
});
}
jQuery.fn.extend({
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
this.on( type, selector, data, types[ type ], one );
}
return this;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return this;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return this.each( function() {
jQuery.event.add( this, types, fn, data, selector );
});
}, },
one: function( types, selector, data, fn ) { one: function( types, selector, data, fn ) {
return this.on( types, selector, data, fn, 1 ); return on( this, types, selector, data, fn, 1 );
}, },
off: function( types, selector, fn ) { off: function( types, selector, fn ) {
var handleObj, type; var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) { if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event // ( event ) dispatched jQuery.Event
handleObj = types.handleObj; handleObj = types.handleObj;
jQuery( types.delegateTarget ).off( jQuery( types.delegateTarget ).off(
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.namespace ?
handleObj.origType + "." + handleObj.namespace :
handleObj.origType,
handleObj.selector, handleObj.selector,
handleObj.handler handleObj.handler
); );
return this; return this;
} }
if ( typeof types === "object" ) { if ( typeof types === "object" ) {
// ( types-object [, selector] ) // ( types-object [, selector] )
for ( type in types ) { for ( type in types ) {
this.off( type, selector, types[ type ] ); this.off( type, selector, types[ type ] );
@ -839,6 +692,7 @@ jQuery.fn.extend({
return this; return this;
} }
if ( selector === false || typeof selector === "function" ) { if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] ) // ( types [, fn] )
fn = selector; fn = selector;
selector = undefined; selector = undefined;
@ -846,23 +700,11 @@ jQuery.fn.extend({
if ( fn === false ) { if ( fn === false ) {
fn = returnFalse; fn = returnFalse;
} }
return this.each(function() { return this.each( function() {
jQuery.event.remove( this, types, fn, selector ); jQuery.event.remove( this, types, fn, selector );
}); } );
},
trigger: function( type, data ) {
return this.each(function() {
jQuery.event.trigger( type, data, this );
});
},
triggerHandler: function( type, data ) {
var elem = this[0];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
} }
}); } );
return jQuery; return jQuery;
}); } );

View file

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

View file

@ -1,11 +1,14 @@
define([ define( [
"../core", "../core",
"../event"
"../event",
"./trigger"
], function( jQuery ) { ], function( jQuery ) {
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
function( i, name ) {
// Handle event binding // Handle event binding
jQuery.fn[ name ] = function( data, fn ) { jQuery.fn[ name ] = function( data, fn ) {
@ -13,27 +16,12 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
this.on( name, null, data, fn ) : this.on( name, null, data, fn ) :
this.trigger( name ); this.trigger( name );
}; };
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
hover: function( fnOver, fnOut ) { hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
} }
}); } );
}); } );

View file

@ -0,0 +1,53 @@
define( [
"../core",
"../data/var/dataPriv",
"./support",
"../event",
"./trigger"
], function( jQuery, dataPriv, support ) {
// Support: Firefox
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
//
// Support: Chrome, Safari
// focus(in | out) events fire after focus & blur events,
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
};
jQuery.event.special[ fix ] = {
setup: function() {
var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix );
if ( !attaches ) {
doc.addEventListener( orig, handler, true );
}
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
var doc = this.ownerDocument || this,
attaches = dataPriv.access( doc, fix ) - 1;
if ( !attaches ) {
doc.removeEventListener( orig, handler, true );
dataPriv.remove( doc, fix );
} else {
dataPriv.access( doc, fix, attaches );
}
}
};
} );
}
return jQuery;
} );

View file

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

View file

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

View file

@ -1,4 +1,4 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
@ -18,7 +18,7 @@ define([
if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() { define( "jquery", [], function() {
return jQuery; return jQuery;
}); } );
} }
}); } );

View file

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

View file

@ -5,7 +5,7 @@
* Includes Sizzle.js * Includes Sizzle.js
* http://sizzlejs.com/ * http://sizzlejs.com/
* *
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *

View file

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./selector", "./selector",
"./traversing", "./traversing",
@ -11,6 +11,7 @@ define([
"./attributes", "./attributes",
"./event", "./event",
"./event/alias", "./event/alias",
"./event/focusin",
"./manipulation", "./manipulation",
"./manipulation/_evalUrl", "./manipulation/_evalUrl",
"./wrap", "./wrap",
@ -28,10 +29,9 @@ define([
"./offset", "./offset",
"./dimensions", "./dimensions",
"./deprecated", "./deprecated",
"./exports/amd", "./exports/amd"
"./exports/global"
], function( jQuery ) { ], function( jQuery ) {
return jQuery; return ( window.jQuery = window.$ = jQuery );
}); } );

View file

@ -1,65 +1,56 @@
define([ define( [
"./core", "./core",
"./var/concat", "./var/concat",
"./var/push", "./var/push",
"./core/access", "./core/access",
"./manipulation/var/rcheckableType", "./manipulation/var/rcheckableType",
"./manipulation/var/rtagName",
"./manipulation/var/rscriptType",
"./manipulation/wrapMap",
"./manipulation/getAll",
"./manipulation/setGlobalEval",
"./manipulation/buildFragment",
"./manipulation/support", "./manipulation/support",
"./data/var/data_priv",
"./data/var/data_user", "./data/var/dataPriv",
"./data/var/dataUser",
"./data/var/acceptData",
"./core/init", "./core/init",
"./data/accepts",
"./traversing", "./traversing",
"./selector", "./selector",
"./event" "./event"
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) { ], function( jQuery, concat, push, access,
rcheckableType, rtagName, rscriptType,
wrapMap, getAll, setGlobalEval, buildFragment, support,
dataPriv, dataUser, acceptData ) {
var var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/,
rhtml = /<|&#?\w+;/, // Support: IE 10-11, Edge 10240+
rnoInnerhtml = /<(?:script|style|link)/i, // In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
rnoInnerhtml = /<script|<style|<link/i,
// checked="checked" or checked // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /^$|\/(?:java|ecma)script/i,
rscriptTypeMasked = /^true\/(.*)/, rscriptTypeMasked = /^true\/(.*)/,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
// We have to close these tags to support XHTML (#13200)
wrapMap = {
// Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ],
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
// Support: IE9
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
// Support: 1.x compatibility
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) { function manipulationTarget( elem, content ) {
return jQuery.nodeName( elem, "table" ) && if ( jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
elem.getElementsByTagName("tbody")[0] || return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
elem.appendChild( elem.ownerDocument.createElement("tbody") ) : }
elem;
return elem;
} }
// Replace/restore the type attribute of script elements for safe DOM manipulation // Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) { function disableScript( elem ) {
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
return elem; return elem;
} }
function restoreScript( elem ) { function restoreScript( elem ) {
@ -68,24 +59,12 @@ function restoreScript( elem ) {
if ( match ) { if ( match ) {
elem.type = match[ 1 ]; elem.type = match[ 1 ];
} else { } else {
elem.removeAttribute("type"); elem.removeAttribute( "type" );
} }
return elem; return elem;
} }
// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
data_priv.set(
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
);
}
}
function cloneCopyEvent( src, dest ) { function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
@ -94,9 +73,9 @@ function cloneCopyEvent( src, dest ) {
} }
// 1. Copy private data: events, handlers, etc. // 1. Copy private data: events, handlers, etc.
if ( data_priv.hasData( src ) ) { if ( dataPriv.hasData( src ) ) {
pdataOld = data_priv.access( src ); pdataOld = dataPriv.access( src );
pdataCur = data_priv.set( dest, pdataOld ); pdataCur = dataPriv.set( dest, pdataOld );
events = pdataOld.events; events = pdataOld.events;
if ( events ) { if ( events ) {
@ -112,24 +91,14 @@ function cloneCopyEvent( src, dest ) {
} }
// 2. Copy user data // 2. Copy user data
if ( data_user.hasData( src ) ) { if ( dataUser.hasData( src ) ) {
udataOld = data_user.access( src ); udataOld = dataUser.access( src );
udataCur = jQuery.extend( {}, udataOld ); udataCur = jQuery.extend( {}, udataOld );
data_user.set( dest, udataCur ); dataUser.set( dest, udataCur );
} }
} }
function getAll( context, tag ) {
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
[];
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}
// Fix IE bugs, see support tests // Fix IE bugs, see support tests
function fixInput( src, dest ) { function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase(); var nodeName = dest.nodeName.toLowerCase();
@ -144,7 +113,122 @@ function fixInput( src, dest ) {
} }
} }
jQuery.extend({ function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return collection.each( function( index ) {
var self = collection.eq( index );
if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
domManip( self, args, callback, ignored );
} );
}
if ( l ) {
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
// Require either new content or an interest in ignored elements to invoke the callback
if ( first || ignored ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item
// instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!dataPriv.access( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
}
}
}
}
}
}
return collection;
}
function remove( elem, selector, keepData ) {
var node,
nodes = selector ? jQuery.filter( selector, elem ) : elem,
i = 0;
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) );
}
if ( node.parentNode ) {
if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
setGlobalEval( getAll( node, "script" ) );
}
node.parentNode.removeChild( node );
}
}
return elem;
}
jQuery.extend( {
htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
},
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var i, l, srcElements, destElements, var i, l, srcElements, destElements,
clone = elem.cloneNode( true ), clone = elem.cloneNode( true ),
@ -187,102 +271,14 @@ jQuery.extend({
return clone; return clone;
}, },
buildFragment: function( elems, context, scripts, selection ) {
var elem, tmp, tag, wrap, contains, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement("div") );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (#12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( (elem = nodes[ i++ ]) ) {
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
continue;
}
contains = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( contains ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
},
cleanData: function( elems ) { cleanData: function( elems ) {
var data, elem, type, key, var data, elem, type,
special = jQuery.event.special, special = jQuery.event.special,
i = 0; i = 0;
for ( ; (elem = elems[ i ]) !== undefined; i++ ) { for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
if ( jQuery.acceptData( elem ) ) { if ( acceptData( elem ) ) {
key = elem[ data_priv.expando ]; if ( ( data = elem[ dataPriv.expando ] ) ) {
if ( key && (data = data_priv.cache[ key ]) ) {
if ( data.events ) { if ( data.events ) {
for ( type in data.events ) { for ( type in data.events ) {
if ( special[ type ] ) { if ( special[ type ] ) {
@ -294,91 +290,86 @@ jQuery.extend({
} }
} }
} }
if ( data_priv.cache[ key ] ) {
// Discard any remaining `private` data // Support: Chrome <= 35-45+
delete data_priv.cache[ key ]; // Assign undefined instead of using delete, see Data#remove
} elem[ dataPriv.expando ] = undefined;
}
if ( elem[ dataUser.expando ] ) {
// Support: Chrome <= 35-45+
// Assign undefined instead of using delete, see Data#remove
elem[ dataUser.expando ] = undefined;
} }
} }
// Discard any remaining `user` data
delete data_user.cache[ elem[ data_user.expando ] ];
} }
} }
}); } );
jQuery.fn.extend( {
// Keep domManip exposed until 3.0 (gh-2225)
domManip: domManip,
detach: function( selector ) {
return remove( this, selector, true );
},
remove: function( selector ) {
return remove( this, selector );
},
jQuery.fn.extend({
text: function( value ) { text: function( value ) {
return access( this, function( value ) { return access( this, function( value ) {
return value === undefined ? return value === undefined ?
jQuery.text( this ) : jQuery.text( this ) :
this.empty().each(function() { this.empty().each( function() {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
this.textContent = value; this.textContent = value;
} }
}); } );
}, null, value, arguments.length ); }, null, value, arguments.length );
}, },
append: function() { append: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.appendChild( elem ); target.appendChild( elem );
} }
}); } );
}, },
prepend: function() { prepend: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild ); target.insertBefore( elem, target.firstChild );
} }
}); } );
}, },
before: function() { before: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
} }
}); } );
}, },
after: function() { after: function() {
return this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
} }
}); } );
},
remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
}
if ( elem.parentNode ) {
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
setGlobalEval( getAll( elem, "script" ) );
}
elem.parentNode.removeChild( elem );
}
}
return this;
}, },
empty: function() { empty: function() {
var elem, var elem,
i = 0; i = 0;
for ( ; (elem = this[i]) != null; i++ ) { for ( ; ( elem = this[ i ] ) != null; i++ ) {
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
// Prevent memory leaks // Prevent memory leaks
@ -396,9 +387,9 @@ jQuery.fn.extend({
dataAndEvents = dataAndEvents == null ? false : dataAndEvents; dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map(function() { return this.map( function() {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
}); } );
}, },
html: function( value ) { html: function( value ) {
@ -415,7 +406,7 @@ jQuery.fn.extend({
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
value = value.replace( rxhtmlTag, "<$1></$2>" ); value = jQuery.htmlPrefilter( value );
try { try {
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
@ -431,7 +422,7 @@ jQuery.fn.extend({
elem = 0; elem = 0;
// If using innerHTML throws an exception, use the fallback method // If using innerHTML throws an exception, use the fallback method
} catch( e ) {} } catch ( e ) {}
} }
if ( elem ) { if ( elem ) {
@ -441,115 +432,25 @@ jQuery.fn.extend({
}, },
replaceWith: function() { replaceWith: function() {
var arg = arguments[ 0 ]; var ignored = [];
// Make the changes, replacing each context element with the new content // Make the changes, replacing each non-ignored context element with the new content
this.domManip( arguments, function( elem ) { return domManip( this, arguments, function( elem ) {
arg = this.parentNode; var parent = this.parentNode;
jQuery.cleanData( getAll( this ) ); if ( jQuery.inArray( this, ignored ) < 0 ) {
jQuery.cleanData( getAll( this ) );
if ( arg ) { if ( parent ) {
arg.replaceChild( elem, this ); parent.replaceChild( elem, this );
}
});
// Force removal if there was no new content (e.g., from empty arguments)
return arg && (arg.length || arg.nodeType) ? this : this.remove();
},
detach: function( selector ) {
return this.remove( selector, true );
},
domManip: function( args, callback ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = this.length,
set = this,
iNoClone = l - 1,
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
}
self.domManip( args, callback );
});
}
if ( l ) {
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
if ( first ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: QtWebKit
// jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( this[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
}
}
}
} }
} }
}
return this; // Force callback invocation
}, ignored );
} }
}); } );
jQuery.each({ jQuery.each( {
appendTo: "append", appendTo: "append",
prependTo: "prepend", prependTo: "prepend",
insertBefore: "before", insertBefore: "before",
@ -574,7 +475,7 @@ jQuery.each({
return this.pushStack( ret ); return this.pushStack( ret );
}; };
}); } );
return jQuery; return jQuery;
}); } );

View file

@ -1,18 +1,20 @@
define([ define( [
"../ajax" "../ajax"
], function( jQuery ) { ], function( jQuery ) {
jQuery._evalUrl = function( url ) { jQuery._evalUrl = function( url ) {
return jQuery.ajax({ return jQuery.ajax( {
url: url, url: url,
// Make this explicit, since user can override this through ajaxSetup (#11264)
type: "GET", type: "GET",
dataType: "script", dataType: "script",
async: false, async: false,
global: false, global: false,
"throws": true "throws": true
}); } );
}; };
return jQuery._evalUrl; return jQuery._evalUrl;
}); } );

View file

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

View file

@ -0,0 +1,21 @@
define( [
"../core"
], function( jQuery ) {
function getAll( context, tag ) {
// Support: IE9-11+
// Use typeof to avoid zero-argument method invocation on host objects (#15151)
var ret = typeof context.getElementsByTagName !== "undefined" ?
context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== "undefined" ?
context.querySelectorAll( tag || "*" ) :
[];
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}
return getAll;
} );

View file

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

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