Build: Update jscs and lint files

Fixes gh-2056
This commit is contained in:
Oleg Gaidarenko 2015-08-16 09:59:58 +03:00
parent 7aa46e0df8
commit 10fdad742a
129 changed files with 8640 additions and 7900 deletions

View File

@ -1,6 +1,10 @@
{ {
"preset": "jquery", "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", "excludeFiles": [ "external", "src/intro.js", "src/outro.js",
"test/node_smoke_tests/lib/ensure_iterability.js" ] "test/node_smoke_tests/lib/ensure_iterability.js", "node_modules" ]
} }

View File

@ -20,7 +20,7 @@ module.exports = function( grunt ) {
// But our modules can // But our modules can
delete srcHintOptions.onevar; delete srcHintOptions.onevar;
grunt.initConfig({ grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ), pkg: grunt.file.readJSON( "package.json" ),
dst: readOptionalJSON( "dist/.destination.json" ), dst: readOptionalJSON( "dist/.destination.json" ),
"compare_size": { "compare_size": {
@ -53,6 +53,7 @@ module.exports = function( grunt ) {
"core", "core",
"selector" "selector"
], ],
// Exclude specified modules if the module matching the key is removed // Exclude specified modules if the module matching the key is removed
removeWith: { removeWith: {
ajax: [ "manipulation/_evalUrl", "event/ajax" ], ajax: [ "manipulation/_evalUrl", "event/ajax" ],
@ -108,7 +109,12 @@ module.exports = function( grunt ) {
gruntfile: "Gruntfile.js", gruntfile: "Gruntfile.js",
// Check parts of tests that pass // Check parts of tests that pass
test: [ "test/data/testrunner.js", "test/unit/animation.js", "test/unit/tween.js" ], test: [
"test/data/testrunner.js",
"test/unit/animation.js",
"test/unit/tween.js",
"test/unit/wrap.js"
],
release: [ "build/*.js", "!build/release-notes.js" ], release: [ "build/*.js", "!build/release-notes.js" ],
tasks: "build/tasks/*.js" tasks: "build/tasks/*.js"
}, },
@ -162,7 +168,7 @@ module.exports = function( grunt ) {
} }
} }
} }
}); } );
// Load grunt tasks from NPM packages // Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt ); require( "load-grunt-tasks" )( grunt );
@ -177,7 +183,7 @@ module.exports = function( grunt ) {
grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] ); grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] );
// Short list as a high frequency watch task // Short list as a high frequency watch task
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] ); grunt.registerTask( "dev", [ "build:*:*", "uglify", "remove_map_comment", "dist:*" ] );
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] ); grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
}; };

View File

@ -9,7 +9,7 @@ module.exports = function( Release ) {
npmTags = Release.npmTags; npmTags = Release.npmTags;
Release.define({ Release.define( {
npmPublish: true, npmPublish: true,
issueTracker: "github", issueTracker: "github",
/** /**
@ -36,6 +36,7 @@ module.exports = function( Release ) {
* for publishing the distribution repo instead * for publishing the distribution repo instead
*/ */
npmTags: function() { npmTags: function() {
// origRepo is not defined if dist was skipped // origRepo is not defined if dist was skipped
Release.dir.repo = Release.dir.origRepo || Release.dir.repo; Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags(); return npmTags();
@ -47,9 +48,9 @@ module.exports = function( Release ) {
dist: function( callback ) { dist: function( callback ) {
cdn.makeArchives( Release, function() { cdn.makeArchives( Release, function() {
dist( Release, callback ); dist( Release, callback );
}); } );
} }
}); } );
}; };
module.exports.dependencies = [ module.exports.dependencies = [

View File

@ -29,13 +29,14 @@ var
function makeReleaseCopies( Release ) { function makeReleaseCopies( Release ) {
shell.mkdir( "-p", cdnFolder ); shell.mkdir( "-p", cdnFolder );
Object.keys( releaseFiles ).forEach(function( key ) { Object.keys( releaseFiles ).forEach( function( key ) {
var text, var text,
builtFile = releaseFiles[ key ], builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, Release.newVersion ), unpathedFile = key.replace( /VER/g, Release.newVersion ),
releaseFile = cdnFolder + "/" + unpathedFile; releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFile ) ) { if ( /\.map$/.test( releaseFile ) ) {
// Map files need to reference the new uncompressed name; // Map files need to reference the new uncompressed name;
// assume that all files reside in the same directory. // assume that all files reside in the same directory.
// "file":"jquery.min.js","sources":["jquery.js"] // "file":"jquery.min.js","sources":["jquery.js"]
@ -47,7 +48,7 @@ function makeReleaseCopies( Release ) {
} else if ( builtFile !== releaseFile ) { } else if ( builtFile !== releaseFile ) {
shell.cp( "-f", builtFile, releaseFile ); shell.cp( "-f", builtFile, releaseFile );
} }
}); } );
} }
function makeArchives( Release, callback ) { function makeArchives( Release, callback ) {
@ -75,23 +76,23 @@ function makeArchives( Release, callback ) {
output.on( "error", function( err ) { output.on( "error", function( err ) {
throw err; throw err;
}); } );
archiver.pipe( output ); archiver.pipe( output );
files = files.map(function( item ) { files = files.map( function( item ) {
return "dist" + ( rver.test( item ) ? "/cdn" : "" ) + "/" + return "dist" + ( rver.test( item ) ? "/cdn" : "" ) + "/" +
item.replace( rver, Release.newVersion ); item.replace( rver, Release.newVersion );
}); } );
sum = Release.exec( "md5sum " + files.join( " " ), "Error retrieving md5sum" ); sum = Release.exec( "md5sum " + files.join( " " ), "Error retrieving md5sum" );
fs.writeFileSync( md5file, sum ); fs.writeFileSync( md5file, sum );
files.push( md5file ); files.push( md5file );
files.forEach(function( file ) { files.forEach( function( file ) {
archiver.append( fs.createReadStream( file ), archiver.append( fs.createReadStream( file ),
{ name: path.basename( file ) } ); { name: path.basename( file ) } );
}); } );
archiver.finalize(); archiver.finalize();
} }
@ -104,9 +105,9 @@ function makeArchives( Release, callback ) {
makeArchive( "mscdn", msFilesCDN, callback ); makeArchive( "mscdn", msFilesCDN, callback );
} }
buildGoogleCDN(function() { buildGoogleCDN( function() {
buildMicrosoftCDN( callback ); buildMicrosoftCDN( callback );
}); } );
} }
module.exports = { module.exports = {

View File

@ -5,6 +5,7 @@ module.exports = function( Release, complete ) {
shell = require( "shelljs" ), shell = require( "shelljs" ),
pkg = require( Release.dir.repo + "/package.json" ), pkg = require( Release.dir.repo + "/package.json" ),
distRemote = Release.remote.replace( "jquery.git", "jquery-dist.git" ), distRemote = Release.remote.replace( "jquery.git", "jquery-dist.git" ),
// These files are included with the distribution // These files are included with the distribution
files = [ files = [
"src", "src",
@ -34,7 +35,7 @@ module.exports = function( Release, complete ) {
* Generate bower file for jquery-dist * Generate bower file for jquery-dist
*/ */
function generateBower() { function generateBower() {
return JSON.stringify({ return JSON.stringify( {
name: pkg.name, name: pkg.name,
main: pkg.main, main: pkg.main,
license: "MIT", license: "MIT",
@ -42,7 +43,7 @@ module.exports = function( Release, complete ) {
"package.json" "package.json"
], ],
keywords: pkg.keywords keywords: pkg.keywords
}, null, 2); }, null, 2 );
} }
/** /**
@ -57,14 +58,14 @@ module.exports = function( Release, complete ) {
"dist/jquery.js", "dist/jquery.js",
"dist/jquery.min.js", "dist/jquery.min.js",
"dist/jquery.min.map" "dist/jquery.min.map"
].forEach(function( file ) { ].forEach( function( file ) {
shell.cp( Release.dir.repo + "/" + file, distFolder ); shell.cp( Release.dir.repo + "/" + file, distFolder );
}); } );
// Copy other files // Copy other files
files.forEach(function( file ) { files.forEach( function( file ) {
shell.cp( "-r", Release.dir.repo + "/" + file, Release.dir.dist ); shell.cp( "-r", Release.dir.repo + "/" + file, Release.dir.dist );
}); } );
// Write generated bower file // Write generated bower file
fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() ); fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );

View File

@ -8,7 +8,7 @@ var fs = require( "fs" ),
* @param {Function(string)} callback * @param {Function(string)} callback
*/ */
function getLatestSizzle( callback ) { function getLatestSizzle( callback ) {
npm.load(function( err, npm ) { npm.load( function( err, npm ) {
if ( err ) { if ( err ) {
throw err; throw err;
} }
@ -17,8 +17,8 @@ function getLatestSizzle( callback ) {
throw err; throw err;
} }
callback( Object.keys( info )[ 0 ] ); callback( Object.keys( info )[ 0 ] );
}); } );
}); } );
} }
/** /**
@ -29,11 +29,12 @@ function getLatestSizzle( callback ) {
function ensureSizzle( Release, callback ) { function ensureSizzle( Release, callback ) {
console.log(); console.log();
console.log( "Checking Sizzle version..." ); console.log( "Checking Sizzle version..." );
getLatestSizzle(function( latest ) { getLatestSizzle( function( latest ) {
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ), var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
version = match ? match[ 1 ] : "Not Found"; version = match ? match[ 1 ] : "Not Found";
if ( version !== latest ) { if ( version !== latest ) {
// colors is inherited from jquery-release // colors is inherited from jquery-release
console.log( console.log(
"The Sizzle version in the src folder (" + version.red + "The Sizzle version in the src folder (" + version.red +
@ -44,7 +45,7 @@ function ensureSizzle( Release, callback ) {
console.log( "Sizzle is latest (" + latest.green + ")" ); console.log( "Sizzle is latest (" + latest.green + ")" );
callback(); callback();
} }
}); } );
} }
module.exports = ensureSizzle; module.exports = ensureSizzle;

View File

@ -3,16 +3,16 @@
* jQuery Release Note Generator * jQuery Release Note Generator
*/ */
var http = require("http"), var http = require( "http" ),
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g, extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g,
version = process.argv[2]; version = process.argv[ 2 ];
if ( !/^\d+\.\d+/.test( version ) ) { if ( !/^\d+\.\d+/.test( version ) ) {
console.error( "Invalid version number: " + version ); console.error( "Invalid version number: " + version );
process.exit( 1 ); process.exit( 1 );
} }
http.request({ http.request( {
host: "bugs.jquery.com", host: "bugs.jquery.com",
port: 80, port: 80,
method: "GET", method: "GET",
@ -23,34 +23,36 @@ http.request({
res.on( "data", function( chunk ) { res.on( "data", function( chunk ) {
data.push( chunk ); data.push( chunk );
}); } );
res.on( "end", function() { res.on( "end", function() {
var match, cur, cat, var match, cur, cat,
file = data.join(""); file = data.join( "" );
while ( (match = extract.exec( file )) ) { while ( ( match = extract.exec( file ) ) ) {
if ( "#" + match[1] !== match[2] ) { if ( "#" + match[ 1 ] !== match[ 2 ] ) {
cat = match[3]; cat = match[ 3 ];
if ( !cur || cur !== cat ) { if ( !cur || cur !== cat ) {
if ( cur ) { if ( cur ) {
console.log("</ul>"); console.log( "</ul>" );
} }
cur = cat; cur = cat;
console.log( "<h3>" + cat.charAt(0).toUpperCase() + cat.slice(1) + "</h3>" ); console.log(
console.log("<ul>"); "<h3>" + cat.charAt( 0 ).toUpperCase() + cat.slice( 1 ) + "</h3>"
);
console.log( "<ul>" );
} }
console.log( console.log(
" <li><a href=\"http://bugs.jquery.com/ticket/" + match[1] + "\">#" + " <li><a href=\"http://bugs.jquery.com/ticket/" + match[ 1 ] + "\">#" +
match[1] + ": " + match[2] + "</a></li>" match[ 1 ] + ": " + match[ 2 ] + "</a></li>"
); );
} }
} }
if ( cur ) { if ( cur ) {
console.log("</ul>"); console.log( "</ul>" );
} }
}); } );
}).end(); } ).end();

View File

@ -16,12 +16,16 @@ module.exports = function( grunt ) {
baseUrl: "src", baseUrl: "src",
name: "jquery", name: "jquery",
out: "dist/jquery.js", out: "dist/jquery.js",
// We have multiple minify steps // We have multiple minify steps
optimize: "none", optimize: "none",
// Include dependencies loaded with require // Include dependencies loaded with require
findNestedDependencies: true, findNestedDependencies: true,
// Avoid inserting define() placeholder // Avoid inserting define() placeholder
skipModuleInsertion: true, skipModuleInsertion: true,
// Avoid breaking semicolons inserted by r.js // Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true, skipSemiColonInsertion: true,
wrap: { wrap: {
@ -47,15 +51,17 @@ module.exports = function( grunt ) {
*/ */
function convert( name, path, contents ) { function convert( name, path, contents ) {
var amdName; var amdName;
// Convert var modules // Convert var modules
if ( /.\/var\//.test( path ) ) { if ( /.\/var\//.test( path ) ) {
contents = contents contents = contents
.replace( /define\([\w\W]*?return/, "var " + (/var\/([\w-]+)/.exec(name)[1]) + " =" ) .replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
.replace( rdefineEnd, "" ); .replace( rdefineEnd, "" );
// Sizzle treatment // Sizzle treatment
} else if ( /^sizzle$/.test( name ) ) { } else if ( /^sizzle$/.test( name ) ) {
contents = "var Sizzle =\n" + contents contents = "var Sizzle =\n" + contents
// Remove EXPOSE lines from Sizzle // Remove EXPOSE lines from Sizzle
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" ); .replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
@ -63,6 +69,7 @@ module.exports = function( grunt ) {
contents = contents contents = contents
.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" ) .replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )
// Multiple exports // Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" ); .replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
@ -82,13 +89,15 @@ module.exports = function( grunt ) {
contents = contents contents = contents
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" ); .replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
} }
// AMD Name // AMD Name
if ( (amdName = grunt.option( "amd" )) != null && /^exports\/amd$/.test( name ) ) { if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
if (amdName) { if ( amdName ) {
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName ); grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
} else { } else {
grunt.log.writeln( "AMD name now anonymous" ); grunt.log.writeln( "AMD name now anonymous" );
} }
// Remove the comma for anonymous defines // Remove the comma for anonymous defines
contents = contents contents = contents
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" ); .replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
@ -121,7 +130,8 @@ module.exports = function( grunt ) {
excludeList = function( list, prepend ) { excludeList = function( list, prepend ) {
if ( list ) { if ( list ) {
prepend = prepend ? prepend + "/" : ""; prepend = prepend ? prepend + "/" : "";
list.forEach(function( module ) { list.forEach( function( module ) {
// Exclude var modules as well // Exclude var modules as well
if ( module === "var" ) { if ( module === "var" ) {
excludeList( excludeList(
@ -130,20 +140,22 @@ module.exports = function( grunt ) {
return; return;
} }
if ( prepend ) { if ( prepend ) {
// Skip if this is not a js file and we're walking files in a dir // Skip if this is not a js file and we're walking files in a dir
if ( !(module = /([\w-\/]+)\.js$/.exec( module )) ) { if ( !( module = /([\w-\/]+)\.js$/.exec( module ) ) ) {
return; return;
} }
// Prepend folder name if passed // Prepend folder name if passed
// Remove .js extension // Remove .js extension
module = prepend + module[1]; module = prepend + module[ 1 ];
} }
// Avoid infinite recursion // Avoid infinite recursion
if ( excluded.indexOf( module ) === -1 ) { if ( excluded.indexOf( module ) === -1 ) {
excluder( "-" + module ); excluder( "-" + module );
} }
}); } );
} }
}, },
/** /**
@ -158,12 +170,15 @@ module.exports = function( grunt ) {
module = m[ 2 ]; module = m[ 2 ];
if ( exclude ) { if ( exclude ) {
// Can't exclude certain modules // Can't exclude certain modules
if ( minimum.indexOf( module ) === -1 ) { if ( minimum.indexOf( module ) === -1 ) {
// Add to excluded // Add to excluded
if ( excluded.indexOf( module ) === -1 ) { if ( excluded.indexOf( module ) === -1 ) {
grunt.log.writeln( flag ); grunt.log.writeln( flag );
excluded.push( module ); excluded.push( module );
// Exclude all files in the folder of the same name // Exclude all files in the folder of the same name
// These are the removable dependencies // These are the removable dependencies
// It's fine if the directory is not there // It's fine if the directory is not there
@ -173,10 +188,11 @@ module.exports = function( grunt ) {
grunt.verbose.writeln( e ); grunt.verbose.writeln( e );
} }
} }
// Check removeWith list // Check removeWith list
excludeList( removeWith[ module ] ); excludeList( removeWith[ module ] );
} else { } else {
grunt.log.error( "Module \"" + module + "\" is a minimum requirement."); grunt.log.error( "Module \"" + module + "\" is a minimum requirement." );
if ( module === "selector" ) { if ( module === "selector" ) {
grunt.log.error( grunt.log.error(
"If you meant to replace Sizzle, use -sizzle instead." "If you meant to replace Sizzle, use -sizzle instead."
@ -215,13 +231,13 @@ module.exports = function( grunt ) {
// Handle Sizzle exclusion // Handle Sizzle exclusion
// Replace with selector-native // Replace with selector-native
if ( (index = excluded.indexOf( "sizzle" )) > -1 ) { if ( ( index = excluded.indexOf( "sizzle" ) ) > -1 ) {
config.rawText.selector = "define(['./selector-native']);"; config.rawText.selector = "define(['./selector-native']);";
excluded.splice( index, 1 ); excluded.splice( index, 1 );
} }
// Replace exports/global with a noop noConflict // Replace exports/global with a noop noConflict
if ( (index = excluded.indexOf( "exports/global" )) > -1 ) { if ( ( index = excluded.indexOf( "exports/global" ) ) > -1 ) {
config.rawText[ "exports/global" ] = "define(['../core']," + config.rawText[ "exports/global" ] = "define(['../core']," +
"function( jQuery ) {\njQuery.noConflict = function() {};\n});"; "function( jQuery ) {\njQuery.noConflict = function() {};\n});";
excluded.splice( index, 1 ); excluded.splice( index, 1 );
@ -233,9 +249,11 @@ module.exports = function( grunt ) {
// append excluded modules to version // append excluded modules to version
if ( excluded.length ) { if ( excluded.length ) {
version += " -" + excluded.join( ",-" ); version += " -" + excluded.join( ",-" );
// set pkg.version to version with excludes, so minified file picks it up // set pkg.version to version with excludes, so minified file picks it up
grunt.config.set( "pkg.version", version ); grunt.config.set( "pkg.version", version );
grunt.verbose.writeln( "Version changed to " + version ); grunt.verbose.writeln( "Version changed to " + version );
// Have to use shallow or core will get excluded since it is a dependency // Have to use shallow or core will get excluded since it is a dependency
config.excludeShallow = excluded; config.excludeShallow = excluded;
} }
@ -247,8 +265,10 @@ module.exports = function( grunt ) {
*/ */
config.out = function( compiled ) { config.out = function( compiled ) {
compiled = compiled compiled = compiled
// Embed Version // Embed Version
.replace( /@VERSION/g, version ) .replace( /@VERSION/g, version )
// Embed Date // Embed Date
// yyyy-mm-ddThh:mmZ // yyyy-mm-ddThh:mmZ
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) ); .replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
@ -259,9 +279,10 @@ module.exports = function( grunt ) {
// Turn off opt-in if necessary // Turn off opt-in if necessary
if ( !optIn ) { if ( !optIn ) {
// Overwrite the default inclusions with the explicit ones provided // Overwrite the default inclusions with the explicit ones provided
config.rawText.jquery = "define([" + config.rawText.jquery = "define([" +
(included.length ? included.join(",") : "") + ( included.length ? included.join( "," ) : "" ) +
"]);"; "]);";
} }
@ -272,8 +293,8 @@ module.exports = function( grunt ) {
done(); done();
}, function( err ) { }, function( err ) {
done( err ); done( err );
}); } );
}); } );
// Special "alias" task to make custom build creation less grawlix-y // Special "alias" task to make custom build creation less grawlix-y
// Translation example // Translation example
@ -289,6 +310,6 @@ module.exports = function( grunt ) {
grunt.log.writeln( "Creating custom build...\n" ); grunt.log.writeln( "Creating custom build...\n" );
grunt.task.run([ "build:*:*" + (modules ? ":" + modules : ""), "uglify", "dist" ]); grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
}); } );
}; };

View File

@ -21,14 +21,14 @@ module.exports = function( grunt ) {
flags = Object.keys( this.flags ); flags = Object.keys( this.flags );
// Combine all output target paths // Combine all output target paths
paths = [].concat( stored, flags ).filter(function( path ) { paths = [].concat( stored, flags ).filter( function( path ) {
return path !== "*"; return path !== "*";
}); } );
// Ensure the dist files are pure ASCII // Ensure the dist files are pure ASCII
nonascii = false; nonascii = false;
distpaths.forEach(function( filename ) { distpaths.forEach( function( filename ) {
var i, c, var i, c,
text = fs.readFileSync( filename, "utf8" ); text = fs.readFileSync( filename, "utf8" );
@ -53,7 +53,7 @@ module.exports = function( grunt ) {
} }
// Optionally copy dist files to other locations // Optionally copy dist files to other locations
paths.forEach(function( path ) { paths.forEach( function( path ) {
var created; var created;
if ( !/\/$/.test( path ) ) { if ( !/\/$/.test( path ) ) {
@ -63,9 +63,9 @@ module.exports = function( grunt ) {
created = path + filename.replace( "dist/", "" ); created = path + filename.replace( "dist/", "" );
grunt.file.write( created, text ); grunt.file.write( created, text );
grunt.log.writeln( "File '" + created + "' created." ); grunt.log.writeln( "File '" + created + "' created." );
}); } );
}); } );
return !nonascii; return !nonascii;
}); } );
}; };

View File

@ -23,5 +23,5 @@ module.exports = function( grunt ) {
args: [ "install", "jsdom@" + version ], args: [ "install", "jsdom@" + version ],
opts: { stdio: "inherit" } opts: { stdio: "inherit" }
}, this.async() ); }, this.async() );
}); } );
}; };

View File

@ -3,11 +3,12 @@ var fs = require( "fs" );
module.exports = function( grunt ) { module.exports = function( grunt ) {
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ]; var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
grunt.registerTask( "remove_map_comment", function() { grunt.registerTask( "remove_map_comment", function() {
// Remove the source map comment; it causes way too many problems. // Remove the source map comment; it causes way too many problems.
// The map file is still generated for manual associations // The map file is still generated for manual associations
// https://github.com/jquery/jquery/issues/1707 // https://github.com/jquery/jquery/issues/1707
var text = fs.readFileSync( minLoc, "utf8" ) var text = fs.readFileSync( minLoc, "utf8" )
.replace( /\/\/# sourceMappingURL=\S+/, "" ); .replace( /\/\/# sourceMappingURL=\S+/, "" );
fs.writeFileSync( minLoc, text ); fs.writeFileSync( minLoc, text );
}); } );
}; };

View File

@ -14,11 +14,12 @@ module.exports = function( grunt ) {
config = grunt.file.readJSON( configFile )[ projectName ]; config = grunt.file.readJSON( configFile )[ projectName ];
browserSets = browserSets || config.browserSets; browserSets = browserSets || config.browserSets;
if ( browserSets[ 0 ] === "[" ) { if ( browserSets[ 0 ] === "[" ) {
// We got an array, parse it // We got an array, parse it
browserSets = JSON.parse( browserSets ); browserSets = JSON.parse( browserSets );
} }
timeout = timeout || 1000 * 60 * 15; timeout = timeout || 1000 * 60 * 15;
tests = grunt.config([ this.name, "tests" ]); tests = grunt.config( [ this.name, "tests" ] );
if ( pull ) { if ( pull ) {
jobName = "Pull <a href='https://github.com/jquery/jquery/pull/" + jobName = "Pull <a href='https://github.com/jquery/jquery/pull/" +
@ -28,18 +29,18 @@ module.exports = function( grunt ) {
commit + "'>" + commit.substr( 0, 10 ) + "</a>"; commit + "'>" + commit.substr( 0, 10 ) + "</a>";
} }
tests.forEach(function( test ) { tests.forEach( function( test ) {
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test; runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
}); } );
testswarm.createClient({ testswarm.createClient( {
url: config.swarmUrl url: config.swarmUrl
} ) } )
.addReporter( testswarm.reporters.cli ) .addReporter( testswarm.reporters.cli )
.auth( { .auth( {
id: config.authUsername, id: config.authUsername,
token: config.authToken token: config.authToken
}) } )
.addjob( .addjob(
{ {
name: jobName, name: jobName,
@ -54,5 +55,5 @@ module.exports = function( grunt ) {
done( passed ); done( passed );
} }
); );
}); } );
}; };

View File

@ -32,10 +32,10 @@
"grunt-cli": "0.1.13", "grunt-cli": "0.1.13",
"grunt-compare-size": "0.4.0", "grunt-compare-size": "0.4.0",
"grunt-contrib-jshint": "0.11.2", "grunt-contrib-jshint": "0.11.2",
"grunt-contrib-uglify": "0.7.0", "grunt-contrib-uglify": "0.9.1",
"grunt-contrib-watch": "0.6.1", "grunt-contrib-watch": "0.6.1",
"grunt-git-authors": "2.0.1", "grunt-git-authors": "2.0.1",
"grunt-jscs-checker": "0.8.1", "grunt-jscs": "2.1.0",
"grunt-jsonlint": "1.0.4", "grunt-jsonlint": "1.0.4",
"grunt-npmcopy": "0.1.0", "grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2", "gzip-js": "0.3.2",

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
@ -15,6 +15,7 @@ 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)$/,
@ -61,16 +62,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 );
} }
} }
} }
@ -97,7 +100,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
} else if ( seekingTransport ) { } else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport ); return !( selected = dataTypeOrTransport );
} }
}); } );
return selected; return selected;
} }
@ -113,7 +116,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 ) {
@ -137,7 +140,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
while ( dataTypes[ 0 ] === "*" ) { while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift(); dataTypes.shift();
if ( ct === undefined ) { if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type"); ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
} }
} }
@ -155,9 +158,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
if ( dataTypes[ 0 ] in responses ) { if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ]; finalDataType = dataTypes[ 0 ];
} else { } else {
// Try convertible dataTypes // Try convertible dataTypes
for ( type in responses ) { for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type; finalDataType = type;
break; break;
} }
@ -165,6 +169,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
firstDataType = type; firstDataType = type;
} }
} }
// Or just use first one // Or just use first one
finalDataType = finalDataType || firstDataType; finalDataType = finalDataType || firstDataType;
} }
@ -186,6 +191,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();
@ -238,6 +244,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
conv = converters[ prev + " " + tmp[ 0 ] ] || conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ]; converters[ "* " + tmp[ 0 ] ];
if ( conv ) { if ( conv ) {
// Condense equivalence converters // Condense equivalence converters
if ( conv === true ) { if ( conv === true ) {
conv = converters[ conv2 ]; conv = converters[ conv2 ];
@ -257,7 +264,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( conv !== true ) { if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them // Unless errors are allowed to bubble, catch and return them
if ( conv && s[ "throws" ] ) { if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
response = conv( response ); response = conv( response );
} else { } else {
try { try {
@ -277,7 +284,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,
@ -382,40 +389,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,
// Url cleanup var // Url cleanup var
urlAnchor, 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 && globalEventContext = s.context &&
( callbackContext.nodeType || callbackContext.jquery ) ? ( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery( callbackContext ) : jQuery( callbackContext ) :
jQuery.event, jQuery.event,
// Deferreds // Deferreds
deferred = jQuery.Deferred(), deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks("once memory"), completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks // Status-dependent callbacks
statusCode = s.statusCode || {}, statusCode = s.statusCode || {},
// Headers (they are sent all at once) // Headers (they are sent all at once)
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {}, requestHeadersNames = {},
// The jqXHR state // The jqXHR state
state = 0, state = 0,
// Default abort message // Default abort message
strAbort = "canceled", strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
readyState: 0, readyState: 0,
@ -426,8 +448,8 @@ jQuery.extend({
if ( state === 2 ) { if ( state === 2 ) {
if ( !responseHeaders ) { if ( !responseHeaders ) {
responseHeaders = {}; responseHeaders = {};
while ( (match = rheaders.exec( responseHeadersString )) ) { while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
} }
} }
match = responseHeaders[ key.toLowerCase() ]; match = responseHeaders[ key.toLowerCase() ];
@ -464,10 +486,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 ] );
} }
@ -510,12 +534,14 @@ jQuery.extend({
// IE throws exception if url is malformed, e.g. http://example.com:80x/ // IE throws exception if url is malformed, e.g. http://example.com:80x/
try { try {
urlAnchor.href = s.url; urlAnchor.href = s.url;
// Support: IE8-11+ // Support: IE8-11+
// Anchor's host property isn't correctly set when s.url is relative // Anchor's host property isn't correctly set when s.url is relative
urlAnchor.href = urlAnchor.href; urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host; urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) { } catch ( e ) {
// If there is an error parsing the URL, assume it is crossDomain, // If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid // it can be rejected by the transport if it is invalid
s.crossDomain = true; s.crossDomain = true;
@ -541,7 +567,7 @@ jQuery.extend({
// Watch for a new set of requests // Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) { if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger("ajaxStart"); jQuery.event.trigger( "ajaxStart" );
} }
// Uppercase the type // Uppercase the type
@ -560,6 +586,7 @@ jQuery.extend({
// If data is available, append data to url // If data is available, append data to url
if ( s.data ) { if ( s.data ) {
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
// #9682: remove data so that it's not used in an eventual retry // #9682: remove data so that it's not used in an eventual retry
delete s.data; delete s.data;
} }
@ -594,8 +621,8 @@ jQuery.extend({
// Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader( jqXHR.setRequestHeader(
"Accept", "Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[0] ] + s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ] s.accepts[ "*" ]
); );
@ -642,8 +669,8 @@ jQuery.extend({
// Timeout // Timeout
if ( s.async && s.timeout > 0 ) { if ( s.async && s.timeout > 0 ) {
timeoutTimer = window.setTimeout(function() { timeoutTimer = window.setTimeout( function() {
jqXHR.abort("timeout"); jqXHR.abort( "timeout" );
}, s.timeout ); }, s.timeout );
} }
@ -651,9 +678,11 @@ jQuery.extend({
state = 1; state = 1;
transport.send( requestHeaders, done ); transport.send( requestHeaders, done );
} catch ( e ) { } catch ( e ) {
// Propagate exception as error if not done // Propagate exception as error if not done
if ( state < 2 ) { if ( state < 2 ) {
done( -1, e ); done( -1, e );
// Simply rethrow otherwise // Simply rethrow otherwise
} else { } else {
throw e; throw e;
@ -705,11 +734,11 @@ jQuery.extend({
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) { if ( s.ifModified ) {
modified = jqXHR.getResponseHeader("Last-Modified"); modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) { if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified; jQuery.lastModified[ cacheURL ] = modified;
} }
modified = jqXHR.getResponseHeader("etag"); modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) { if ( modified ) {
jQuery.etag[ cacheURL ] = modified; jQuery.etag[ cacheURL ] = modified;
} }
@ -731,6 +760,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 ) {
@ -766,9 +796,10 @@ jQuery.extend({
if ( fireGlobals ) { if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter // Handle the global AJAX counter
if ( !( --jQuery.active ) ) { if ( !( --jQuery.active ) ) {
jQuery.event.trigger("ajaxStop"); jQuery.event.trigger( "ajaxStop" );
} }
} }
} }
@ -783,10 +814,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;
@ -795,7 +827,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
} }
// The url can be an options object (which then must have .url) // The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend({ return jQuery.ajax( jQuery.extend( {
url: url, url: url,
type: method, type: method,
dataType: type, dataType: type,
@ -803,7 +835,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
success: callback success: callback
}, jQuery.isPlainObject( url ) && url ) ); }, 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 ) {
@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
"url" : "url" :
typeof s.data === "string" && typeof s.data === "string" &&
( s.contentType || "" ) ( s.contentType || "" )
.indexOf("application/x-www-form-urlencoded") === 0 && .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data" rjsonp.test( s.data ) && "data"
); );
@ -46,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
@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}; };
// Clean-up function (fires after converters) // Clean-up function (fires after converters)
jqXHR.always(function() { jqXHR.always( function() {
// If previous value didn't exist - remove it // If previous value didn't exist - remove it
if ( overwritten === undefined ) { if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName ); jQuery( window ).removeProp( callbackName );
@ -75,10 +76,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
// Save back as free // Save back as free
if ( s[ callbackName ] ) { if ( s[ callbackName ] ) {
// make sure that re-using the options doesn't screw things around
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback; s.jsonpCallback = originalSettings.jsonpCallback;
// save the callback name for future use // Save the callback name for future use
oldCallbacks.push( callbackName ); oldCallbacks.push( callbackName );
} }
@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
} }
responseContainer = overwritten = undefined; responseContainer = overwritten = undefined;
}); } );
// Delegate to script // Delegate to script
return "script"; return "script";
} }
}); } );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../core/parseHTML", "../core/parseHTML",
"../ajax", "../ajax",
@ -13,7 +13,7 @@ define([
jQuery.fn.load = function( url, params, callback ) { 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 > -1 ) { if ( off > -1 ) {
selector = jQuery.trim( url.slice( off ) ); selector = jQuery.trim( url.slice( off ) );
@ -34,7 +34,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If we have elements to modify, make the request // If we have elements to modify, make the request
if ( self.length > 0 ) { if ( self.length > 0 ) {
jQuery.ajax({ jQuery.ajax( {
url: url, url: url,
// If "type" variable is undefined, then "GET" method will be used. // If "type" variable is undefined, then "GET" method will be used.
@ -43,7 +43,7 @@ jQuery.fn.load = function( url, params, callback ) {
type: type || "GET", type: type || "GET",
dataType: "html", dataType: "html",
data: params data: params
}).done(function( responseText ) { } ).done( function( responseText ) {
// Save response for use in complete callback // Save response for use in complete callback
response = arguments; response = arguments;
@ -52,7 +52,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If a selector was specified, locate the right elements in a dummy div // If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors // Exclude scripts to avoid IE 'Permission Denied' errors
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result // Otherwise use the full result
responseText ); responseText );
@ -60,14 +60,14 @@ jQuery.fn.load = function( url, params, callback ) {
// If the request succeeds, this function gets "data", "status", "jqXHR" // If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above. // but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error" // If it fails, this function gets "jqXHR", "status", "error"
}).always( callback && function( jqXHR, status ) { } ).always( callback && function( jqXHR, status ) {
self.each( function() { self.each( function() {
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] ); callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
}); } );
}); } );
} }
return this; return this;
}; };
}); } );

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,4 +1,4 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
@ -24,4 +24,4 @@ jQuery.parseXML = function( data ) {
return jQuery.parseXML; return jQuery.parseXML;
}); } );

View File

@ -1,11 +1,11 @@
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../ajax" "../ajax"
], function( jQuery, document ) { ], function( jQuery, document ) {
// Install script dataType // Install script dataType
jQuery.ajaxSetup({ jQuery.ajaxSetup( {
accepts: { accepts: {
script: "text/javascript, application/javascript, " + script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript" "application/ecmascript, application/x-ecmascript"
@ -19,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 ) {
@ -29,19 +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( {
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();
@ -62,6 +63,6 @@ jQuery.ajaxTransport( "script", function( s ) {
} }
}; };
} }
}); } );
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return window.location; return window.location;
}); } );

View File

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

View File

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

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/support", "../var/support",
"../ajax" "../ajax"
@ -11,8 +11,10 @@ jQuery.ajaxSettings.xhr = function() {
}; };
var xhrSuccessStatus = { var 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
@ -22,7 +24,7 @@ var xhrSuccessStatus = {
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;
// Cross domain only allowed if supported through XMLHttpRequest // Cross domain only allowed if supported through XMLHttpRequest
@ -57,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
@ -76,7 +78,8 @@ jQuery.ajaxTransport(function( options ) {
xhr.abort(); xhr.abort();
} else if ( type === "error" ) { } else if ( type === "error" ) {
complete( complete(
// file: protocol always yields status 0; see #8605, #14207
// File: protocol always yields status 0; see #8605, #14207
xhr.status, xhr.status,
xhr.statusText xhr.statusText
); );
@ -84,6 +87,7 @@ jQuery.ajaxTransport(function( options ) {
complete( complete(
xhrSuccessStatus[ xhr.status ] || xhr.status, xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText, xhr.statusText,
// Support: IE9 // Support: IE9
// Accessing binary-data responseText throws an exception // Accessing binary-data responseText throws an exception
// (#11426) // (#11426)
@ -99,15 +103,17 @@ jQuery.ajaxTransport(function( options ) {
// Listen to events // Listen to events
xhr.onload = callback(); xhr.onload = callback();
xhr.onerror = callback("error"); xhr.onerror = callback( "error" );
// Create the abort callback // Create the abort callback
callback = 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;
@ -122,6 +128,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,4 +1,4 @@
define([ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support", "./support",
@ -9,19 +9,19 @@ define([
var 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 ret, hooks, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
@ -91,7 +91,7 @@ jQuery.extend({
attrNames = value && value.match( rnotwhite ); attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) { if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[i++] ) ) { while ( ( name = attrNames[ i++ ] ) ) {
propName = jQuery.propFix[ name ] || name; propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870) // Boolean attributes get special treatment (#10870)
@ -105,12 +105,13 @@ jQuery.extend({
} }
} }
} }
}); } );
// 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 {
@ -125,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;
@ -135,6 +137,6 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
} }
return ret; return ret;
}; };
}); } );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite", "../var/rnotwhite",
"../data/var/dataPriv", "../data/var/dataPriv",
@ -11,7 +11,7 @@ function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || ""; return elem.getAttribute && elem.getAttribute( "class" ) || "";
} }
jQuery.fn.extend({ jQuery.fn.extend( {
addClass: function( value ) { addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue, var classes, elem, cur, curValue, clazz, j, finalValue,
proceed = typeof value === "string" && value, proceed = typeof value === "string" && value,
@ -19,12 +19,13 @@ jQuery.fn.extend({
len = this.length; len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) { if ( proceed ) {
// The disjunction here is for better compressibility (see removeClass) // The disjunction here is for better compressibility (see removeClass)
classes = ( value || "" ).match( rnotwhite ) || []; classes = ( value || "" ).match( rnotwhite ) || [];
@ -36,13 +37,13 @@ jQuery.fn.extend({
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 ( curValue !== finalValue ) { if ( curValue !== finalValue ) {
elem.setAttribute( "class", finalValue ); elem.setAttribute( "class", finalValue );
@ -61,9 +62,9 @@ jQuery.fn.extend({
len = this.length; len = this.length;
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) { return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
}); } );
} }
if ( proceed ) { if ( proceed ) {
classes = ( value || "" ).match( rnotwhite ) || []; classes = ( value || "" ).match( rnotwhite ) || [];
@ -78,7 +79,8 @@ jQuery.fn.extend({
if ( cur ) { if ( cur ) {
j = 0; j = 0;
while ( (clazz = classes[j++]) ) { while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances // Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) > -1 ) { while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " ); cur = cur.replace( " " + clazz + " ", " " );
@ -105,15 +107,15 @@ jQuery.fn.extend({
} }
if ( jQuery.isFunction( value ) ) { if ( jQuery.isFunction( value ) ) {
return this.each(function( i ) { return this.each( function( i ) {
jQuery( this ).toggleClass( jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ), value.call( this, i, getClass( this ), stateVal ),
stateVal stateVal
); );
}); } );
} }
return this.each(function() { return this.each( function() {
var className, i, self, classNames; var className, i, self, classNames;
if ( type === "string" ) { if ( type === "string" ) {
@ -138,7 +140,7 @@ jQuery.fn.extend({
className = getClass( this ); className = getClass( this );
if ( className ) { if ( className ) {
// store className if set // Store className if set
dataPriv.set( this, "__className__", className ); dataPriv.set( this, "__className__", className );
} }
@ -154,7 +156,7 @@ jQuery.fn.extend({
); );
} }
} }
}); } );
}, },
hasClass: function( selector ) { hasClass: function( selector ) {
@ -162,8 +164,8 @@ jQuery.fn.extend({
i = 0, i = 0,
l = this.length; l = this.length;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
if ( this[i].nodeType === 1 && if ( this[ i ].nodeType === 1 &&
( " " + getClass( this[i] ) + " " ).replace( rclass, " " ) ( " " + getClass( this[ i ] ) + " " ).replace( rclass, " " )
.indexOf( className ) > -1 .indexOf( className ) > -1
) { ) {
return true; return true;
@ -172,6 +174,6 @@ jQuery.fn.extend({
return false; return false;
} }
}); } );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../core/access", "../core/access",
"./support", "./support",
@ -7,19 +7,19 @@ define([
var rfocusable = /^(?:input|select|textarea|button)$/i; var rfocusable = /^(?:input|select|textarea|button)$/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({ jQuery.extend( {
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var ret, hooks, var ret, hooks,
nType = elem.nodeType; nType = elem.nodeType;
@ -67,7 +67,7 @@ jQuery.extend({
"for": "htmlFor", "for": "htmlFor",
"class": "className" "class": "className"
} }
}); } );
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
@ -81,7 +81,7 @@ if ( !support.optSelected ) {
}; };
} }
jQuery.each([ jQuery.each( [
"tabIndex", "tabIndex",
"readOnly", "readOnly",
"maxLength", "maxLength",
@ -94,6 +94,6 @@ jQuery.each([
"contentEditable" "contentEditable"
], function() { ], function() {
jQuery.propFix[ this.toLowerCase() ] = this; jQuery.propFix[ this.toLowerCase() ] = this;
}); } );
}); } );

View File

@ -1,9 +1,9 @@
define([ define( [
"../var/document", "../var/document",
"../var/support" "../var/support"
], function( document, 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" ) );
@ -29,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,25 +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 ] || hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ]; jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { if ( hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret; return ret;
} }
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// Handle most common string cases // 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;
} }
@ -34,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 ) {
@ -57,23 +62,24 @@ 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 ) {
// Support: IE<11 // Support: IE<11
// option.value not trimmed (#14858) // option.value not trimmed (#14858)
return jQuery.trim( elem.value ); return jQuery.trim( elem.value );
@ -97,6 +103,7 @@ jQuery.extend({
// IE8-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 ? ( support.optDisabled ?
!option.disabled : option.getAttribute( "disabled" ) === null ) && !option.disabled : option.getAttribute( "disabled" ) === null ) &&
@ -127,8 +134,9 @@ jQuery.extend({
while ( i-- ) { while ( i-- ) {
option = options[ i ]; option = options[ i ];
if ( (option.selected = if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1) ) { jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true; optionSet = true;
} }
} }
@ -141,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 ) > -1 ); return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
} }
} }
}; };
if ( !support.checkOn ) { if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) { jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute("value") === null ? "on" : elem.value; return elem.getAttribute( "value" ) === null ? "on" : elem.value;
}; };
} }
}); } );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/rnotwhite" "./var/rnotwhite"
], function( jQuery, rnotwhite ) { ], function( jQuery, rnotwhite ) {
@ -8,7 +8,7 @@ function createOptions( options ) {
var object = {}; var object = {};
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
object[ flag ] = true; object[ flag ] = true;
}); } );
return object; return object;
} }
@ -44,18 +44,25 @@ jQuery.Callbacks = function( options ) {
var // Flag to know if list is currently firing var // Flag to know if list is currently firing
firing, firing,
// Last fire value for non-forgettable lists // Last fire value for non-forgettable lists
memory, memory,
// Flag to know if list was already fired // Flag to know if list was already fired
fired, fired,
// Flag to prevent firing // Flag to prevent firing
locked, locked,
// Actual callback list // Actual callback list
list = [], list = [],
// Queue of execution data for repeatable lists // Queue of execution data for repeatable lists
queue = [], queue = [],
// Index of currently firing callback (modified by add/remove as needed) // Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1, firingIndex = -1,
// Fire callbacks // Fire callbacks
fire = function() { fire = function() {
@ -114,18 +121,19 @@ jQuery.Callbacks = function( options ) {
queue.push( memory ); queue.push( memory );
} }
(function add( args ) { ( function add( args ) {
jQuery.each( args, function( _, arg ) { jQuery.each( args, function( _, arg ) {
if ( jQuery.isFunction( arg ) ) { if ( jQuery.isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) { if ( !options.unique || !self.has( arg ) ) {
list.push( arg ); list.push( arg );
} }
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
// Inspect recursively // Inspect recursively
add( arg ); add( arg );
} }
}); } );
})( arguments ); } )( arguments );
if ( memory && !firing ) { if ( memory && !firing ) {
fire(); fire();
@ -146,7 +154,7 @@ jQuery.Callbacks = function( options ) {
firingIndex--; firingIndex--;
} }
} }
}); } );
return this; return this;
}, },
@ -221,4 +229,4 @@ jQuery.Callbacks = function( options ) {
}; };
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./var/arr", "./var/arr",
"./var/document", "./var/document",
"./var/slice", "./var/slice",
@ -16,6 +16,7 @@ var
// 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 );
@ -35,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,
@ -79,9 +81,9 @@ jQuery.fn = jQuery.prototype = {
}, },
map: function( callback ) { map: function( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) { return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem ); return callback.call( elem, i, elem );
})); } ) );
}, },
slice: function() { slice: function() {
@ -99,11 +101,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( null );
}, },
// For internal use only. // For internal use only.
@ -115,7 +117,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;
@ -130,7 +132,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 = {};
} }
@ -141,8 +143,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 ];
@ -154,15 +158,15 @@ jQuery.extend = jQuery.fn.extend = function() {
} }
// Recurse if we're merging plain objects or arrays // Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) || if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
(copyIsArray = jQuery.isArray(copy)) ) ) { ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
if ( copyIsArray ) { if ( copyIsArray ) {
copyIsArray = false; copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : []; clone = src && jQuery.isArray( src ) ? src : [];
} else { } else {
clone = src && jQuery.isPlainObject(src) ? src : {}; clone = src && jQuery.isPlainObject( src ) ? src : {};
} }
// Never move original objects, clone them // Never move original objects, clone them
@ -180,7 +184,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, "" ),
@ -194,7 +199,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,
@ -204,14 +209,16 @@ 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; return !jQuery.isArray( obj ) && ( obj - parseFloat( obj ) + 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
@ -242,9 +249,10 @@ jQuery.extend({
if ( obj == null ) { if ( obj == null ) {
return obj + ""; return obj + "";
} }
// Support: Android<4.0 (functionish RegExp) // Support: Android<4.0 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" : class2type[ toString.call( obj ) ] || "object" :
typeof obj; typeof obj;
}, },
@ -421,7 +429,7 @@ 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. // JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global // Defining this global in .jshintrc would create a danger of using the global
@ -434,10 +442,10 @@ if ( typeof Symbol === "function" ) {
/* jshint ignore: end */ /* jshint ignore: end */
// Populate the class2type map // Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), jQuery.each( "Boolean Number String Function Array Date RegExp Object Error".split( " " ),
function(i, name) { function( i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase(); class2type[ "[object " + name + "]" ] = name.toLowerCase();
}); } );
function isArrayLike( obj ) { function isArrayLike( obj ) {
@ -457,4 +465,4 @@ function isArrayLike( obj ) {
} }
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
@ -13,7 +13,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
if ( jQuery.type( key ) === "object" ) { if ( jQuery.type( key ) === "object" ) {
chainable = true; chainable = true;
for ( i in key ) { for ( i in key ) {
access( elems, fn, i, key[i], true, emptyGet, raw ); access( elems, fn, i, key[ i ], true, emptyGet, raw );
} }
// Sets one value // Sets one value
@ -25,6 +25,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
} }
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 = function( elems, fn, key, value, chainable, emptyGet, raw ) {
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 = function( elems, fn, key, value, chainable, emptyGet, raw ) {
// 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,5 +1,5 @@
// Initialize a jQuery object // Initialize a jQuery object
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"./var/rsingleTag", "./var/rsingleTag",
@ -23,13 +23,13 @@ var rootjQuery,
return this; return this;
} }
// init accepts an alternate rootjQuery // Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101) // so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery; root = root || rootjQuery;
// Handle HTML strings // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
if ( selector[0] === "<" && if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" && selector[ selector.length - 1 ] === ">" &&
selector.length >= 3 ) { selector.length >= 3 ) {
@ -41,23 +41,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 ] );
@ -73,11 +74,12 @@ var rootjQuery,
// HANDLE: $(#id) // HANDLE: $(#id)
} else { } else {
elem = document.getElementById( match[2] ); elem = document.getElementById( match[ 2 ] );
if ( elem ) { if ( elem ) {
// Inject the element directly into the jQuery object // Inject the element directly into the jQuery object
this[0] = elem; this[ 0 ] = elem;
this.length = 1; this.length = 1;
} }
return this; return this;
@ -95,7 +97,7 @@ var rootjQuery,
// HANDLE: $(DOMElement) // HANDLE: $(DOMElement)
} else if ( selector.nodeType ) { } else if ( selector.nodeType ) {
this[0] = selector; this[ 0 ] = selector;
this.length = 1; this.length = 1;
return this; return this;
@ -104,6 +106,7 @@ var rootjQuery,
} else if ( jQuery.isFunction( selector ) ) { } else if ( jQuery.isFunction( selector ) ) {
return root.ready !== undefined ? return root.ready !== undefined ?
root.ready( selector ) : root.ready( selector ) :
// Execute immediately if ready is not present // Execute immediately if ready is not present
selector( jQuery ); selector( jQuery );
} }
@ -119,4 +122,4 @@ rootjQuery = jQuery( document );
return init; return init;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"./var/rsingleTag", "./var/rsingleTag",
@ -8,7 +8,7 @@ define([
"./support" "./support"
], function( jQuery, document, rsingleTag, buildFragment, support ) { ], function( jQuery, document, rsingleTag, buildFragment, support ) {
// data: string of html // Argument "data" should be string of html
// context (optional): If specified, the fragment will be created in this context, // context (optional): If specified, the fragment will be created in this context,
// defaults to document // defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string // keepScripts (optional): If true, will include scripts passed in the html string
@ -20,8 +20,9 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
keepScripts = context; keepScripts = context;
context = false; context = false;
} }
// document.implementation stops scripts or inline event handlers from
// being executed immediately // Stop scripts or inline event handlers from being executed immediately
// by using document.implementation
context = context || ( support.createHTMLDocument ? context = context || ( support.createHTMLDocument ?
document.implementation.createHTMLDocument( "" ) : document.implementation.createHTMLDocument( "" ) :
document ); document );
@ -31,7 +32,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
// Single tag // Single tag
if ( parsed ) { if ( parsed ) {
return [ context.createElement( parsed[1] ) ]; return [ context.createElement( parsed[ 1 ] ) ];
} }
parsed = buildFragment( [ data ], context, scripts ); parsed = buildFragment( [ data ], context, scripts );
@ -45,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
return jQuery.parseHTML; return jQuery.parseHTML;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../deferred" "../deferred"
@ -8,13 +8,15 @@ define([
var readyList; var readyList;
jQuery.fn.ready = function( fn ) { jQuery.fn.ready = function( fn ) {
// Add the callback // Add the callback
jQuery.ready.promise().done( fn ); jQuery.ready.promise().done( fn );
return this; return this;
}; };
jQuery.extend({ jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs. // Is the DOM ready to be used? Set to true once it occurs.
isReady: false, isReady: false,
@ -50,7 +52,7 @@ jQuery.extend({
// If there are functions bound, to execute // If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] ); readyList.resolveWith( document, [ jQuery ] );
} }
}); } );
/** /**
* The ready event handler and self cleanup method * The ready event handler and self cleanup method
@ -72,6 +74,7 @@ jQuery.ready.promise = function( obj ) {
// but it caused issues like the one // but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) { if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready ); window.setTimeout( jQuery.ready );
@ -90,4 +93,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

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

View File

@ -1,4 +1,5 @@
define(function() { define( function() {
// Match a standalone tag // Match a standalone tag
return (/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/); return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/pnum", "./var/pnum",
"./core/access", "./core/access",
@ -23,6 +23,7 @@ define([
isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) { isHidden, getStyles, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) {
var var
// Swappable if display is none or starts with table // Swappable if display is none or starts with table
// except "table", "table-cell", or "table-caption" // 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
@ -47,7 +48,7 @@ function vendorPropName( 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 ),
i = cssPrefixes.length; i = cssPrefixes.length;
while ( i-- ) { while ( i-- ) {
@ -61,6 +62,7 @@ function vendorPropName( name ) {
function setPositiveNumber( elem, value, subtract ) { function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value ); var matches = rnumsplit.exec( value );
return matches ? return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks // Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
value; value;
@ -68,20 +70,24 @@ function setPositiveNumber( elem, value, subtract ) {
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ? var i = extra === ( isBorderBox ? "border" : "content" ) ?
// If we already have the right measurement, avoid augmentation // If we already have the right measurement, avoid augmentation
4 : 4 :
// Otherwise initialize for horizontal or vertical properties // Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0, name === "width" ? 1 : 0,
val = 0; val = 0;
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// Both box models exclude margin, so add it if we want it // Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
} }
if ( isBorderBox ) { if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content // border-box includes padding, so remove it if we want content
if ( extra === "content" ) { if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
@ -92,6 +98,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 );
@ -131,6 +138,7 @@ function getWidthOrHeight( elem, name, extra ) {
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) { if ( val <= 0 || val == null ) {
// Fall back to computed then uncomputed css if necessary // Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
@ -138,7 +146,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;
} }
@ -163,7 +171,7 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px"; ) + "px";
} }
jQuery.extend({ jQuery.extend( {
// Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
// behavior of getting and setting a style property // behavior of getting and setting a style property
@ -226,8 +234,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 = rcssNum.exec( value )) && ret[ 1 ] ) { if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = adjustCSS( elem, name, ret ); value = adjustCSS( elem, name, ret );
// Fixes bug #9237 // Fixes bug #9237
type = "number"; type = "number";
} }
@ -249,16 +258,17 @@ 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) || if ( !hooks || !( "set" in hooks ) ||
(value = hooks.set( elem, value, extra )) !== undefined ) { ( 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 && if ( hooks && "get" in hooks &&
(ret = hooks.get( elem, false, extra )) !== undefined ) { ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret; return ret;
} }
@ -301,9 +311,9 @@ jQuery.extend({
} }
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 ) {
@ -311,6 +321,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
// 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" ) ) && return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
// Support: Safari 8+ // Support: Safari 8+
// Table columns in Safari have non-zero offsetWidth & zero // Table columns in Safari have non-zero offsetWidth & zero
// getBoundingClientRect().width unless display is changed. // getBoundingClientRect().width unless display is changed.
@ -320,7 +331,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
swap( elem, cssShow, function() { swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra ); return getWidthOrHeight( elem, name, extra );
}) : } ) :
getWidthOrHeight( elem, name, extra ); getWidthOrHeight( elem, name, extra );
} }
}, },
@ -338,7 +349,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
); );
} }
}; };
}); } );
// Support: Android 2.3 // Support: Android 2.3
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
@ -351,7 +362,7 @@ jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
); );
// 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"
@ -362,7 +373,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 ] =
@ -376,9 +387,9 @@ jQuery.each({
if ( !rmargin.test( prefix ) ) { if ( !rmargin.test( prefix ) ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
css: function( name, value ) { css: function( name, value ) {
return access( this, function( elem, name, value ) { return access( this, function( elem, name, value ) {
var styles, len, var styles, len,
@ -412,15 +423,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

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/rcssNum" "../var/rcssNum"
], function( jQuery, rcssNum ) { ], function( jQuery, rcssNum ) {
@ -12,11 +12,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
function() { return jQuery.css( elem, prop, "" ); }, function() { return jQuery.css( elem, prop, "" ); },
initial = currentValue(), initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches // Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) ); rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Trust units reported by jQuery.css // Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ]; unit = unit || initialInUnit[ 3 ];
@ -27,6 +29,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
initialInUnit = +initial || 1; initialInUnit = +initial || 1;
do { do {
// If previous iteration zeroed out, double until we get *something*. // If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below // Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5"; scale = scale || ".5";
@ -38,12 +41,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
// Update scale, tolerating zero or NaN from tween.cur() // Update scale, tolerating zero or NaN from tween.cur()
// Break the loop if scale is unchanged or perfect, or if we've just had enough. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
} while ( } while (
scale !== (scale = currentValue() / initial) && scale !== 1 && --maxIterations scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
); );
} }
if ( valueParts ) { if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0; initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified // Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ? adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
@ -58,4 +62,4 @@ function adjustCSS( elem, prop, valueParts, tween ) {
} }
return adjustCSS; return adjustCSS;
}); } );

View File

@ -1,10 +1,10 @@
define([ define( [
"../core", "../core",
"./var/rnumnonpx", "./var/rnumnonpx",
"./var/rmargin", "./var/rmargin",
"./var/getStyles", "./var/getStyles",
"./support", "./support",
"../selector" // contains "../selector" // Get jQuery.contains
], function( jQuery, rnumnonpx, rmargin, getStyles, support ) { ], function( jQuery, rnumnonpx, rmargin, getStyles, support ) {
function curCSS( elem, name, computed ) { function curCSS( elem, name, computed ) {
@ -46,6 +46,7 @@ function curCSS( elem, name, computed ) {
} }
return ret !== undefined ? return ret !== undefined ?
// Support: IE9-11+ // Support: IE9-11+
// IE returns zIndex value as an integer. // IE returns zIndex value as an integer.
ret + "" : ret + "" :
@ -53,4 +54,4 @@ function curCSS( elem, name, computed ) {
} }
return curCSS; return curCSS;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../selector" "../selector"
], function( jQuery ) { ], function( jQuery ) {
@ -10,4 +10,4 @@ jQuery.expr.filters.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
}; };
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../data/var/dataPriv" "../data/var/dataPriv"
], function( dataPriv ) { ], function( dataPriv ) {
@ -18,6 +18,7 @@ function showHide( elements, show ) {
display = elem.style.display; display = elem.style.display;
if ( show ) { if ( show ) {
if ( display === "none" ) { if ( display === "none" ) {
// Restore a pre-hide() value if we have one // Restore a pre-hide() value if we have one
values[ index ] = dataPriv.get( elem, "display" ) || ""; values[ index ] = dataPriv.get( elem, "display" ) || "";
} }
@ -44,4 +45,4 @@ function showHide( elements, show ) {
return showHide; return showHide;
}); } );

View File

@ -1,11 +1,11 @@
define([ define( [
"../core", "../core",
"../var/document", "../var/document",
"../var/documentElement", "../var/documentElement",
"../var/support" "../var/support"
], function( jQuery, document, documentElement, support ) { ], function( jQuery, document, documentElement, support ) {
(function() { ( function() {
var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
@ -29,6 +29,7 @@ define([
// 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 computeStyleTests() { function computeStyleTests() {
div.style.cssText = div.style.cssText =
// Support: Android 2.3 // Support: Android 2.3
// Vendor-prefix box-sizing // Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;box-sizing:border-box;" + "-webkit-box-sizing:border-box;box-sizing:border-box;" +
@ -49,6 +50,7 @@ define([
jQuery.extend( support, { jQuery.extend( support, {
pixelPosition: function() { 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.
@ -62,6 +64,7 @@ define([
return boxSizingReliableVal; return boxSizingReliableVal;
}, },
pixelMarginRight: function() { pixelMarginRight: function() {
// Support: Android 4.0-4.3 // Support: Android 4.0-4.3
// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
// since that compresses better and they're computed together anyway. // since that compresses better and they're computed together anyway.
@ -82,6 +85,7 @@ define([
// Reset CSS: box-sizing; display; margin; border; padding // Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText = marginDiv.style.cssText = div.style.cssText =
// Support: Android 2.3 // Support: Android 2.3
// Vendor-prefix box-sizing // Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" + "-webkit-box-sizing:content-box;box-sizing:content-box;" +
@ -97,9 +101,9 @@ define([
return ret; return ret;
} }
}); } );
})(); } )();
return support; return support;
}); } );

View File

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

View File

@ -1,4 +1,4 @@
define(function() { define( function() {
return function( elem ) { return function( elem ) {
// Support: IE<=11+, Firefox<=30+ (#15098, #14150) // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
@ -12,4 +12,4 @@ define(function() {
return view.getComputedStyle( elem ); return view.getComputedStyle( elem );
}; };
}); } );

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
define(function() { define( function() {
// A method for quickly swapping in/out CSS properties to get correct calculations. // A method for quickly swapping in/out CSS properties to get correct calculations.
return function( elem, options, callback, args ) { return function( elem, options, callback, args ) {
@ -21,4 +21,4 @@ return function( elem, options, callback, args ) {
return ret; return ret;
}; };
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./data/var/dataPriv", "./data/var/dataPriv",
@ -32,6 +32,7 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true : data = data === "true" ? true :
data === "false" ? false : data === "false" ? false :
data === "null" ? null : data === "null" ? null :
// Only convert to a number if it doesn't change the string // Only convert to a number if it doesn't change the string
+data + "" === data ? +data : +data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) : rbrace.test( data ) ? jQuery.parseJSON( data ) :
@ -47,7 +48,7 @@ function dataAttr( elem, key, data ) {
return data; return data;
} }
jQuery.extend({ jQuery.extend( {
hasData: function( elem ) { hasData: function( elem ) {
return dataUser.hasData( elem ) || dataPriv.hasData( elem ); return dataUser.hasData( elem ) || dataPriv.hasData( elem );
}, },
@ -69,9 +70,9 @@ jQuery.extend({
_removeData: function( elem, name ) { _removeData: function( elem, name ) {
dataPriv.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 ],
@ -91,7 +92,7 @@ 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 ] );
} }
} }
@ -105,9 +106,9 @@ jQuery.fn.extend({
// Sets multiple values // Sets multiple values
if ( typeof key === "object" ) { if ( typeof key === "object" ) {
return this.each(function() { return this.each( function() {
dataUser.set( this, key ); dataUser.set( this, key );
}); } );
} }
return access( this, function( value ) { return access( this, function( value ) {
@ -139,20 +140,20 @@ jQuery.fn.extend({
} }
// Set the data... // Set the data...
this.each(function() { this.each( function() {
// We always store the camelCased key // We always store the camelCased key
dataUser.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() {
dataUser.remove( this, key ); dataUser.remove( this, key );
}); } );
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/rnotwhite", "../var/rnotwhite",
"./accepts" "./accepts"
@ -29,7 +29,7 @@ Data.prototype = {
value: value, value: value,
writable: true, writable: true,
configurable: true configurable: true
}); } );
} }
return owner[ this.expando ]; return owner[ this.expando ];
}, },
@ -100,7 +100,7 @@ Data.prototype = {
return this.get( owner, key ); return this.get( owner, 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
@ -157,4 +157,4 @@ Data.prototype = {
}; };
return Data; return Data;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
@ -6,6 +6,7 @@ define([
* Determines whether an object can have data * Determines whether an object can have data
*/ */
jQuery.acceptData = function( owner ) { jQuery.acceptData = function( owner ) {
// Accepts only: // Accepts only:
// - Node // - Node
// - Node.ELEMENT_NODE // - Node.ELEMENT_NODE
@ -17,4 +18,4 @@ jQuery.acceptData = function( owner ) {
}; };
return jQuery.acceptData; return jQuery.acceptData;
}); } );

View File

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

View File

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

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/slice", "./var/slice",
"./callbacks" "./callbacks"
@ -11,18 +11,19 @@ function Thrower( ex ) {
throw ex; throw ex;
} }
jQuery.extend({ jQuery.extend( {
Deferred: function( func ) { Deferred: function( func ) {
var tuples = [ var tuples = [
// action, add listener, callbacks, // action, add listener, callbacks,
// ... .then handlers, argument index, [final state] // ... .then handlers, argument index, [final state]
[ "notify", "progress", jQuery.Callbacks("memory"), [ "notify", "progress", jQuery.Callbacks( "memory" ),
jQuery.Callbacks("memory"), 2 ], jQuery.Callbacks( "memory" ), 2 ],
[ "resolve", "done", jQuery.Callbacks("once memory"), [ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks("once memory"), 0, "resolved" ], jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"), [ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks("once memory"), 1, "rejected" ] jQuery.Callbacks( "once memory" ), 1, "rejected" ]
], ],
state = "pending", state = "pending",
promise = { promise = {
@ -36,19 +37,21 @@ jQuery.extend({
"catch": function( fn ) { "catch": function( fn ) {
return promise.then( null, fn ); return promise.then( null, fn );
}, },
// Keep pipe for back-compat // Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) { pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments; var fns = arguments;
return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) { jQuery.each( tuples, function( i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress) // Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify }) // deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve }) // deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject }) // deferred.fail(function() { bind to newDefer or newDefer.reject })
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()
@ -61,10 +64,10 @@ jQuery.extend({
fn ? [ returned ] : arguments fn ? [ returned ] : arguments
); );
} }
}); } );
}); } );
fns = null; fns = null;
}).promise(); } ).promise();
}, },
then: function( onFulfilled, onRejected, onProgress ) { then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0; var maxDepth = 0;
@ -105,6 +108,7 @@ jQuery.extend({
// Handle a returned thenable // Handle a returned thenable
if ( jQuery.isFunction( then ) ) { if ( jQuery.isFunction( then ) ) {
// Special processors (notify) just wait for resolution // Special processors (notify) just wait for resolution
if ( special ) { if ( special ) {
then.call( then.call(
@ -130,6 +134,7 @@ jQuery.extend({
// Handle all other returned values // Handle all other returned values
} else { } else {
// Only substitue handlers pass on context // Only substitue handlers pass on context
// and multiple values (non-spec behavior) // and multiple values (non-spec behavior)
if ( handler !== Identity ) { if ( handler !== Identity ) {
@ -156,6 +161,7 @@ jQuery.extend({
// https://promisesaplus.com/#point-61 // https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions // Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) { if ( depth + 1 >= maxDepth ) {
// Only substitue handlers pass on context // Only substitue handlers pass on context
// and multiple values (non-spec behavior) // and multiple values (non-spec behavior)
if ( handler !== Thrower ) { if ( handler !== Thrower ) {
@ -181,7 +187,8 @@ jQuery.extend({
}; };
} }
return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... ) // progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add( tuples[ 0 ][ 3 ].add(
resolve( resolve(
@ -215,8 +222,9 @@ jQuery.extend({
Thrower Thrower
) )
); );
}).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 ) {
@ -233,12 +241,13 @@ jQuery.extend({
// promise.progress = list.add // promise.progress = list.add
// promise.done = list.add // promise.done = list.add
// promise.fail = list.add // promise.fail = list.add
promise[ tuple[1] ] = list.add; promise[ tuple[ 1 ] ] = list.add;
// Handle state // Handle state
if ( stateString ) { if ( stateString ) {
list.add( list.add(
function() { function() {
// state = "resolved" (i.e., fulfilled) // state = "resolved" (i.e., fulfilled)
// state = "rejected" // state = "rejected"
state = stateString; state = stateString;
@ -261,16 +270,16 @@ jQuery.extend({
// deferred.notify = function() { deferred.notifyWith(...) } // deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) } // deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) } // deferred.reject = function() { deferred.rejectWith(...) }
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.notifyWith = list.fireWith // deferred.notifyWith = list.fireWith
// deferred.resolveWith = list.fireWith // deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith // deferred.rejectWith = list.fireWith
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 );
@ -320,14 +329,14 @@ jQuery.extend({
resolveContexts = new Array( length ); resolveContexts = new Array( length );
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && if ( resolveValues[ i ] &&
jQuery.isFunction( (method = resolveValues[ i ].promise) ) ) { jQuery.isFunction( ( method = resolveValues[ i ].promise ) ) ) {
method.call( resolveValues[ i ] ) method.call( resolveValues[ i ] )
.progress( updateFunc( i, progressContexts, progressValues ) ) .progress( updateFunc( i, progressContexts, progressValues ) )
.done( updateFunc( i, resolveContexts, resolveValues ) ) .done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( master.reject ); .fail( master.reject );
} else if ( resolveValues[ i ] && } else if ( resolveValues[ i ] &&
jQuery.isFunction( (method = resolveValues[ i ].then) ) ) { jQuery.isFunction( ( method = resolveValues[ i ].then ) ) ) {
method.call( method.call(
resolveValues[ i ], resolveValues[ i ],
@ -348,7 +357,7 @@ jQuery.extend({
return master.promise(); return master.promise();
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,2 +1,2 @@
define(function() { define( function() {
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./css" "./css"
@ -18,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
var doc; var doc;
if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
// isn't a whole lot we can do. See pull request at this URL for discussion: // isn't a whole lot we can do. See pull request at this URL for discussion:
// https://github.com/jquery/jquery/pull/764 // https://github.com/jquery/jquery/pull/764
@ -38,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 ) :
@ -45,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;
}); } );

81
src/effects.js vendored
View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rcssNum", "./var/rcssNum",
@ -34,9 +34,9 @@ function raf() {
// Animations created synchronously will run synchronously // Animations created synchronously will run synchronously
function createFxNow() { function createFxNow() {
window.setTimeout(function() { window.setTimeout( function() {
fxNow = undefined; fxNow = undefined;
}); } );
return ( fxNow = jQuery.now() ); return ( fxNow = jQuery.now() );
} }
@ -67,7 +67,7 @@ function createTween( value, prop, animation ) {
index = 0, index = 0,
length = collection.length; length = collection.length;
for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
if ( (tween = collection[ index ].call( animation, prop, value )) ) { if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// We're done with this property // We're done with this property
return tween; return tween;
@ -99,15 +99,16 @@ 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();
} }
}); } );
}); } );
} }
// Detect show/hide animations // Detect show/hide animations
@ -140,6 +141,7 @@ function defaultPrefilter( elem, props, opts ) {
// Restrict "overflow" and "display" styles during box animations // Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) { if ( isBox && elem.nodeType === 1 ) {
// Support: IE 9 - 11 // Support: IE 9 - 11
// Record all 3 overflow attributes because IE does not infer the shorthand // Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY // from identically-valued overflowX and overflowY
@ -163,9 +165,9 @@ function defaultPrefilter( elem, props, opts ) {
// Restore the original display value at the end of pure show/hide animations // Restore the original display value at the end of pure show/hide animations
if ( !propTween ) { if ( !propTween ) {
anim.done(function() { anim.done( function() {
style.display = restoreDisplay; style.display = restoreDisplay;
}); } );
if ( restoreDisplay == null ) { if ( restoreDisplay == null ) {
display = style.display; display = style.display;
restoreDisplay = display === "none" ? "" : display; restoreDisplay = display === "none" ? "" : display;
@ -178,11 +180,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 ];
}); } );
} }
// Implement show/hide animations // Implement show/hide animations
@ -210,7 +212,8 @@ function defaultPrefilter( elem, props, opts ) {
} }
/* jshint -W083 */ /* jshint -W083 */
anim.done(function() { anim.done( function() {
// The final step of a "hide" animation is actually hiding the element // The final step of a "hide" animation is actually hiding the element
if ( !hidden ) { if ( !hidden ) {
showHide( [ elem ] ); showHide( [ elem ] );
@ -219,7 +222,7 @@ function defaultPrefilter( elem, props, opts ) {
for ( prop in orig ) { for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] ); jQuery.style( elem, prop, orig[ prop ] );
} }
}); } );
} }
// Per-property setup // Per-property setup
@ -277,15 +280,17 @@ function Animation( elem, properties, options ) {
index = 0, index = 0,
length = Animation.prefilters.length, length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() { deferred = jQuery.Deferred().always( function() {
// Don't match elem in the :animated selector // Don't match elem in the :animated selector
delete tick.elem; delete tick.elem;
}), } ),
tick = function() { tick = function() {
if ( stopped ) { if ( stopped ) {
return false; return false;
} }
var currentTime = fxNow || createFxNow(), var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3 // Support: Android 2.3
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
@ -297,7 +302,7 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
} }
deferred.notifyWith( elem, [ animation, percent, remaining ]); deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) { if ( percent < 1 && length ) {
return remaining; return remaining;
@ -306,7 +311,7 @@ function Animation( elem, properties, options ) {
return false; return false;
} }
}, },
animation = deferred.promise({ animation = deferred.promise( {
elem: elem, elem: elem,
props: jQuery.extend( {}, properties ), props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, { opts: jQuery.extend( true, {
@ -326,6 +331,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;
@ -345,7 +351,7 @@ function Animation( elem, properties, options ) {
} }
return this; return this;
} }
}), } ),
props = animation.props; props = animation.props;
propFilter( props, animation.opts.specialEasing ); propFilter( props, animation.opts.specialEasing );
@ -372,7 +378,7 @@ function Animation( elem, properties, options ) {
elem: elem, elem: elem,
anim: animation, anim: animation,
queue: animation.opts.queue queue: animation.opts.queue
}) } )
); );
// attach callbacks from options // attach callbacks from options
@ -420,7 +426,7 @@ jQuery.Animation = jQuery.extend( Animation, {
Animation.prefilters.push( callback ); Animation.prefilters.push( callback );
} }
} }
}); } );
jQuery.speed = function( speed, easing, fn ) { jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
@ -461,19 +467,20 @@ 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 );
@ -504,7 +511,7 @@ 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,
@ -524,7 +531,7 @@ jQuery.fn.extend({
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && if ( timers[ index ].elem === this &&
(type == null || timers[ index ].queue === type) ) { ( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd ); timers[ index ].anim.stop( gotoEnd );
dequeue = false; dequeue = false;
@ -538,13 +545,13 @@ 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 = dataPriv.get( this ), data = dataPriv.get( this ),
queue = data[ type + "queue" ], queue = data[ type + "queue" ],
@ -579,24 +586,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" }
@ -604,7 +611,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() {
@ -616,6 +623,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 );
@ -659,9 +667,10 @@ jQuery.fx.stop = function() {
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 ) {
@ -71,10 +71,12 @@ 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.
@ -116,4 +118,4 @@ jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point // Back Compat <1.8 extension point
jQuery.fx.step = {}; jQuery.fx.step = {};
}); } );

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,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/rnotwhite", "./var/rnotwhite",
@ -39,8 +39,10 @@ function on( elem, types, selector, data, fn, one ) {
// Types can be a map of types/handlers // Types can be a map of types/handlers
if ( typeof types === "object" ) { if ( typeof types === "object" ) {
// ( types-Object, selector, data ) // ( types-Object, selector, data )
if ( typeof selector !== "string" ) { if ( typeof selector !== "string" ) {
// ( types-Object, data ) // ( types-Object, data )
data = data || selector; data = data || selector;
selector = undefined; selector = undefined;
@ -52,15 +54,18 @@ function on( elem, types, selector, data, fn, one ) {
} }
if ( data == null && fn == null ) { if ( data == null && fn == null ) {
// ( types, fn ) // ( types, fn )
fn = selector; fn = selector;
data = selector = undefined; data = selector = undefined;
} else if ( fn == null ) { } else if ( fn == null ) {
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
// ( types, selector, fn ) // ( types, selector, fn )
fn = data; fn = data;
data = undefined; data = undefined;
} else { } else {
// ( types, data, fn ) // ( types, data, fn )
fn = data; fn = data;
data = selector; data = selector;
@ -74,16 +79,18 @@ function on( elem, types, selector, data, fn, one ) {
if ( one === 1 ) { if ( one === 1 ) {
origFn = fn; origFn = fn;
fn = function( event ) { fn = function( event ) {
// Can use an empty set, since event contains the info // Can use an empty set, since event contains the info
jQuery().off( event ); jQuery().off( event );
return origFn.apply( this, arguments ); return origFn.apply( this, arguments );
}; };
// Use same guid so caller can remove using origFn // Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
} }
return elem.each( function() { return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector ); jQuery.event.add( this, types, fn, data, selector );
}); } );
} }
/* /*
@ -119,11 +126,12 @@ jQuery.event = {
} }
// Init the element's event structure and main handler, if this is the first // Init the element's event structure and main handler, if this is the first
if ( !(events = elemData.events) ) { if ( !( events = elemData.events ) ) {
events = elemData.events = {}; events = elemData.events = {};
} }
if ( !(eventHandle = elemData.handle) ) { if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) { eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and // Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded // when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
@ -135,9 +143,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 ) {
@ -154,7 +162,7 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {}; special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers // handleObj is passed to all event handlers
handleObj = jQuery.extend({ handleObj = jQuery.extend( {
type: type, type: type,
origType: origType, origType: origType,
data: data, data: data,
@ -162,11 +170,11 @@ 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;
@ -209,7 +217,7 @@ jQuery.event = {
special, handlers, type, namespaces, origType, special, handlers, type, namespaces, origType,
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
if ( !elemData || !(events = elemData.events) ) { if ( !elemData || !( events = elemData.events ) ) {
return; return;
} }
@ -217,9 +225,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ]; types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length; t = types.length;
while ( t-- ) { while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || []; tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[1]; type = origType = tmp[ 1 ];
namespaces = ( tmp[2] || "" ).split( "." ).sort(); namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element // Unbind all events (on this namespace, if provided) for the element
if ( !type ) { if ( !type ) {
@ -232,7 +240,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;
@ -279,7 +288,7 @@ jQuery.event = {
var i, cur, tmp, bubbleType, ontype, handle, special, var i, cur, tmp, bubbleType, ontype, handle, special,
eventPath = [ elem || document ], eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event, type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = tmp = elem = elem || document; cur = tmp = elem = elem || document;
@ -293,13 +302,14 @@ jQuery.event = {
return; return;
} }
if ( type.indexOf(".") > -1 ) { if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle() // Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split("."); namespaces = type.split( "." );
type = namespaces.shift(); type = namespaces.shift();
namespaces.sort(); namespaces.sort();
} }
ontype = type.indexOf(":") < 0 && "on" + type; ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string // Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ? event = event[ jQuery.expando ] ?
@ -308,9 +318,9 @@ jQuery.event = {
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3; event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join("."); event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ? event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null; null;
// Clean up the event in case it is being reused // Clean up the event in case it is being reused
@ -344,14 +354,14 @@ jQuery.event = {
} }
// Only add window if we got to document (e.g., not plain obj or detached DOM) // Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === (elem.ownerDocument || document) ) { if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window ); eventPath.push( tmp.defaultView || tmp.parentWindow || window );
} }
} }
// Fire handlers on the event path // Fire handlers on the event path
i = 0; i = 0;
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
event.type = i > 1 ? event.type = i > 1 ?
bubbleType : bubbleType :
@ -378,7 +388,8 @@ jQuery.event = {
// If nobody prevented the default action, do it now // If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) { if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && if ( ( !special._default ||
special._default.apply( eventPath.pop(), data ) === false ) &&
jQuery.acceptData( elem ) ) { jQuery.acceptData( elem ) ) {
// Call a native DOM method on the target with the same name name as the event. // Call a native DOM method on the target with the same name name as the event.
@ -419,7 +430,7 @@ jQuery.event = {
special = jQuery.event.special[ event.type ] || {}; special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event // Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event; args[ 0 ] = event;
event.delegateTarget = this; event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired // Call the preDispatch hook for the mapped type, and let it bail if desired
@ -432,11 +443,11 @@ jQuery.event = {
// Run delegates first; they may want to stop propagation beneath us // Run delegates first; they may want to stop propagation beneath us
i = 0; i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem; event.currentTarget = matched.elem;
j = 0; j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) { !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or 2) have namespace(s) // Triggered event must either 1) have no namespace, or 2) have namespace(s)
@ -446,11 +457,11 @@ jQuery.event = {
event.handleObj = handleObj; event.handleObj = handleObj;
event.data = handleObj.data; event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args ); handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) { if ( ret !== undefined ) {
if ( (event.result = ret) === false ) { if ( ( event.result = ret ) === false ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
@ -479,13 +490,13 @@ jQuery.event = {
// //
// Support: Firefox // Support: Firefox
// Avoid non-left-click bubbling in Firefox (#3861) // Avoid non-left-click bubbling in Firefox (#3861)
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { if ( delegateCount && cur.nodeType && ( !event.button || event.type !== "click" ) ) {
for ( ; cur !== this; cur = cur.parentNode || this ) { for ( ; cur !== this; cur = cur.parentNode || this ) {
// Don't check non-elements (#13208) // 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.nodeType === 1 && (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 ];
@ -503,7 +514,7 @@ jQuery.event = {
} }
} }
if ( matches.length ) { if ( matches.length ) {
handlerQueue.push({ elem: cur, handlers: matches }); handlerQueue.push( { elem: cur, handlers: matches } );
} }
} }
} }
@ -511,7 +522,7 @@ 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;
@ -519,12 +530,12 @@ jQuery.event = {
// Includes some event props shared by KeyEvent and MouseEvent // Includes some event props shared by KeyEvent and MouseEvent
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "), "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
fixHooks: {}, fixHooks: {},
keyHooks: { keyHooks: {
props: "char charCode key keyCode".split(" "), props: "char charCode key keyCode".split( " " ),
filter: function( event, original ) { filter: function( event, original ) {
// Add which for key events // Add which for key events
@ -538,7 +549,7 @@ jQuery.event = {
mouseHooks: { mouseHooks: {
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " +
"screenX screenY toElement" ).split(" "), "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;
@ -605,10 +616,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 ) {
@ -628,6 +641,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" ) ) {
@ -662,6 +676,7 @@ jQuery.event = {
{ {
type: type, type: type,
isSimulated: true isSimulated: true
// Previously, `originalEvent: {}` was set here, so stopPropagation call // Previously, `originalEvent: {}` was set here, so stopPropagation call
// would not be triggered on donor event, since in our own // would not be triggered on donor event, since in our own
// jQuery.event.stopPropagation function we had a check for existence of // jQuery.event.stopPropagation function we had a check for existence of
@ -694,8 +709,9 @@ jQuery.removeEvent = function( elem, 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 );
} }
@ -708,6 +724,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 :
@ -777,7 +794,7 @@ jQuery.Event.prototype = {
// Safari sends mouseenter too often; see: // Safari sends mouseenter too often; see:
// https://code.google.com/p/chromium/issues/detail?id=470258 // https://code.google.com/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well). // for the description of the bug (it existed in older Chrome versions as well).
jQuery.each({ jQuery.each( {
mouseenter: "mouseover", mouseenter: "mouseover",
mouseleave: "mouseout", mouseleave: "mouseout",
pointerenter: "pointerover", pointerenter: "pointerover",
@ -795,7 +812,7 @@ jQuery.each({
// For mousenter/leave call the handler if related is outside the target. // For mousenter/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;
@ -803,7 +820,7 @@ jQuery.each({
return ret; return ret;
} }
}; };
}); } );
// Support: Firefox // Support: Firefox
// Firefox doesn't have focus(in | out) events // Firefox doesn't have focus(in | out) events
@ -814,7 +831,7 @@ jQuery.each({
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) { if ( !support.focusin ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout // Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) { var handler = function( event ) {
@ -844,10 +861,10 @@ if ( !support.focusin ) {
} }
} }
}; };
}); } );
} }
jQuery.fn.extend({ jQuery.fn.extend( {
on: function( types, selector, data, fn ) { on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn ); return on( this, types, selector, data, fn );
@ -858,6 +875,7 @@ jQuery.fn.extend({
off: function( types, selector, fn ) { off: function( types, selector, fn ) {
var handleObj, type; var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) { if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event // ( event ) dispatched jQuery.Event
handleObj = types.handleObj; handleObj = types.handleObj;
jQuery( types.delegateTarget ).off( jQuery( types.delegateTarget ).off(
@ -870,6 +888,7 @@ jQuery.fn.extend({
return this; return this;
} }
if ( typeof types === "object" ) { if ( typeof types === "object" ) {
// ( types-object [, selector] ) // ( types-object [, selector] )
for ( type in types ) { for ( type in types ) {
this.off( type, selector, types[ type ] ); this.off( type, selector, types[ type ] );
@ -877,6 +896,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;
@ -884,23 +904,23 @@ jQuery.fn.extend({
if ( fn === false ) { if ( fn === false ) {
fn = returnFalse; fn = returnFalse;
} }
return this.each(function() { return this.each( function() {
jQuery.event.remove( this, types, fn, selector ); jQuery.event.remove( this, types, fn, selector );
}); } );
}, },
trigger: function( type, data ) { trigger: function( type, data ) {
return this.each(function() { return this.each( function() {
jQuery.event.trigger( type, data, this ); jQuery.event.trigger( type, data, this );
}); } );
}, },
triggerHandler: function( type, data ) { triggerHandler: function( type, data ) {
var elem = this[0]; var elem = this[ 0 ];
if ( elem ) { if ( elem ) {
return jQuery.event.trigger( type, data, elem, true ); return jQuery.event.trigger( type, data, elem, true );
} }
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,10 +1,10 @@
define([ define( [
"../core", "../core",
"../event" "../event"
], function( jQuery ) { ], function( jQuery ) {
// Attach a bunch of functions for handling common AJAX events // Attach a bunch of functions for handling common AJAX events
jQuery.each([ jQuery.each( [
"ajaxStart", "ajaxStart",
"ajaxStop", "ajaxStop",
"ajaxComplete", "ajaxComplete",
@ -15,6 +15,6 @@ jQuery.each([
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,11 @@
define([ define( [
"../core", "../core",
"../event" "../event"
], function( jQuery ) { ], function( jQuery ) {
jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " + jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu").split(" "), "change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( i, name ) { function( i, name ) {
// Handle event binding // Handle event binding
@ -14,9 +14,9 @@ jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " +
this.on( name, null, data, fn ) : this.on( name, null, data, fn ) :
this.trigger( name ); this.trigger( name );
}; };
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
hover: function( fnOver, fnOut ) { hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
}, },
@ -32,11 +32,12 @@ jQuery.fn.extend({
return this.on( types, selector, data, fn ); return this.on( types, selector, data, fn );
}, },
undelegate: function( selector, types, fn ) { undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] ) // ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ? return arguments.length === 1 ?
this.off( selector, "**" ) : this.off( selector, "**" ) :
this.off( types, selector || "**", fn ); this.off( types, selector || "**", fn );
} }
}); } );
}); } );

View File

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

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,4 +1,5 @@
var var
// Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
_jQuery = window.jQuery, _jQuery = window.jQuery,

6
src/jquery.js vendored
View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./selector", "./selector",
"./traversing", "./traversing",
@ -31,6 +31,6 @@ define([
"./exports/amd" "./exports/amd"
], function( jQuery ) { ], function( jQuery ) {
return (window.jQuery = window.$ = jQuery); return ( window.jQuery = window.$ = jQuery );
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/concat", "./var/concat",
"./var/push", "./var/push",
@ -28,6 +28,7 @@ define([
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,
rnoInnerhtml = /<(?:script|style|link)/i, rnoInnerhtml = /<(?:script|style|link)/i,
// checked="checked" or checked // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptTypeMasked = /^true\/(.*)/, rscriptTypeMasked = /^true\/(.*)/,
@ -45,7 +46,7 @@ function manipulationTarget( elem, content ) {
// 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 ) {
@ -54,7 +55,7 @@ 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;
@ -124,13 +125,13 @@ function domManip( collection, args, callback, ignored ) {
if ( isFunction || if ( isFunction ||
( l > 1 && typeof value === "string" && ( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) { !support.checkClone && rchecked.test( value ) ) ) {
return collection.each(function( index ) { return collection.each( function( index ) {
var self = collection.eq( index ); var self = collection.eq( index );
if ( isFunction ) { if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() ); args[ 0 ] = value.call( this, index, self.html() );
} }
domManip( self, args, callback, ignored ); domManip( self, args, callback, ignored );
}); } );
} }
if ( l ) { if ( l ) {
@ -157,6 +158,7 @@ function domManip( collection, args, callback, ignored ) {
// Keep references to cloned scripts for later restoration // Keep references to cloned scripts for later restoration
if ( hasScripts ) { if ( hasScripts ) {
// Support: Android<4.1, PhantomJS<2 // Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit // push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) ); jQuery.merge( scripts, getAll( node, "script" ) );
@ -180,6 +182,7 @@ function domManip( collection, args, callback, ignored ) {
jQuery.contains( doc, node ) ) { jQuery.contains( doc, node ) ) {
if ( node.src ) { if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present // Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) { if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src ); jQuery._evalUrl( node.src );
@ -201,7 +204,7 @@ function remove( elem, selector, keepData ) {
nodes = selector ? jQuery.filter( selector, elem ) : elem, nodes = selector ? jQuery.filter( selector, elem ) : elem,
i = 0; i = 0;
for ( ; (node = nodes[i]) != null; i++ ) { for ( ; ( node = nodes[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) { if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) ); jQuery.cleanData( getAll( node ) );
} }
@ -217,7 +220,7 @@ function remove( elem, selector, keepData ) {
return elem; return elem;
} }
jQuery.extend({ jQuery.extend( {
htmlPrefilter: function( html ) { htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" ); return html.replace( rxhtmlTag, "<$1></$2>" );
}, },
@ -269,9 +272,9 @@ jQuery.extend({
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 ( jQuery.acceptData( elem ) ) {
if ( (data = elem[ dataPriv.expando ] ) ) { if ( ( data = elem[ dataPriv.expando ] ) ) {
if ( data.events ) { if ( data.events ) {
for ( type in data.events ) { for ( type in data.events ) {
if ( special[ type ] ) { if ( special[ type ] ) {
@ -291,9 +294,9 @@ jQuery.extend({
} }
} }
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
detach: function( selector ) { detach: function( selector ) {
return remove( this, selector, true ); return remove( this, selector, true );
}, },
@ -306,11 +309,11 @@ jQuery.fn.extend({
return access( this, function( value ) { return access( this, function( value ) {
return value === undefined ? return value === undefined ?
jQuery.text( this ) : jQuery.text( this ) :
this.empty().each(function() { this.empty().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 );
}, },
@ -320,7 +323,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.appendChild( elem ); target.appendChild( elem );
} }
}); } );
}, },
prepend: function() { prepend: function() {
@ -329,7 +332,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem ); var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild ); target.insertBefore( elem, target.firstChild );
} }
}); } );
}, },
before: function() { before: function() {
@ -337,7 +340,7 @@ jQuery.fn.extend({
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this ); this.parentNode.insertBefore( elem, this );
} }
}); } );
}, },
after: function() { after: function() {
@ -345,14 +348,14 @@ jQuery.fn.extend({
if ( this.parentNode ) { if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling ); this.parentNode.insertBefore( elem, this.nextSibling );
} }
}); } );
}, },
empty: function() { empty: function() {
var elem, var elem,
i = 0; i = 0;
for ( ; (elem = this[i]) != null; i++ ) { for ( ; ( elem = this[ i ] ) != null; i++ ) {
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
// Prevent memory leaks // Prevent memory leaks
@ -370,9 +373,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 ) {
@ -431,9 +434,9 @@ jQuery.fn.extend({
// Force callback invocation // Force callback invocation
}, ignored ); }, ignored );
} }
}); } );
jQuery.each({ jQuery.each( {
appendTo: "append", appendTo: "append",
prependTo: "prepend", prependTo: "prepend",
insertBefore: "before", insertBefore: "before",
@ -458,7 +461,7 @@ jQuery.each({
return this.pushStack( ret ); return this.pushStack( ret );
}; };
}); } );
return jQuery; return jQuery;
}); } );

View File

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

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"./var/rtagName", "./var/rtagName",
"./var/rscriptType", "./var/rscriptType",
@ -23,6 +23,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
// Add nodes directly // Add nodes directly
if ( jQuery.type( elem ) === "object" ) { if ( jQuery.type( elem ) === "object" ) {
// Support: Android<4.1, PhantomJS<2 // Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit // push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
@ -98,4 +99,4 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
} }
return buildFragment; return buildFragment;
}); } );

View File

@ -1,8 +1,9 @@
define([ define( [
"../core" "../core"
], function( jQuery ) { ], function( jQuery ) {
function getAll( context, tag ) { function getAll( context, tag ) {
// Support: IE9-11+ // Support: IE9-11+
// Use typeof to avoid zero-argument method invocation on host objects (#15151) // Use typeof to avoid zero-argument method invocation on host objects (#15151)
var ret = typeof context.getElementsByTagName !== "undefined" ? var ret = typeof context.getElementsByTagName !== "undefined" ?
@ -17,4 +18,4 @@ function getAll( context, tag ) {
} }
return getAll; return getAll;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../data/var/dataPriv" "../data/var/dataPriv"
], function( dataPriv ) { ], function( dataPriv ) {
@ -17,4 +17,4 @@ function setGlobalEval( elems, refElements ) {
} }
return setGlobalEval; return setGlobalEval;
}); } );

View File

@ -1,9 +1,9 @@
define([ define( [
"../var/document", "../var/document",
"../var/support" "../var/support"
], function( document, support ) { ], function( document, support ) {
(function() { ( function() {
var fragment = document.createDocumentFragment(), var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ), div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" ); input = document.createElement( "input" );
@ -26,8 +26,8 @@ define([
// Make sure textarea (and checkbox) defaultValue is properly cloned // Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>"; div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
})(); } )();
return support; return support;
}); } );

View File

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

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return ( /^$|\/(?:java|ecma)script/i ); return ( /^$|\/(?:java|ecma)script/i );
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return ( /<([\w:-]+)/ ); return ( /<([\w:-]+)/ );
}); } );

View File

@ -1,4 +1,4 @@
define(function() { define( function() {
// We have to close these tags to support XHTML (#13200) // We have to close these tags to support XHTML (#13200)
var wrapMap = { var wrapMap = {
@ -32,4 +32,4 @@ wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.the
wrapMap.th = wrapMap.td; wrapMap.th = wrapMap.td;
return wrapMap; return wrapMap;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./core/access", "./core/access",
"./var/document", "./var/document",
@ -36,7 +36,7 @@ jQuery.offset = {
curCSSTop = jQuery.css( elem, "top" ); curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" ); curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) && calculatePosition = ( position === "absolute" || position === "fixed" ) &&
( curCSSTop + curCSSLeft ).indexOf("auto") > -1; ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
// Need to be able to calculate position if either // Need to be able to calculate position if either
// top or left is auto and position is either absolute or fixed // top or left is auto and position is either absolute or fixed
@ -72,15 +72,16 @@ jQuery.offset = {
} }
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
offset: function( options ) { offset: function( options ) {
// Preserve chaining for setter // Preserve chaining for setter
if ( arguments.length ) { if ( arguments.length ) {
return options === undefined ? return options === undefined ?
this : this :
this.each(function( i ) { this.each( function( i ) {
jQuery.offset.setOffset( this, options, i ); jQuery.offset.setOffset( this, options, i );
}); } );
} }
var docElem, win, rect, doc, var docElem, win, rect, doc,
@ -127,10 +128,12 @@ jQuery.fn.extend({
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
// because it is its only offset parent // because it is its only offset parent
if ( jQuery.css( elem, "position" ) === "fixed" ) { if ( jQuery.css( elem, "position" ) === "fixed" ) {
// Assume getBoundingClientRect is there when computed position is fixed // Assume getBoundingClientRect is there when computed position is fixed
offset = elem.getBoundingClientRect(); offset = elem.getBoundingClientRect();
} else { } else {
// Get *real* offsetParent // Get *real* offsetParent
offsetParent = this.offsetParent(); offsetParent = this.offsetParent();
@ -166,7 +169,7 @@ jQuery.fn.extend({
// //
// This logic, however, is not guaranteed and can change at any point in the future // This logic, however, is not guaranteed and can change at any point in the future
offsetParent: function() { offsetParent: function() {
return this.map(function() { return this.map( function() {
var offsetParent = this.offsetParent; var offsetParent = this.offsetParent;
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
@ -174,9 +177,9 @@ jQuery.fn.extend({
} }
return offsetParent || documentElement; return offsetParent || documentElement;
}); } );
} }
}); } );
// Create scrollLeft and scrollTop methods // Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
@ -201,7 +204,7 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
} }
}, method, val, arguments.length, null ); }, method, val, arguments.length, null );
}; };
}); } );
// Support: Safari<7-8+, Chrome<37-44+ // Support: Safari<7-8+, Chrome<37-44+
// Add the top/left cssHooks using jQuery.fn.position // Add the top/left cssHooks using jQuery.fn.position
@ -214,6 +217,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
computed = curCSS( elem, prop ); computed = curCSS( elem, prop );
// If curCSS returns percentage, fallback to offset // If curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ? return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" : jQuery( elem ).position()[ prop ] + "px" :
@ -221,7 +225,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
} }
} }
); );
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,11 +1,11 @@
define([ define( [
"./core", "./core",
"./data/var/dataPriv", "./data/var/dataPriv",
"./deferred", "./deferred",
"./callbacks" "./callbacks"
], function( jQuery, dataPriv ) { ], function( jQuery, dataPriv ) {
jQuery.extend({ jQuery.extend( {
queue: function( elem, type, data ) { queue: function( elem, type, data ) {
var queue; var queue;
@ -16,7 +16,7 @@ jQuery.extend({
// Speed up dequeue by getting out quickly if this is just a lookup // Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) { if ( data ) {
if ( !queue || jQuery.isArray( data ) ) { if ( !queue || jQuery.isArray( data ) ) {
queue = dataPriv.access( elem, type, jQuery.makeArray(data) ); queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
} else { } else {
queue.push( data ); queue.push( data );
} }
@ -64,14 +64,14 @@ jQuery.extend({
_queueHooks: function( elem, type ) { _queueHooks: function( elem, type ) {
var key = type + "queueHooks"; var key = type + "queueHooks";
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
empty: jQuery.Callbacks("once memory").add(function() { empty: jQuery.Callbacks( "once memory" ).add( function() {
dataPriv.remove( elem, [ type + "queue", key ] ); dataPriv.remove( elem, [ type + "queue", key ] );
}) } )
}); } );
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
queue: function( type, data ) { queue: function( type, data ) {
var setter = 2; var setter = 2;
@ -82,30 +82,31 @@ jQuery.fn.extend({
} }
if ( arguments.length < setter ) { if ( arguments.length < setter ) {
return jQuery.queue( this[0], type ); return jQuery.queue( this[ 0 ], type );
} }
return data === undefined ? return data === undefined ?
this : this :
this.each(function() { this.each( function() {
var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
// Ensure a hooks for this queue // Ensure a hooks for this queue
jQuery._queueHooks( this, type ); jQuery._queueHooks( this, type );
if ( type === "fx" && queue[0] !== "inprogress" ) { if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
} }
}); } );
}, },
dequeue: function( type ) { dequeue: function( type ) {
return this.each(function() { return this.each( function() {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
}); } );
}, },
clearQueue: function( type ) { clearQueue: function( type ) {
return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
}, },
// Get a promise resolved when queues of a certain type // Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default) // are emptied (fx is the type by default)
promise: function( type, obj ) { promise: function( type, obj ) {
@ -136,7 +137,7 @@ jQuery.fn.extend({
resolve(); resolve();
return defer.promise( obj ); return defer.promise( obj );
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../queue", "../queue",
"../effects" // Delay is optional because of this dependency "../effects" // Delay is optional because of this dependency
@ -15,8 +15,8 @@ jQuery.fn.delay = function( time, type ) {
hooks.stop = function() { hooks.stop = function() {
window.clearTimeout( timeout ); window.clearTimeout( timeout );
}; };
}); } );
}; };
return jQuery.fn.delay; return jQuery.fn.delay;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/document", "./var/document",
"./var/documentElement" "./var/documentElement"
@ -36,6 +36,7 @@ var hasDuplicate,
documentElement.oMatchesSelector || documentElement.oMatchesSelector ||
documentElement.msMatchesSelector, documentElement.msMatchesSelector,
sortOrder = function( a, b ) { sortOrder = function( a, b ) {
// Flag for duplicate removal // Flag for duplicate removal
if ( a === b ) { if ( a === b ) {
hasDuplicate = true; hasDuplicate = true;
@ -47,14 +48,15 @@ var hasDuplicate,
a.compareDocumentPosition( b ); a.compareDocumentPosition( b );
if ( compare ) { if ( compare ) {
// Disconnected nodes // Disconnected nodes
if ( compare & 1 ) { if ( compare & 1 ) {
// Choose the first element that is related to our document // Choose the first element that is related to our document
if ( a === document || jQuery.contains(document, a) ) { if ( a === document || jQuery.contains( document, a ) ) {
return -1; return -1;
} }
if ( b === document || jQuery.contains(document, b) ) { if ( b === document || jQuery.contains( document, b ) ) {
return 1; return 1;
} }
@ -78,7 +80,7 @@ var hasDuplicate,
results.sort( sortOrder ); results.sort( sortOrder );
if ( hasDuplicate ) { if ( hasDuplicate ) {
while ( (elem = results[i++]) ) { while ( ( elem = results[ i++ ] ) ) {
if ( elem === results[ i ] ) { if ( elem === results[ i ] ) {
j = duplicates.push( i ); j = duplicates.push( i );
} }
@ -91,7 +93,7 @@ var hasDuplicate,
return results; return results;
}; };
jQuery.extend({ jQuery.extend( {
find: function( selector, context, results, seed ) { find: function( selector, context, results, seed ) {
var elem, nodeType, var elem, nodeType,
i = 0; i = 0;
@ -105,18 +107,18 @@ jQuery.extend({
} }
// Early return if context is not an element or document // Early return if context is not an element or document
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) {
return []; return [];
} }
if ( seed ) { if ( seed ) {
while ( (elem = seed[i++]) ) { while ( ( elem = seed[ i++ ] ) ) {
if ( jQuery.find.matchesSelector(elem, selector) ) { if ( jQuery.find.matchesSelector( elem, selector ) ) {
results.push( elem ); results.push( elem );
} }
} }
} else { } else {
jQuery.merge( results, context.querySelectorAll(selector) ); jQuery.merge( results, context.querySelectorAll( selector ) );
} }
return results; return results;
@ -130,17 +132,21 @@ jQuery.extend({
nodeType = elem.nodeType; nodeType = elem.nodeType;
if ( !nodeType ) { if ( !nodeType ) {
// If no nodeType, this is expected to be an array // If no nodeType, this is expected to be an array
while ( (node = elem[i++]) ) { while ( ( node = elem[ i++ ] ) ) {
// Do not traverse comment nodes // Do not traverse comment nodes
ret += jQuery.text( node ); ret += jQuery.text( node );
} }
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
// Use textContent for elements // Use textContent for elements
return elem.textContent; return elem.textContent;
} else if ( nodeType === 3 || nodeType === 4 ) { } else if ( nodeType === 3 || nodeType === 4 ) {
return elem.nodeValue; return elem.nodeValue;
} }
// Do not include comment or processing instruction nodes // Do not include comment or processing instruction nodes
return ret; return ret;
@ -148,10 +154,10 @@ jQuery.extend({
contains: function( a, b ) { contains: function( a, b ) {
var adown = a.nodeType === 9 ? a.documentElement : a, var adown = a.nodeType === 9 ? a.documentElement : a,
bup = b && b.parentNode; bup = b && b.parentNode;
return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) ); return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) );
}, },
isXMLDoc: function( elem ) { isXMLDoc: function( elem ) {
return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML"; return ( elem.ownerDocument || elem ).documentElement.nodeName !== "HTML";
}, },
expr: { expr: {
attrHandle: {}, attrHandle: {},
@ -161,7 +167,7 @@ jQuery.extend({
needsContext: /^[\x20\t\r\n\f]*[>+~]/ needsContext: /^[\x20\t\r\n\f]*[>+~]/
} }
} }
}); } );
jQuery.extend( jQuery.find, { jQuery.extend( jQuery.find, {
matches: function( expr, elements ) { matches: function( expr, elements ) {
@ -173,6 +179,6 @@ jQuery.extend( jQuery.find, {
attr: function( elem, name ) { attr: function( elem, name ) {
return elem.getAttribute( name ); return elem.getAttribute( name );
} }
}); } );
}); } );

View File

@ -1,14 +1,14 @@
define([ define( [
"./core", "./core",
"sizzle" "sizzle"
], function( jQuery, Sizzle ) { ], function( jQuery, Sizzle ) {
jQuery.find = Sizzle; jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors; jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos; jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText; jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML; jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains; jQuery.contains = Sizzle.contains;
}); } );

View File

@ -1 +1 @@
define([ "./selector-sizzle" ], function() {}); define( [ "./selector-sizzle" ], function() {} );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./manipulation/var/rcheckableType", "./manipulation/var/rcheckableType",
"./core/init", "./core/init",
@ -16,13 +16,16 @@ function buildParams( prefix, obj, traditional, add ) {
var name; var name;
if ( jQuery.isArray( obj ) ) { if ( jQuery.isArray( obj ) ) {
// Serialize array item. // Serialize array item.
jQuery.each( obj, function( i, v ) { jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) { if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar. // Treat each array item as a scalar.
add( prefix, v ); add( prefix, v );
} else { } else {
// Item is non-scalar (array or object), encode its numeric index. // Item is non-scalar (array or object), encode its numeric index.
buildParams( buildParams(
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", prefix + "[" + ( typeof v === "object" ? i : "" ) + "]",
@ -31,15 +34,17 @@ function buildParams( prefix, obj, traditional, add ) {
add add
); );
} }
}); } );
} else if ( !traditional && jQuery.type( obj ) === "object" ) { } else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item. // Serialize object item.
for ( name in obj ) { for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
} }
} else { } else {
// Serialize scalar item. // Serialize scalar item.
add( prefix, obj ); add( prefix, obj );
} }
@ -51,6 +56,7 @@ jQuery.param = function( a, traditional ) {
var prefix, var prefix,
s = [], s = [],
add = function( key, value ) { add = function( key, value ) {
// If value is a function, invoke it and return its value // If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
@ -63,12 +69,14 @@ jQuery.param = function( a, traditional ) {
// If an array was passed in, assume that it is an array of form elements. // If an array was passed in, assume that it is an array of form elements.
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements // Serialize the form elements
jQuery.each( a, function() { jQuery.each( a, function() {
add( this.name, this.value ); add( this.name, this.value );
}); } );
} else { } else {
// If traditional, encode the "old" way (the way 1.3.2 or older // If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively. // did it), otherwise encode params recursively.
for ( prefix in a ) { for ( prefix in a ) {
@ -80,25 +88,26 @@ jQuery.param = function( a, traditional ) {
return s.join( "&" ).replace( r20, "+" ); return s.join( "&" ).replace( r20, "+" );
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
serialize: function() { serialize: function() {
return jQuery.param( this.serializeArray() ); return jQuery.param( this.serializeArray() );
}, },
serializeArray: function() { serializeArray: function() {
return this.map(function() { return this.map( function() {
// Can add propHook for "elements" to filter or add form elements // Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" ); var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this; return elements ? jQuery.makeArray( elements ) : this;
}) } )
.filter(function() { .filter( function() {
var type = this.type; var type = this.type;
// Use .is( ":disabled" ) so that fieldset[disabled] works // Use .is( ":disabled" ) so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) && return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) ); ( this.checked || !rcheckableType.test( type ) );
}) } )
.map(function( i, elem ) { .map( function( i, elem ) {
var val = jQuery( this ).val(); var val = jQuery( this ).val();
return val == null ? return val == null ?
@ -106,11 +115,11 @@ jQuery.fn.extend({
jQuery.isArray( val ) ? jQuery.isArray( val ) ?
jQuery.map( val, function( val ) { jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}) : } ) :
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}).get(); } ).get();
} }
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"./core", "./core",
"./var/indexOf", "./var/indexOf",
"./traversing/var/rneedsContext", "./traversing/var/rneedsContext",
@ -8,6 +8,7 @@ define([
], function( jQuery, indexOf, rneedsContext ) { ], function( jQuery, indexOf, rneedsContext ) {
var rparentsprev = /^(?:parents|prev(?:Until|All))/, var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// Methods guaranteed to produce a unique set when starting from a unique set // Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = { guaranteedUnique = {
children: true, children: true,
@ -16,12 +17,12 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
prev: true prev: true
}; };
jQuery.extend({ jQuery.extend( {
dir: function( elem, dir, until ) { dir: function( elem, dir, until ) {
var matched = [], var matched = [],
truncate = until !== undefined; truncate = until !== undefined;
while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) { if ( truncate && jQuery( elem ).is( until ) ) {
break; break;
@ -43,21 +44,21 @@ jQuery.extend({
return matched; return matched;
} }
}); } );
jQuery.fn.extend({ jQuery.fn.extend( {
has: function( target ) { has: function( target ) {
var targets = jQuery( target, this ), var targets = jQuery( target, this ),
l = targets.length; l = targets.length;
return this.filter(function() { return this.filter( function() {
var i = 0; var i = 0;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
if ( jQuery.contains( this, targets[i] ) ) { if ( jQuery.contains( this, targets[ i ] ) ) {
return true; return true;
} }
} }
}); } );
}, },
closest: function( selectors, context ) { closest: function( selectors, context ) {
@ -70,14 +71,15 @@ jQuery.fn.extend({
0; 0;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments // Always skip document fragments
if ( cur.nodeType < 11 && (pos ? if ( cur.nodeType < 11 && ( pos ?
pos.index(cur) > -1 : pos.index( cur ) > -1 :
// Don't pass non-elements to Sizzle // Don't pass non-elements to Sizzle
cur.nodeType === 1 && cur.nodeType === 1 &&
jQuery.find.matchesSelector(cur, selectors)) ) { jQuery.find.matchesSelector( cur, selectors ) ) ) {
matched.push( cur ); matched.push( cur );
break; break;
@ -119,17 +121,17 @@ jQuery.fn.extend({
addBack: function( selector ) { addBack: function( selector ) {
return this.add( selector == null ? return this.add( selector == null ?
this.prevObject : this.prevObject.filter(selector) this.prevObject : this.prevObject.filter( selector )
); );
} }
}); } );
function sibling( cur, dir ) { function sibling( cur, dir ) {
while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
return cur; return cur;
} }
jQuery.each({ jQuery.each( {
parent: function( elem ) { parent: function( elem ) {
var parent = elem.parentNode; var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null; return parent && parent.nodeType !== 11 ? parent : null;
@ -180,6 +182,7 @@ jQuery.each({
} }
if ( this.length > 1 ) { if ( this.length > 1 ) {
// Remove duplicates // Remove duplicates
if ( !guaranteedUnique[ name ] ) { if ( !guaranteedUnique[ name ] ) {
jQuery.uniqueSort( matched ); jQuery.uniqueSort( matched );
@ -193,7 +196,7 @@ jQuery.each({
return this.pushStack( matched ); return this.pushStack( matched );
}; };
}); } );
return jQuery; return jQuery;
}); } );

View File

@ -1,4 +1,4 @@
define([ define( [
"../core", "../core",
"../var/indexOf", "../var/indexOf",
"./var/rneedsContext", "./var/rneedsContext",
@ -13,14 +13,14 @@ function winnow( elements, qualifier, not ) {
return jQuery.grep( elements, function( elem, i ) { return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */ /* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not; return !!qualifier.call( elem, i, elem ) !== not;
}); } );
} }
if ( qualifier.nodeType ) { if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not; return ( elem === qualifier ) !== not;
}); } );
} }
@ -34,7 +34,7 @@ function winnow( elements, qualifier, not ) {
return jQuery.grep( elements, function( elem ) { return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not; return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
}); } );
} }
jQuery.filter = function( expr, elems, not ) { jQuery.filter = function( expr, elems, not ) {
@ -48,10 +48,10 @@ jQuery.filter = function( expr, elems, not ) {
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1; return elem.nodeType === 1;
})); } ) );
}; };
jQuery.fn.extend({ jQuery.fn.extend( {
find: function( selector ) { find: function( selector ) {
var i, var i,
len = this.length, len = this.length,
@ -59,13 +59,13 @@ jQuery.fn.extend({
self = this; self = this;
if ( typeof selector !== "string" ) { if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter(function() { return this.pushStack( jQuery( selector ).filter( function() {
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) { if ( jQuery.contains( self[ i ], this ) ) {
return true; return true;
} }
} }
}) ); } ) );
} }
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
@ -75,10 +75,10 @@ jQuery.fn.extend({
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret ); return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
}, },
filter: function( selector ) { filter: function( selector ) {
return this.pushStack( winnow(this, selector || [], false) ); return this.pushStack( winnow( this, selector || [], false ) );
}, },
not: function( selector ) { not: function( selector ) {
return this.pushStack( winnow(this, selector || [], true) ); return this.pushStack( winnow( this, selector || [], true ) );
}, },
is: function( selector ) { is: function( selector ) {
return !!winnow( return !!winnow(
@ -92,6 +92,6 @@ jQuery.fn.extend({
false false
).length; ).length;
} }
}); } );
}); } );

View File

@ -1,6 +1,6 @@
define([ define( [
"../../core", "../../core",
"../../selector" "../../selector"
], function( jQuery ) { ], function( jQuery ) {
return jQuery.expr.match.needsContext; return jQuery.expr.match.needsContext;
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return []; return [];
}); } );

View File

@ -1,4 +1,5 @@
define(function() { define( function() {
// [[Class]] -> type pairs // [[Class]] -> type pairs
return {}; return {};
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./arr" "./arr"
], function( arr ) { ], function( arr ) {
return arr.concat; return arr.concat;
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return window.document; return window.document;
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./document" "./document"
], function( document ) { ], function( document ) {
return document.documentElement; return document.documentElement;
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./class2type" "./class2type"
], function( class2type ) { ], function( class2type ) {
return class2type.hasOwnProperty; return class2type.hasOwnProperty;
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./arr" "./arr"
], function( arr ) { ], function( arr ) {
return arr.indexOf; return arr.indexOf;
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; return ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./arr" "./arr"
], function( arr ) { ], function( arr ) {
return arr.push; return arr.push;
}); } );

View File

@ -1,7 +1,7 @@
define([ define( [
"../var/pnum" "../var/pnum"
], function( pnum ) { ], function( pnum ) {
return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
}); } );

View File

@ -1,3 +1,3 @@
define(function() { define( function() {
return (/\S+/g); return ( /\S+/g );
}); } );

View File

@ -1,5 +1,5 @@
define([ define( [
"./arr" "./arr"
], function( arr ) { ], function( arr ) {
return arr.slice; return arr.slice;
}); } );

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