mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Build: Update jscs and lint files
Fixes gh-2056
This commit is contained in:
parent
7aa46e0df8
commit
10fdad742a
6
.jscsrc
6
.jscsrc
@ -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" ]
|
||||||
}
|
}
|
||||||
|
10
Gruntfile.js
10
Gruntfile.js
@ -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"
|
||||||
},
|
},
|
||||||
@ -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" ] );
|
||||||
};
|
};
|
||||||
|
@ -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();
|
||||||
|
@ -36,6 +36,7 @@ function makeReleaseCopies( Release ) {
|
|||||||
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"]
|
||||||
|
@ -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,6 +34,7 @@ function ensureSizzle( Release, callback ) {
|
|||||||
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 +
|
||||||
|
@ -38,7 +38,9 @@ http.request({
|
|||||||
console.log( "</ul>" );
|
console.log( "</ul>" );
|
||||||
}
|
}
|
||||||
cur = cat;
|
cur = cat;
|
||||||
console.log( "<h3>" + cat.charAt(0).toUpperCase() + cat.slice(1) + "</h3>" );
|
console.log(
|
||||||
|
"<h3>" + cat.charAt( 0 ).toUpperCase() + cat.slice( 1 ) + "</h3>"
|
||||||
|
);
|
||||||
console.log( "<ul>" );
|
console.log( "<ul>" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,6 +51,7 @@ 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
|
||||||
@ -56,6 +61,7 @@ module.exports = function( grunt ) {
|
|||||||
// 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,6 +89,7 @@ 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 ) {
|
||||||
@ -89,6 +97,7 @@ module.exports = function( grunt ) {
|
|||||||
} 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" : "" );
|
||||||
@ -122,6 +131,7 @@ module.exports = function( grunt ) {
|
|||||||
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,10 +140,12 @@ 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 ];
|
||||||
@ -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,6 +188,7 @@ 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 {
|
||||||
@ -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,6 +279,7 @@ 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( "," ) : "" ) +
|
||||||
|
@ -3,6 +3,7 @@ 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
|
||||||
|
@ -14,6 +14,7 @@ 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 );
|
||||||
}
|
}
|
||||||
|
@ -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",
|
||||||
|
34
src/ajax.js
34
src/ajax.js
@ -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,8 +62,10 @@ 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 ) || "*";
|
||||||
@ -155,6 +158,7 @@ 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 ] ] ) {
|
||||||
@ -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 {
|
||||||
@ -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,
|
||||||
@ -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;
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
@ -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,6 +796,7 @@ 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" );
|
||||||
@ -787,6 +818,7 @@ jQuery.extend({
|
|||||||
|
|
||||||
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;
|
||||||
|
@ -53,7 +53,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||||||
return responseContainer[ 0 ];
|
return responseContainer[ 0 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
// force json dataType
|
// Force json dataType
|
||||||
s.dataTypes[ 0 ] = "json";
|
s.dataTypes[ 0 ] = "json";
|
||||||
|
|
||||||
// Install callback
|
// Install callback
|
||||||
@ -64,6 +64,7 @@ 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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ jQuery.ajaxPrefilter( "script", function( s ) {
|
|||||||
|
|
||||||
// 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;
|
||||||
|
@ -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
|
||||||
@ -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)
|
||||||
@ -105,9 +109,11 @@ jQuery.ajaxTransport(function( options ) {
|
|||||||
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;
|
||||||
|
@ -111,6 +111,7 @@ jQuery.extend({
|
|||||||
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;
|
||||||
|
@ -25,6 +25,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ) || [];
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 );
|
||||||
@ -79,6 +80,7 @@ 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 + " ", " " );
|
||||||
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,15 +16,20 @@ jQuery.fn.extend({
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -74,6 +79,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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() {
|
||||||
|
|
||||||
@ -121,6 +128,7 @@ jQuery.Callbacks = function( options ) {
|
|||||||
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 );
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
|
||||||
@ -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 ];
|
||||||
@ -181,6 +185,7 @@ jQuery.extend = jQuery.fn.extend = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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, "" ),
|
||||||
|
|
||||||
@ -204,6 +209,7 @@ 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
|
||||||
@ -212,6 +218,7 @@ jQuery.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
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,6 +249,7 @@ 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" :
|
||||||
|
@ -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 ) )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ 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;
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ var rootjQuery,
|
|||||||
// 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 ] );
|
||||||
@ -76,6 +77,7 @@ var rootjQuery,
|
|||||||
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;
|
||||||
@ -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 );
|
||||||
}
|
}
|
||||||
|
@ -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 );
|
||||||
|
@ -8,6 +8,7 @@ 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 );
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ jQuery.fn.ready = function( fn ) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
|
|
||||||
@ -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 );
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
define( function() {
|
define( function() {
|
||||||
|
|
||||||
// Match a standalone tag
|
// Match a standalone tag
|
||||||
return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
|
return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
|
||||||
} );
|
} );
|
||||||
|
11
src/css.js
11
src/css.js
@ -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
|
||||||
@ -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 ) {
|
||||||
@ -228,6 +236,7 @@ jQuery.extend({
|
|||||||
// 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";
|
||||||
}
|
}
|
||||||
@ -256,6 +265,7 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
} 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 ) {
|
||||||
@ -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.
|
||||||
|
@ -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 +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";
|
||||||
@ -44,6 +47,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
|
|||||||
|
|
||||||
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 ] :
|
||||||
|
@ -4,7 +4,7 @@ define([
|
|||||||
"./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 + "" :
|
||||||
|
@ -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" ) || "";
|
||||||
}
|
}
|
||||||
|
@ -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;" +
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
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;
|
||||||
|
@ -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 ) :
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -15,6 +15,7 @@ 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" ),
|
||||||
@ -36,12 +37,14 @@ 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 ] ];
|
||||||
|
|
||||||
@ -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 ) {
|
||||||
@ -182,6 +188,7 @@ 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(
|
||||||
@ -217,6 +224,7 @@ jQuery.extend({
|
|||||||
);
|
);
|
||||||
} ).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 ) {
|
||||||
@ -239,6 +247,7 @@ jQuery.extend({
|
|||||||
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;
|
||||||
|
@ -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 ) :
|
||||||
|
|
||||||
|
9
src/effects.js
vendored
9
src/effects.js
vendored
@ -100,6 +100,7 @@ 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--;
|
||||||
@ -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
|
||||||
@ -211,6 +213,7 @@ 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 ] );
|
||||||
@ -277,6 +280,7 @@ 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;
|
||||||
} ),
|
} ),
|
||||||
@ -286,6 +290,7 @@ function Animation( elem, properties, options ) {
|
|||||||
}
|
}
|
||||||
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,
|
||||||
@ -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;
|
||||||
@ -474,6 +480,7 @@ jQuery.fn.extend({
|
|||||||
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 );
|
||||||
|
|
||||||
@ -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,6 +667,7 @@ 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
|
||||||
};
|
};
|
||||||
|
@ -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.
|
||||||
|
24
src/event.js
24
src/event.js
@ -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,10 +79,12 @@ 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++ );
|
||||||
}
|
}
|
||||||
@ -124,6 +131,7 @@ jQuery.event = {
|
|||||||
}
|
}
|
||||||
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 ?
|
||||||
@ -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;
|
||||||
@ -294,6 +303,7 @@ jQuery.event = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
@ -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.
|
||||||
@ -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,6 +709,7 @@ 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 :
|
||||||
@ -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;
|
||||||
|
@ -32,6 +32,7 @@ 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, "**" ) :
|
||||||
|
@ -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,
|
||||||
|
|
||||||
|
@ -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\/(.*)/,
|
||||||
@ -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 );
|
||||||
|
@ -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 );
|
||||||
|
@ -3,6 +3,7 @@ define([
|
|||||||
], 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" ?
|
||||||
|
@ -74,6 +74,7 @@ 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 ?
|
||||||
@ -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();
|
||||||
|
|
||||||
@ -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" :
|
||||||
|
@ -106,6 +106,7 @@ jQuery.fn.extend({
|
|||||||
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 ) {
|
||||||
|
@ -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,6 +48,7 @@ var hasDuplicate,
|
|||||||
a.compareDocumentPosition( b );
|
a.compareDocumentPosition( b );
|
||||||
|
|
||||||
if ( compare ) {
|
if ( compare ) {
|
||||||
|
|
||||||
// Disconnected nodes
|
// Disconnected nodes
|
||||||
if ( compare & 1 ) {
|
if ( compare & 1 ) {
|
||||||
|
|
||||||
@ -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;
|
||||||
|
@ -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 : "" ) + "]",
|
||||||
@ -34,12 +37,14 @@ function buildParams( prefix, obj, traditional, 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 ) {
|
||||||
@ -86,6 +94,7 @@ jQuery.fn.extend({
|
|||||||
},
|
},
|
||||||
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;
|
||||||
|
@ -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,
|
||||||
@ -71,6 +72,7 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
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 :
|
||||||
@ -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 );
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
define( function() {
|
define( function() {
|
||||||
|
|
||||||
// [[Class]] -> type pairs
|
// [[Class]] -> type pairs
|
||||||
return {};
|
return {};
|
||||||
} );
|
} );
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
define( function() {
|
define( function() {
|
||||||
|
|
||||||
// All support tests are defined in their respective modules.
|
// All support tests are defined in their respective modules.
|
||||||
return {};
|
return {};
|
||||||
} );
|
} );
|
||||||
|
300
test/data/jquery-1.9.1.js
vendored
300
test/data/jquery-1.9.1.js
vendored
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
|||||||
var fireNative, originaljQuery, original$,
|
var fireNative, originaljQuery, original$,
|
||||||
baseURL = "",
|
baseURL = "",
|
||||||
supportjQuery = this.jQuery,
|
supportjQuery = this.jQuery,
|
||||||
|
|
||||||
// see RFC 2606
|
// see RFC 2606
|
||||||
externalHost = "example.com";
|
externalHost = "example.com";
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
|||||||
// be available as long as the object is not garbage collected by
|
// be available as long as the object is not garbage collected by
|
||||||
// the js engine, and when it is, the data will be removed with it.
|
// the js engine, and when it is, the data will be removed with it.
|
||||||
if ( !elem.nodeType ) {
|
if ( !elem.nodeType ) {
|
||||||
|
|
||||||
// Fixes false positives for dataTests(window), dataTests({}).
|
// Fixes false positives for dataTests(window), dataTests({}).
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -56,6 +57,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
|||||||
expando = elem[ jQuery.expando ];
|
expando = elem[ jQuery.expando ];
|
||||||
|
|
||||||
if ( expando === undefined ) {
|
if ( expando === undefined ) {
|
||||||
|
|
||||||
// In this case the element exists fine, but
|
// In this case the element exists fine, but
|
||||||
// jQuery.data (or internal data) was never (in)directly
|
// jQuery.data (or internal data) was never (in)directly
|
||||||
// called.
|
// called.
|
||||||
@ -106,6 +108,7 @@ window.moduleTeardown = function() {
|
|||||||
delete jQuery.cache[ i ];
|
delete jQuery.cache[ i ];
|
||||||
delete expectedDataKeys[ i ];
|
delete expectedDataKeys[ i ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case it was removed from cache before (or never there in the first place)
|
// In case it was removed from cache before (or never there in the first place)
|
||||||
for ( i in expectedDataKeys ) {
|
for ( i in expectedDataKeys ) {
|
||||||
deepEqual(
|
deepEqual(
|
||||||
@ -151,6 +154,7 @@ window.moduleTeardown = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
QUnit.done( function() {
|
QUnit.done( function() {
|
||||||
|
|
||||||
// Remove our own fixtures outside #qunit-fixture
|
// Remove our own fixtures outside #qunit-fixture
|
||||||
supportjQuery( "#qunit ~ *" ).remove();
|
supportjQuery( "#qunit ~ *" ).remove();
|
||||||
} );
|
} );
|
||||||
@ -159,6 +163,7 @@ QUnit.testDone(function() {
|
|||||||
|
|
||||||
// Ensure jQuery events and data on the fixture are properly removed
|
// Ensure jQuery events and data on the fixture are properly removed
|
||||||
jQuery( "#qunit-fixture" ).empty();
|
jQuery( "#qunit-fixture" ).empty();
|
||||||
|
|
||||||
// ...even if the jQuery under test has a broken .empty()
|
// ...even if the jQuery under test has a broken .empty()
|
||||||
supportjQuery( "#qunit-fixture" ).empty();
|
supportjQuery( "#qunit-fixture" ).empty();
|
||||||
|
|
||||||
|
@ -270,6 +270,7 @@ QUnit.module( "ajax", {
|
|||||||
url: url( "data/headers.php?keys=content-type" ),
|
url: url( "data/headers.php?keys=content-type" ),
|
||||||
contentType: false,
|
contentType: false,
|
||||||
success: function( data ) {
|
success: function( data ) {
|
||||||
|
|
||||||
// Some server/interpreter combinations always supply a Content-Type to scripts
|
// Some server/interpreter combinations always supply a Content-Type to scripts
|
||||||
data = data || "content-type: \n";
|
data = data || "content-type: \n";
|
||||||
assert.strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" );
|
assert.strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" );
|
||||||
@ -880,7 +881,6 @@ QUnit.module( "ajax", {
|
|||||||
];
|
];
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, function( assert ) {
|
ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, function( assert ) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -1138,6 +1138,7 @@ QUnit.module( "ajax", {
|
|||||||
|
|
||||||
ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, function( assert ) {
|
ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, function( assert ) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
// see RFC 2606
|
// see RFC 2606
|
||||||
url: "http://example.invalid",
|
url: "http://example.invalid",
|
||||||
error: function( xhr, _, e ) {
|
error: function( xhr, _, e ) {
|
||||||
@ -1561,6 +1562,7 @@ QUnit.module( "ajax", {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function( assert ) {
|
QUnit.asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function( assert ) {
|
||||||
|
|
||||||
// Support: Android 2.3 only
|
// Support: Android 2.3 only
|
||||||
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
||||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||||
@ -1629,6 +1631,7 @@ QUnit.module( "ajax", {
|
|||||||
var parsedXML = jQuery( jQuery.parseXML( "<tab title=\"Added\">blibli</tab>" ) ).find( "tab" );
|
var parsedXML = jQuery( jQuery.parseXML( "<tab title=\"Added\">blibli</tab>" ) ).find( "tab" );
|
||||||
ajaxXML = jQuery( ajaxXML );
|
ajaxXML = jQuery( ajaxXML );
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Android 2.3 doesn't automatically adopt nodes from foreign documents.
|
// Android 2.3 doesn't automatically adopt nodes from foreign documents.
|
||||||
// (see the comment in test/manipulation.js)
|
// (see the comment in test/manipulation.js)
|
||||||
// Support: Android 2.3
|
// Support: Android 2.3
|
||||||
@ -1749,6 +1752,7 @@ QUnit.module( "ajax", {
|
|||||||
return {
|
return {
|
||||||
dataType: "prefix",
|
dataType: "prefix",
|
||||||
setup: function() {
|
setup: function() {
|
||||||
|
|
||||||
// Ensure prefix does not throw an error
|
// Ensure prefix does not throw an error
|
||||||
jQuery.ajaxPrefilter( "+prefix", function( options, _, jqXHR ) {
|
jQuery.ajaxPrefilter( "+prefix", function( options, _, jqXHR ) {
|
||||||
if ( options.abortInPrefilter ) {
|
if ( options.abortInPrefilter ) {
|
||||||
|
@ -79,6 +79,7 @@ QUnit.test( "attr(String)", function( assert ) {
|
|||||||
assert.equal( jQuery( "#testForm" ).attr( "target" ), undefined, "Retrieving target does not equal the input with name=target" );
|
assert.equal( jQuery( "#testForm" ).attr( "target" ), undefined, "Retrieving target does not equal the input with name=target" );
|
||||||
assert.equal( jQuery( "#testForm" ).attr( "target", "newTarget" ).attr( "target" ), "newTarget", "Set target successfully on a form" );
|
assert.equal( jQuery( "#testForm" ).attr( "target", "newTarget" ).attr( "target" ), "newTarget", "Set target successfully on a form" );
|
||||||
assert.equal( jQuery( "#testForm" ).removeAttr( "id" ).attr( "id" ), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" );
|
assert.equal( jQuery( "#testForm" ).removeAttr( "id" ).attr( "id" ), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" );
|
||||||
|
|
||||||
// Bug #3685 (form contains input with name="name")
|
// Bug #3685 (form contains input with name="name")
|
||||||
assert.equal( jQuery( "#testForm" ).attr( "name" ), undefined, "Retrieving name does not retrieve input with name=name" );
|
assert.equal( jQuery( "#testForm" ).attr( "name" ), undefined, "Retrieving name does not retrieve input with name=name" );
|
||||||
extras.remove();
|
extras.remove();
|
||||||
@ -810,13 +811,13 @@ QUnit.test( "val() after modification", function( assert ) {
|
|||||||
assert.equal( jQuery( "#text1" ).val(), "bla", "Check for modified value of input element" );
|
assert.equal( jQuery( "#text1" ).val(), "bla", "Check for modified value of input element" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
QUnit.test( "val()", function( assert ) {
|
QUnit.test( "val()", function( assert ) {
|
||||||
|
|
||||||
assert.expect( 20 + ( jQuery.fn.serialize ? 6 : 0 ) );
|
assert.expect( 20 + ( jQuery.fn.serialize ? 6 : 0 ) );
|
||||||
|
|
||||||
var checks, $button;
|
var checks, $button;
|
||||||
assert.equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" );
|
assert.equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" );
|
||||||
|
|
||||||
// ticket #1714 this caused a JS error in IE
|
// ticket #1714 this caused a JS error in IE
|
||||||
assert.equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" );
|
assert.equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" );
|
||||||
assert.ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" );
|
assert.ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" );
|
||||||
@ -1161,7 +1162,6 @@ var testRemoveClass = function( valueObj, assert ) {
|
|||||||
$set.removeClass( valueObj( "asdf" ) );
|
$set.removeClass( valueObj( "asdf" ) );
|
||||||
assert.ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" );
|
assert.ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" );
|
||||||
|
|
||||||
|
|
||||||
jQuery( div ).removeClass( valueObj( "foo" ) );
|
jQuery( div ).removeClass( valueObj( "foo" ) );
|
||||||
assert.strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" );
|
assert.strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" );
|
||||||
|
|
||||||
|
@ -515,6 +515,7 @@ QUnit.test("XSS via location.hash", function( assert ) {
|
|||||||
QUnit.start();
|
QUnit.start();
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// This throws an error because it's processed like an id
|
// This throws an error because it's processed like an id
|
||||||
jQuery( "#<img id='check9521' src='no-such-.gif' onerror='jQuery._check9521(false)'>" ).appendTo( "#qunit-fixture" );
|
jQuery( "#<img id='check9521' src='no-such-.gif' onerror='jQuery._check9521(false)'>" ).appendTo( "#qunit-fixture" );
|
||||||
} catch ( err ) {
|
} catch ( err ) {
|
||||||
@ -585,6 +586,7 @@ QUnit.test("jQuery('html')", function( assert ) {
|
|||||||
|
|
||||||
assert.equal( jQuery( "element[attribute='<div></div>']" ).length, 0,
|
assert.equal( jQuery( "element[attribute='<div></div>']" ).length, 0,
|
||||||
"When html is within brackets, do not recognize as html." );
|
"When html is within brackets, do not recognize as html." );
|
||||||
|
|
||||||
//equal( jQuery( "element[attribute=<div></div>]" ).length, 0,
|
//equal( jQuery( "element[attribute=<div></div>]" ).length, 0,
|
||||||
// "When html is within brackets, do not recognize as html." );
|
// "When html is within brackets, do not recognize as html." );
|
||||||
assert.equal( jQuery( "element:not(<div></div>)" ).length, 0,
|
assert.equal( jQuery( "element:not(<div></div>)" ).length, 0,
|
||||||
@ -634,6 +636,7 @@ QUnit.test("jQuery(selector, xml).text(str) - loaded via xml document", function
|
|||||||
assert.expect( 2 );
|
assert.expect( 2 );
|
||||||
|
|
||||||
var xml = createDashboardXML(),
|
var xml = createDashboardXML(),
|
||||||
|
|
||||||
// tests for #1419 where ie was a problem
|
// tests for #1419 where ie was a problem
|
||||||
tab = jQuery( "tab", xml ).eq( 0 );
|
tab = jQuery( "tab", xml ).eq( 0 );
|
||||||
assert.equal( tab.text(), "blabla", "verify initial text correct" );
|
assert.equal( tab.text(), "blabla", "verify initial text correct" );
|
||||||
@ -692,6 +695,7 @@ QUnit.test("inArray()", function( assert ) {
|
|||||||
|
|
||||||
jQuery.each( tests, function( key, obj ) {
|
jQuery.each( tests, function( key, obj ) {
|
||||||
assert.equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
|
assert.equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
|
||||||
|
|
||||||
// Third argument (fromIndex)
|
// Third argument (fromIndex)
|
||||||
assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" );
|
assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" );
|
||||||
assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" );
|
assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" );
|
||||||
@ -1080,8 +1084,10 @@ QUnit.test("jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed
|
|||||||
assert.expect( 2 );
|
assert.expect( 2 );
|
||||||
|
|
||||||
var result, initial = {
|
var result, initial = {
|
||||||
|
|
||||||
// This will make "copyIsArray" true
|
// This will make "copyIsArray" true
|
||||||
array: [ 1, 2, 3, 4 ],
|
array: [ 1, 2, 3, 4 ],
|
||||||
|
|
||||||
// If "copyIsArray" doesn't get reset to false, the check
|
// If "copyIsArray" doesn't get reset to false, the check
|
||||||
// will evaluate true and enter the array copy block
|
// will evaluate true and enter the array copy block
|
||||||
// instead of the object copy block. Since the ternary in the
|
// instead of the object copy block. Since the ternary in the
|
||||||
|
@ -742,6 +742,7 @@ QUnit.test("jQuery.cssProps behavior, (bug #8402)", function( assert ) {
|
|||||||
assert.equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
|
assert.equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
|
||||||
div.css( "top", "100px" );
|
div.css( "top", "100px" );
|
||||||
assert.equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
|
assert.equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
|
||||||
|
|
||||||
// cleanup jQuery.cssProps
|
// cleanup jQuery.cssProps
|
||||||
jQuery.cssProps.top = undefined;
|
jQuery.cssProps.top = undefined;
|
||||||
} );
|
} );
|
||||||
@ -814,6 +815,7 @@ QUnit.test("Do not append px (#9548, #12990)", function( assert ) {
|
|||||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
$div.css( "fill-opacity", 1 );
|
$div.css( "fill-opacity", 1 );
|
||||||
|
|
||||||
// Support: Android 2.3 (no support for fill-opacity)
|
// Support: Android 2.3 (no support for fill-opacity)
|
||||||
if ( $div.css( "fill-opacity" ) ) {
|
if ( $div.css( "fill-opacity" ) ) {
|
||||||
assert.equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
assert.equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
||||||
@ -1032,6 +1034,7 @@ QUnit.test( "Keep the last style if the new one isn't recognized by the browser
|
|||||||
QUnit.test( "Reset the style if set to an empty string", function( assert ) {
|
QUnit.test( "Reset the style if set to an empty string", function( assert ) {
|
||||||
assert.expect( 1 );
|
assert.expect( 1 );
|
||||||
var el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "" );
|
var el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "" );
|
||||||
|
|
||||||
// Some browsers return an empty string; others "static". Both those cases mean the style
|
// Some browsers return an empty string; others "static". Both those cases mean the style
|
||||||
// was reset successfully so accept them both.
|
// was reset successfully so accept them both.
|
||||||
assert.equal( el.css( "position" ) || "static", "static",
|
assert.equal( el.css( "position" ) || "static", "static",
|
||||||
@ -1049,6 +1052,7 @@ QUnit.asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original
|
|||||||
value: [ "rgb(255, 0, 0)", "rgb(255,0,0)", "#ff0000" ],
|
value: [ "rgb(255, 0, 0)", "rgb(255,0,0)", "#ff0000" ],
|
||||||
expected: [ "transparent" ]
|
expected: [ "transparent" ]
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
// Firefox returns auto's value
|
// Firefox returns auto's value
|
||||||
name: "backgroundImage",
|
name: "backgroundImage",
|
||||||
value: [ "url('test.png')", "url(" + baseUrl + "test.png)", "url(\"" + baseUrl + "test.png\")" ],
|
value: [ "url('test.png')", "url(" + baseUrl + "test.png)", "url(\"" + baseUrl + "test.png\")" ],
|
||||||
@ -1058,6 +1062,7 @@ QUnit.asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original
|
|||||||
value: [ "5% 5%" ],
|
value: [ "5% 5%" ],
|
||||||
expected: [ "0% 0%", "-1000px 0px", "-1000px 0%" ]
|
expected: [ "0% 0%", "-1000px 0px", "-1000px 0%" ]
|
||||||
}, {
|
}, {
|
||||||
|
|
||||||
// Firefox returns no-repeat
|
// Firefox returns no-repeat
|
||||||
name: "backgroundRepeat",
|
name: "backgroundRepeat",
|
||||||
value: [ "repeat-y" ],
|
value: [ "repeat-y" ],
|
||||||
@ -1186,6 +1191,7 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QUnit.test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function( assert ) {
|
QUnit.test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function( assert ) {
|
||||||
|
|
||||||
// Note: this test needs a property we know is only supported in a prefixed version
|
// Note: this test needs a property we know is only supported in a prefixed version
|
||||||
// by at least one of our main supported browsers. This may get out of date so let's
|
// by at least one of our main supported browsers. This may get out of date so let's
|
||||||
// use -(webkit|moz)-appearance as well as those two are not on a standards track.
|
// use -(webkit|moz)-appearance as well as those two are not on a standards track.
|
||||||
|
@ -651,6 +651,7 @@ QUnit.test(".data supports interoperable hyphenated/camelCase get/set of propert
|
|||||||
"an-object": {},
|
"an-object": {},
|
||||||
"bool-true": true,
|
"bool-true": true,
|
||||||
"bool-false": false,
|
"bool-false": false,
|
||||||
|
|
||||||
// JSHint enforces double quotes,
|
// JSHint enforces double quotes,
|
||||||
// but JSON strings need double quotes to parse
|
// but JSON strings need double quotes to parse
|
||||||
// so we need escaped double quotes here
|
// so we need escaped double quotes here
|
||||||
@ -681,6 +682,7 @@ QUnit.test(".data supports interoperable removal of hyphenated/camelCase propert
|
|||||||
"an-object": {},
|
"an-object": {},
|
||||||
"bool-true": true,
|
"bool-true": true,
|
||||||
"bool-false": false,
|
"bool-false": false,
|
||||||
|
|
||||||
// JSHint enforces double quotes,
|
// JSHint enforces double quotes,
|
||||||
// but JSON strings need double quotes to parse
|
// but JSON strings need double quotes to parse
|
||||||
// so we need escaped double quotes here
|
// so we need escaped double quotes here
|
||||||
@ -713,6 +715,7 @@ QUnit.test(".data supports interoperable removal of properties SET TWICE #13850"
|
|||||||
"an-object": {},
|
"an-object": {},
|
||||||
"bool-true": true,
|
"bool-true": true,
|
||||||
"bool-false": false,
|
"bool-false": false,
|
||||||
|
|
||||||
// JSHint enforces double quotes,
|
// JSHint enforces double quotes,
|
||||||
// but JSON strings need double quotes to parse
|
// but JSON strings need double quotes to parse
|
||||||
// so we need escaped double quotes here
|
// so we need escaped double quotes here
|
||||||
@ -741,8 +744,10 @@ QUnit.test( ".removeData supports removal of hyphenated properties via array (#1
|
|||||||
|
|
||||||
// Properties should always be camelCased
|
// Properties should always be camelCased
|
||||||
compare = {
|
compare = {
|
||||||
|
|
||||||
// From batch assignment .data({ "a-a": 1 })
|
// From batch assignment .data({ "a-a": 1 })
|
||||||
"aA": 1,
|
"aA": 1,
|
||||||
|
|
||||||
// From property, value assignment .data( "b-b", 1 )
|
// From property, value assignment .data( "b-b", 1 )
|
||||||
"bB": 1
|
"bB": 1
|
||||||
};
|
};
|
||||||
@ -770,6 +775,7 @@ QUnit.test(".removeData should not throw exceptions. (#10080)", function( assert
|
|||||||
assert.ok( true, "called unload" );
|
assert.ok( true, "called unload" );
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// change the url to trigger unload
|
// change the url to trigger unload
|
||||||
frame.attr( "src", "data/iframe.html?param=true" );
|
frame.attr( "src", "data/iframe.html?param=true" );
|
||||||
} );
|
} );
|
||||||
|
@ -77,7 +77,6 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
|||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
||||||
|
|
||||||
var defer = jQuery.Deferred();
|
var defer = jQuery.Deferred();
|
||||||
@ -643,6 +642,7 @@ QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
|||||||
notifiedResolved.then( null, null, function() {
|
notifiedResolved.then( null, null, function() {
|
||||||
return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
|
return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
|
||||||
} ).progress( function( v ) {
|
} ).progress( function( v ) {
|
||||||
|
|
||||||
// Progress from the surrogate deferred is ignored
|
// Progress from the surrogate deferred is ignored
|
||||||
assert.strictEqual( v, "quux", "deferred replaced then'd progress value" );
|
assert.strictEqual( v, "quux", "deferred replaced then'd progress value" );
|
||||||
done.pop().call();
|
done.pop().call();
|
||||||
|
26
test/unit/effects.js
vendored
26
test/unit/effects.js
vendored
@ -308,7 +308,6 @@ QUnit.test("animate negative padding", function( assert ) {
|
|||||||
QUnit.test( "animate block as inline width/height", function( assert ) {
|
QUnit.test( "animate block as inline width/height", function( assert ) {
|
||||||
assert.expect( 3 );
|
assert.expect( 3 );
|
||||||
|
|
||||||
|
|
||||||
jQuery( "#foo" ).css( { display: "inline", width: "", height: "" } ).animate( { width: 42, height: 42 }, 100, function() {
|
jQuery( "#foo" ).css( { display: "inline", width: "", height: "" } ).animate( { width: 42, height: 42 }, 100, function() {
|
||||||
assert.equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
assert.equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
||||||
assert.equal( this.offsetWidth, 42, "width was animated" );
|
assert.equal( this.offsetWidth, 42, "width was animated" );
|
||||||
@ -506,7 +505,6 @@ QUnit.test( "animate option { queue: 'name' }", function( assert ) {
|
|||||||
assert.deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
|
assert.deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// this is the first callback function that should be called
|
// this is the first callback function that should be called
|
||||||
order.push( 1 );
|
order.push( 1 );
|
||||||
assert.equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." );
|
assert.equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." );
|
||||||
@ -530,7 +528,6 @@ QUnit.test("animate with no properties", function( assert ) {
|
|||||||
|
|
||||||
assert.equal( divs.length, count, "Make sure that callback is called for each element in the set." );
|
assert.equal( divs.length, count, "Make sure that callback is called for each element in the set." );
|
||||||
|
|
||||||
|
|
||||||
foo = jQuery( "#foo" );
|
foo = jQuery( "#foo" );
|
||||||
|
|
||||||
foo.animate( {} );
|
foo.animate( {} );
|
||||||
@ -543,7 +540,6 @@ QUnit.test("animate with no properties", function( assert ) {
|
|||||||
QUnit.test( "animate duration 0", function( assert ) {
|
QUnit.test( "animate duration 0", function( assert ) {
|
||||||
assert.expect( 11 );
|
assert.expect( 11 );
|
||||||
|
|
||||||
|
|
||||||
var $elem,
|
var $elem,
|
||||||
$elems = jQuery( [ { a:0 },{ a:0 } ] ),
|
$elems = jQuery( [ { a:0 },{ a:0 } ] ),
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@ -573,6 +569,7 @@ QUnit.test("animate duration 0", function( assert ) {
|
|||||||
} );
|
} );
|
||||||
$elems.eq( 1 ).animate( { a:3 }, 200, function() {
|
$elems.eq( 1 ).animate( { a:3 }, 200, function() {
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
// Failed until [6115]
|
// Failed until [6115]
|
||||||
assert.equal( counter, 5, "One synchronic and one asynchronic" );
|
assert.equal( counter, 5, "One synchronic and one asynchronic" );
|
||||||
} );
|
} );
|
||||||
@ -598,6 +595,7 @@ QUnit.test("animate hyphenated properties", function( assert ) {
|
|||||||
.animate( { "font-size": 20 }, 200, function() {
|
.animate( { "font-size": 20 }, 200, function() {
|
||||||
assert.equal( this.style.fontSize, "20px", "The font-size property was animated." );
|
assert.equal( this.style.fontSize, "20px", "The font-size property was animated." );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// FIXME why is this double only when run with other tests
|
// FIXME why is this double only when run with other tests
|
||||||
this.clock.tick( 400 );
|
this.clock.tick( 400 );
|
||||||
|
|
||||||
@ -647,6 +645,7 @@ QUnit.test("stop()", function( assert ) {
|
|||||||
this.clock.tick( 100 );
|
this.clock.tick( 100 );
|
||||||
$two.fadeTo( 100, 0, function() {
|
$two.fadeTo( 100, 0, function() {
|
||||||
assert.equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" );
|
assert.equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" );
|
||||||
|
|
||||||
// Reset styles
|
// Reset styles
|
||||||
$one.add( $two ).css( "opacity", "" );
|
$one.add( $two ).css( "opacity", "" );
|
||||||
} );
|
} );
|
||||||
@ -725,10 +724,12 @@ QUnit.test("stop(clearQueue, gotoEnd)", function( assert ) {
|
|||||||
$foo.stop( false, true );
|
$foo.stop( false, true );
|
||||||
|
|
||||||
nw = $foo.css( "width" );
|
nw = $foo.css( "width" );
|
||||||
|
|
||||||
// Disabled, being flaky
|
// Disabled, being flaky
|
||||||
//equal( nw, 1, "Stop() reset the animation" );
|
//equal( nw, 1, "Stop() reset the animation" );
|
||||||
|
|
||||||
this.clock.tick( 100 );
|
this.clock.tick( 100 );
|
||||||
|
|
||||||
// Disabled, being flaky
|
// Disabled, being flaky
|
||||||
//equal( $foo.queue().length, 2, "The next animation continued" );
|
//equal( $foo.queue().length, 2, "The next animation continued" );
|
||||||
$foo.stop( true );
|
$foo.stop( true );
|
||||||
@ -935,6 +936,7 @@ jQuery.each({
|
|||||||
}
|
}
|
||||||
|
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
// TODO: uncrowd this
|
// TODO: uncrowd this
|
||||||
if ( t_h === "show" ) { num++; }
|
if ( t_h === "show" ) { num++; }
|
||||||
if ( t_w === "show" ) { num++; }
|
if ( t_w === "show" ) { num++; }
|
||||||
@ -1113,6 +1115,7 @@ QUnit.test( "interrupt toggle", function( assert ) {
|
|||||||
|
|
||||||
jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) {
|
jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) {
|
||||||
var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each( function() {
|
var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each( function() {
|
||||||
|
|
||||||
// Don't end test until we're done with this element
|
// Don't end test until we're done with this element
|
||||||
remaining++;
|
remaining++;
|
||||||
|
|
||||||
@ -1306,6 +1309,7 @@ QUnit.test("callbacks should fire in correct order (#9100)", function( assert )
|
|||||||
cb = 0;
|
cb = 0;
|
||||||
|
|
||||||
jQuery( "<p data-operation='*2'></p><p data-operation='^2'></p>" ).appendTo( "#qunit-fixture" )
|
jQuery( "<p data-operation='*2'></p><p data-operation='^2'></p>" ).appendTo( "#qunit-fixture" )
|
||||||
|
|
||||||
// The test will always pass if no properties are animated or if the duration is 0
|
// The test will always pass if no properties are animated or if the duration is 0
|
||||||
.animate( { fontSize: 12 }, 13, function() {
|
.animate( { fontSize: 12 }, 13, function() {
|
||||||
a *= jQuery( this ).data( "operation" ) === "*2" ? 2 : a;
|
a *= jQuery( this ).data( "operation" ) === "*2" ? 2 : a;
|
||||||
@ -1376,6 +1380,7 @@ QUnit.test("Do not append px to 'fill-opacity' #9548", function( assert ) {
|
|||||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
$div.css( "fill-opacity", 0 ).animate( { "fill-opacity": 1.0 }, 0, function() {
|
$div.css( "fill-opacity", 0 ).animate( { "fill-opacity": 1.0 }, 0, function() {
|
||||||
|
|
||||||
// Support: Android 2.3 (no support for fill-opacity)
|
// Support: Android 2.3 (no support for fill-opacity)
|
||||||
if ( jQuery( this ).css( "fill-opacity" ) ) {
|
if ( jQuery( this ).css( "fill-opacity" ) ) {
|
||||||
assert.equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
assert.equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
||||||
@ -1489,6 +1494,7 @@ QUnit.test( "Animate Option: step: function( percent, tween )", function( assert
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
step: function( value, tween ) {
|
step: function( value, tween ) {
|
||||||
var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
|
var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
|
||||||
|
|
||||||
// in case this is called multiple times for either, lets store it in
|
// in case this is called multiple times for either, lets store it in
|
||||||
// 0 or 1 in the array
|
// 0 or 1 in the array
|
||||||
calls[ value === 0 ? 0 : 1 ] = value;
|
calls[ value === 0 ? 0 : 1 ] = value;
|
||||||
@ -1762,6 +1768,7 @@ QUnit.test( "multiple unqueued and promise", function( assert ) {
|
|||||||
duration: 2000,
|
duration: 2000,
|
||||||
queue: false,
|
queue: false,
|
||||||
complete: function() {
|
complete: function() {
|
||||||
|
|
||||||
// no properties is a non-op and finishes immediately
|
// no properties is a non-op and finishes immediately
|
||||||
assert.strictEqual( step++, 1, "Step 1" );
|
assert.strictEqual( step++, 1, "Step 1" );
|
||||||
}
|
}
|
||||||
@ -1887,11 +1894,13 @@ QUnit.test("Animation callbacks (#11797)", function( assert ) {
|
|||||||
assert.ok( true, "async: start" );
|
assert.ok( true, "async: start" );
|
||||||
},
|
},
|
||||||
progress: function( anim, percent ) {
|
progress: function( anim, percent ) {
|
||||||
|
|
||||||
// occasionally the progress handler is called twice in first frame.... *shrug*
|
// occasionally the progress handler is called twice in first frame.... *shrug*
|
||||||
if ( percent === 0 && expectedProgress === 1 ) {
|
if ( percent === 0 && expectedProgress === 1 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert.equal( percent, expectedProgress, "async: progress " + expectedProgress );
|
assert.equal( percent, expectedProgress, "async: progress " + expectedProgress );
|
||||||
|
|
||||||
// once at 0, once at 1
|
// once at 0, once at 1
|
||||||
expectedProgress++;
|
expectedProgress++;
|
||||||
},
|
},
|
||||||
@ -1972,6 +1981,7 @@ QUnit.test( "Animations with 0 duration don't ease (#12273)", function( assert )
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) {
|
jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) {
|
||||||
|
|
||||||
// this test would look a lot better if we were using something to override
|
// this test would look a lot better if we were using something to override
|
||||||
// the default timers
|
// the default timers
|
||||||
var duration = 1500;
|
var duration = 1500;
|
||||||
@ -2013,6 +2023,7 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
|
|||||||
},
|
},
|
||||||
always: secondToggle
|
always: secondToggle
|
||||||
} );
|
} );
|
||||||
|
|
||||||
//FIXME figure out why 470
|
//FIXME figure out why 470
|
||||||
this.clock.tick( 470 );
|
this.clock.tick( 470 );
|
||||||
} );
|
} );
|
||||||
@ -2034,9 +2045,11 @@ QUnit.test( "jQuery.fx.start & jQuery.fx.stop hook points", function( assert ) {
|
|||||||
|
|
||||||
// calls start
|
// calls start
|
||||||
foo.animate( { foo: 1 }, { queue: false } );
|
foo.animate( { foo: 1 }, { queue: false } );
|
||||||
|
|
||||||
// calls start
|
// calls start
|
||||||
foo.animate( { foo: 2 }, { queue: false } );
|
foo.animate( { foo: 2 }, { queue: false } );
|
||||||
foo.stop();
|
foo.stop();
|
||||||
|
|
||||||
// calls stop
|
// calls stop
|
||||||
jQuery.fx.tick();
|
jQuery.fx.tick();
|
||||||
|
|
||||||
@ -2059,6 +2072,7 @@ QUnit.test( ".finish() completes all queued animations", function( assert ) {
|
|||||||
jQuery.each( animations, function( prop, value ) {
|
jQuery.each( animations, function( prop, value ) {
|
||||||
var anim = {};
|
var anim = {};
|
||||||
anim[ prop ] = value;
|
anim[ prop ] = value;
|
||||||
|
|
||||||
// the delay shouldn't matter at all!
|
// the delay shouldn't matter at all!
|
||||||
div.css( prop, 1 ).animate( anim, function() {
|
div.css( prop, 1 ).animate( anim, function() {
|
||||||
assert.ok( true, "Called animation callback for " + prop );
|
assert.ok( true, "Called animation callback for " + prop );
|
||||||
@ -2074,6 +2088,7 @@ QUnit.test( ".finish() completes all queued animations", function( assert ) {
|
|||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
div.remove();
|
div.remove();
|
||||||
|
|
||||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||||
jQuery.fx.tick();
|
jQuery.fx.tick();
|
||||||
} );
|
} );
|
||||||
@ -2108,6 +2123,7 @@ QUnit.test( ".finish( false ) - unqueued animations", function( assert ) {
|
|||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
div.remove();
|
div.remove();
|
||||||
|
|
||||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||||
jQuery.fx.tick();
|
jQuery.fx.tick();
|
||||||
} );
|
} );
|
||||||
@ -2134,6 +2150,7 @@ QUnit.test( ".finish( \"custom\" ) - custom queue animations", function( assert
|
|||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
assert.equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
|
assert.equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
|
||||||
|
|
||||||
// start the first animation
|
// start the first animation
|
||||||
div.dequeue( "custom" );
|
div.dequeue( "custom" );
|
||||||
assert.equal( div.is( ":animated" ), true, ":animated matches" );
|
assert.equal( div.is( ":animated" ), true, ":animated matches" );
|
||||||
@ -2145,6 +2162,7 @@ QUnit.test( ".finish( \"custom\" ) - custom queue animations", function( assert
|
|||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
div.remove();
|
div.remove();
|
||||||
|
|
||||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||||
jQuery.fx.tick();
|
jQuery.fx.tick();
|
||||||
} );
|
} );
|
||||||
|
@ -36,6 +36,7 @@ QUnit.test("Handler changes and .trigger() order", function( assert ) {
|
|||||||
path += this.nodeName.toLowerCase() + " ";
|
path += this.nodeName.toLowerCase() + " ";
|
||||||
} )
|
} )
|
||||||
.filter( "b" ).on( "click", function( e ) {
|
.filter( "b" ).on( "click", function( e ) {
|
||||||
|
|
||||||
// Removing span should not stop propagation to original parents
|
// Removing span should not stop propagation to original parents
|
||||||
if ( e.target === this ) {
|
if ( e.target === this ) {
|
||||||
jQuery( this ).parent().remove();
|
jQuery( this ).parent().remove();
|
||||||
@ -98,8 +99,7 @@ QUnit.test("on(), multiple events at once", function( assert ) {
|
|||||||
handler = function( event ) {
|
handler = function( event ) {
|
||||||
if ( event.type === "click" ) {
|
if ( event.type === "click" ) {
|
||||||
clickCounter += 1;
|
clickCounter += 1;
|
||||||
}
|
} else if ( event.type === "mouseover" ) {
|
||||||
else if (event.type === "mouseover") {
|
|
||||||
mouseoverCounter += 1;
|
mouseoverCounter += 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -268,11 +268,13 @@ QUnit.test("on/one/off(Object)", function( assert ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$elem = jQuery( "#firstp" )
|
$elem = jQuery( "#firstp" )
|
||||||
|
|
||||||
// Regular bind
|
// Regular bind
|
||||||
.on( {
|
.on( {
|
||||||
"click":handler,
|
"click":handler,
|
||||||
"mouseover":handler
|
"mouseover":handler
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Bind with data
|
// Bind with data
|
||||||
.one( {
|
.one( {
|
||||||
"click":handlerWithData,
|
"click":handlerWithData,
|
||||||
@ -381,6 +383,7 @@ QUnit.test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function
|
|||||||
assert.ok( false, "immediate propagation should have been stopped" );
|
assert.ok( false, "immediate propagation should have been stopped" );
|
||||||
},
|
},
|
||||||
fakeClick = function( $jq ) {
|
fakeClick = function( $jq ) {
|
||||||
|
|
||||||
// Use a native click so we don't get jQuery simulated bubbling
|
// Use a native click so we don't get jQuery simulated bubbling
|
||||||
var e = document.createEvent( "MouseEvents" );
|
var e = document.createEvent( "MouseEvents" );
|
||||||
e.initEvent( "click", true, true );
|
e.initEvent( "click", true, true );
|
||||||
@ -396,6 +399,7 @@ QUnit.test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function
|
|||||||
$anchor2.off( "click" );
|
$anchor2.off( "click" );
|
||||||
$main.off( "click", "**" );
|
$main.off( "click", "**" );
|
||||||
$anchor2.on( "click", function() {
|
$anchor2.on( "click", function() {
|
||||||
|
|
||||||
// Let the default action occur
|
// Let the default action occur
|
||||||
} );
|
} );
|
||||||
$main.on( "click", "#foo", function( e ) {
|
$main.on( "click", "#foo", function( e ) {
|
||||||
@ -787,6 +791,7 @@ QUnit.test("off(eventObject)", function( assert ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$elem
|
$elem
|
||||||
|
|
||||||
// This handler shouldn't be unbound
|
// This handler shouldn't be unbound
|
||||||
.on( "foo", function() {
|
.on( "foo", function() {
|
||||||
num += 1;
|
num += 1;
|
||||||
@ -795,6 +800,7 @@ QUnit.test("off(eventObject)", function( assert ) {
|
|||||||
$elem.off( e );
|
$elem.off( e );
|
||||||
num += 2;
|
num += 2;
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Neither this one
|
// Neither this one
|
||||||
.on( "bar", function() {
|
.on( "bar", function() {
|
||||||
num += 4;
|
num += 4;
|
||||||
@ -1008,7 +1014,6 @@ QUnit.test("trigger(type, [data], [fn])", function( assert ) {
|
|||||||
assert.ok( true, "Native call was triggered" );
|
assert.ok( true, "Native call was triggered" );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
jQuery( document ).on( "mouseenter", "#firstp", function() {
|
jQuery( document ).on( "mouseenter", "#firstp", function() {
|
||||||
assert.ok( true, "Trigger mouseenter bound by on" );
|
assert.ok( true, "Trigger mouseenter bound by on" );
|
||||||
} );
|
} );
|
||||||
@ -1176,6 +1181,7 @@ QUnit.test("trigger(eventObject, [data], [fn])", function( assert ) {
|
|||||||
assert.equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
|
assert.equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
|
||||||
|
|
||||||
$parent.on( "foo", function( e ) {
|
$parent.on( "foo", function( e ) {
|
||||||
|
|
||||||
// Tries bubbling
|
// Tries bubbling
|
||||||
assert.equal( e.type, "foo", "Verify event type when passed passing an event object" );
|
assert.equal( e.type, "foo", "Verify event type when passed passing an event object" );
|
||||||
assert.equal( e.target.id, "child", "Verify event.target when passed passing an event object" );
|
assert.equal( e.target.id, "child", "Verify event.target when passed passing an event object" );
|
||||||
@ -2159,7 +2165,6 @@ QUnit.test(".on and .off", function( assert ) {
|
|||||||
.off( "click", "em" );
|
.off( "click", "em" );
|
||||||
assert.equal( counter, 54, "delegated event bindings with data" );
|
assert.equal( counter, 54, "delegated event bindings with data" );
|
||||||
|
|
||||||
|
|
||||||
// Mixed event bindings and types
|
// Mixed event bindings and types
|
||||||
counter = 0;
|
counter = 0;
|
||||||
mixfn = function( e, trig ) {
|
mixfn = function( e, trig ) {
|
||||||
@ -2255,6 +2260,7 @@ QUnit.test("special on name mapping", function( assert ) {
|
|||||||
delegateType: "click",
|
delegateType: "click",
|
||||||
handle: function( event ) {
|
handle: function( event ) {
|
||||||
assert.equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" );
|
assert.equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" );
|
||||||
|
|
||||||
// Need to call the handler since .one() uses it to unbind
|
// Need to call the handler since .one() uses it to unbind
|
||||||
return event.handleObj.handler.call( this, event );
|
return event.handleObj.handler.call( this, event );
|
||||||
}
|
}
|
||||||
@ -2395,6 +2401,7 @@ QUnit.test( "event object properties on natively-triggered event", function( ass
|
|||||||
|
|
||||||
// IE9+ requires element to be in the body before it will dispatch
|
// IE9+ requires element to be in the body before it will dispatch
|
||||||
$link.appendTo( "body" ).on( "click", function( e ) {
|
$link.appendTo( "body" ).on( "click", function( e ) {
|
||||||
|
|
||||||
// Not trying to assert specific values here, just ensure the property exists
|
// Not trying to assert specific values here, just ensure the property exists
|
||||||
assert.equal( "detail" in e, true, "has .detail" );
|
assert.equal( "detail" in e, true, "has .detail" );
|
||||||
assert.equal( "cancelable" in e, true, "has .cancelable" );
|
assert.equal( "cancelable" in e, true, "has .cancelable" );
|
||||||
@ -2569,6 +2576,7 @@ QUnit.test("trigger click on checkbox, fires change event", function( assert ) {
|
|||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
|
|
||||||
check.on( "change", function() {
|
check.on( "change", function() {
|
||||||
|
|
||||||
// get it?
|
// get it?
|
||||||
check.off( "change" );
|
check.off( "change" );
|
||||||
assert.ok( true, "Change event fired as a result of triggered click" );
|
assert.ok( true, "Change event fired as a result of triggered click" );
|
||||||
|
@ -529,6 +529,7 @@ QUnit.test( "append(xml)", function( assert ) {
|
|||||||
var xmlDoc, xml1, xml2;
|
var xmlDoc, xml1, xml2;
|
||||||
|
|
||||||
function createXMLDoc() {
|
function createXMLDoc() {
|
||||||
|
|
||||||
// Initialize DOM based upon latest installed MSXML or Netscape
|
// Initialize DOM based upon latest installed MSXML or Netscape
|
||||||
var elem, n, len,
|
var elem, n, len,
|
||||||
aActiveX =
|
aActiveX =
|
||||||
@ -541,6 +542,7 @@ QUnit.test( "append(xml)", function( assert ) {
|
|||||||
if ( document.implementation && "createDocument" in document.implementation ) {
|
if ( document.implementation && "createDocument" in document.implementation ) {
|
||||||
return document.implementation.createDocument( "", "", null );
|
return document.implementation.createDocument( "", "", null );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// IE
|
// IE
|
||||||
for ( n = 0, len = aActiveX.length; n < len; n++ ) {
|
for ( n = 0, len = aActiveX.length; n < len; n++ ) {
|
||||||
try {
|
try {
|
||||||
@ -1185,7 +1187,6 @@ function testReplaceWith( val, assert ) {
|
|||||||
jQuery( "#anchor1" ).contents().replaceWith( val( tmp ) );
|
jQuery( "#anchor1" ).contents().replaceWith( val( tmp ) );
|
||||||
assert.deepEqual( jQuery( "#anchor1" ).contents().get(), [ tmp ], "Replace text node with element" );
|
assert.deepEqual( jQuery( "#anchor1" ).contents().get(), [ tmp ], "Replace text node with element" );
|
||||||
|
|
||||||
|
|
||||||
tmp = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
tmp = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
||||||
assert.ok( true, "Newly bound click run." );
|
assert.ok( true, "Newly bound click run." );
|
||||||
} );
|
} );
|
||||||
@ -1203,7 +1204,6 @@ function testReplaceWith( val, assert ) {
|
|||||||
y.trigger( "click" ); // Shouldn't be run
|
y.trigger( "click" ); // Shouldn't be run
|
||||||
child.trigger( "click" ); // Shouldn't be run
|
child.trigger( "click" ); // Shouldn't be run
|
||||||
|
|
||||||
|
|
||||||
y = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
y = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
||||||
assert.ok( false, "Previously bound click run." );
|
assert.ok( false, "Previously bound click run." );
|
||||||
} );
|
} );
|
||||||
@ -1216,13 +1216,11 @@ function testReplaceWith( val, assert ) {
|
|||||||
|
|
||||||
child2.trigger( "click" );
|
child2.trigger( "click" );
|
||||||
|
|
||||||
|
|
||||||
set = jQuery( "<div/>" ).replaceWith( val( "<span>test</span>" ) );
|
set = jQuery( "<div/>" ).replaceWith( val( "<span>test</span>" ) );
|
||||||
assert.equal( set[ 0 ].nodeName.toLowerCase(), "div", "No effect on a disconnected node." );
|
assert.equal( set[ 0 ].nodeName.toLowerCase(), "div", "No effect on a disconnected node." );
|
||||||
assert.equal( set.length, 1, "No effect on a disconnected node." );
|
assert.equal( set.length, 1, "No effect on a disconnected node." );
|
||||||
assert.equal( set[ 0 ].childNodes.length, 0, "No effect on a disconnected node." );
|
assert.equal( set[ 0 ].childNodes.length, 0, "No effect on a disconnected node." );
|
||||||
|
|
||||||
|
|
||||||
child = jQuery( "#qunit-fixture" ).children().first();
|
child = jQuery( "#qunit-fixture" ).children().first();
|
||||||
$div = jQuery( "<div class='pathological'/>" ).insertBefore( child );
|
$div = jQuery( "<div class='pathological'/>" ).insertBefore( child );
|
||||||
$div.replaceWith( $div );
|
$div.replaceWith( $div );
|
||||||
@ -1234,7 +1232,6 @@ function testReplaceWith( val, assert ) {
|
|||||||
assert.deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [],
|
assert.deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [],
|
||||||
"Replacement with following sibling (context removed)" );
|
"Replacement with following sibling (context removed)" );
|
||||||
|
|
||||||
|
|
||||||
non_existent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) );
|
non_existent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) );
|
||||||
assert.equal( non_existent.length, 0, "Length of non existent element." );
|
assert.equal( non_existent.length, 0, "Length of non existent element." );
|
||||||
|
|
||||||
@ -1466,6 +1463,7 @@ QUnit.test( "clone()", function( assert ) {
|
|||||||
assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||||
div = div.find( "object" );
|
div = div.find( "object" );
|
||||||
clone = clone.find( "object" );
|
clone = clone.find( "object" );
|
||||||
|
|
||||||
// oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
|
// oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
|
||||||
jQuery.each( [ "height", "width", "classid" ], function( i, attr ) {
|
jQuery.each( [ "height", "width", "classid" ], function( i, attr ) {
|
||||||
assert.equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
|
assert.equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
|
||||||
@ -2268,6 +2266,7 @@ QUnit.test( "Ensure oldIE creates a new set on appendTo (#8894)", function( asse
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) {
|
QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) {
|
||||||
|
|
||||||
// Support: Android 2.3 only
|
// Support: Android 2.3 only
|
||||||
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
||||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||||
|
@ -7,6 +7,7 @@ if ( !jQuery.fn.offset ) {
|
|||||||
var supportsScroll, supportsFixedPosition,
|
var supportsScroll, supportsFixedPosition,
|
||||||
forceScroll = jQuery( "<div/>" ).css( { width: 2000, height: 2000 } ),
|
forceScroll = jQuery( "<div/>" ).css( { width: 2000, height: 2000 } ),
|
||||||
checkSupport = function() {
|
checkSupport = function() {
|
||||||
|
|
||||||
// Only run once
|
// Only run once
|
||||||
checkSupport = false;
|
checkSupport = false;
|
||||||
|
|
||||||
@ -89,7 +90,6 @@ testIframe("offset/absolute", "absolute", function( $, iframe, document, assert
|
|||||||
assert.equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
assert.equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
||||||
@ -117,7 +117,6 @@ testIframe("offset/absolute", "absolute", function( $, window, document, assert
|
|||||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||||
@ -135,7 +134,6 @@ testIframe("offset/absolute", "absolute", function( $, window, document, assert
|
|||||||
assert.equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
assert.equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||||
assert.equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
assert.equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||||
|
|
||||||
|
|
||||||
// set offset
|
// set offset
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
||||||
@ -201,7 +199,6 @@ testIframe("offset/relative", "relative", function( $, window, document, assert
|
|||||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#relative-1", "top": 6, "left": 6 },
|
{ "id": "#relative-1", "top": 6, "left": 6 },
|
||||||
@ -213,7 +210,6 @@ testIframe("offset/relative", "relative", function( $, window, document, assert
|
|||||||
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// set offset
|
// set offset
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#relative-2", "top": 200, "left": 50 },
|
{ "id": "#relative-2", "top": 200, "left": 50 },
|
||||||
@ -260,7 +256,6 @@ testIframe("offset/static", "static", function( $, window, document, assert ) {
|
|||||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#static-1", "top": 6, "left": 6 },
|
{ "id": "#static-1", "top": 6, "left": 6 },
|
||||||
@ -273,7 +268,6 @@ testIframe("offset/static", "static", function( $, window, document, assert ) {
|
|||||||
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" );
|
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
// set offset
|
// set offset
|
||||||
tests = [
|
tests = [
|
||||||
{ "id": "#static-2", "top": 200, "left": 200 },
|
{ "id": "#static-2", "top": 200, "left": 200 },
|
||||||
@ -344,6 +338,7 @@ testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
|||||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
assert.equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||||
assert.equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
assert.equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// need to have same number of assertions
|
// need to have same number of assertions
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
@ -376,6 +371,7 @@ testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
|||||||
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||||
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// need to have same number of assertions
|
// need to have same number of assertions
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
@ -390,6 +386,7 @@ testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
|||||||
assert.equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
assert.equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||||
assert.equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
assert.equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// need to have same number of assertions
|
// need to have same number of assertions
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
assert.ok( true, "Fixed position is not supported" );
|
assert.ok( true, "Fixed position is not supported" );
|
||||||
@ -572,6 +569,7 @@ QUnit.test("iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
|||||||
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Tests scrollTop/Left with iframes
|
// Tests scrollTop/Left with iframes
|
||||||
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
|
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
|
||||||
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
|
ifDoc.write( "<div style='width: 1000px; height: 1000px;'></div>" );
|
||||||
|
@ -196,6 +196,7 @@ QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( as
|
|||||||
promised = false;
|
promised = false;
|
||||||
|
|
||||||
foo.queue( function( next ) {
|
foo.queue( function( next ) {
|
||||||
|
|
||||||
// called twice!
|
// called twice!
|
||||||
assert.ok( !promised, "Promised hasn't been called" );
|
assert.ok( !promised, "Promised hasn't been called" );
|
||||||
setTimeout( next, 10 );
|
setTimeout( next, 10 );
|
||||||
@ -261,7 +262,6 @@ QUnit.test( ".promise(obj)", function( assert ) {
|
|||||||
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
if ( jQuery.fn.stop ) {
|
if ( jQuery.fn.stop ) {
|
||||||
QUnit.test( "delay() can be stopped", function( assert ) {
|
QUnit.test( "delay() can be stopped", function( assert ) {
|
||||||
assert.expect( 3 );
|
assert.expect( 3 );
|
||||||
|
@ -111,6 +111,7 @@ testIframeWithCallback(
|
|||||||
"reliableMarginRight": true
|
"reliableMarginRight": true
|
||||||
};
|
};
|
||||||
} else if ( /chrome/i.test( userAgent ) ) {
|
} else if ( /chrome/i.test( userAgent ) ) {
|
||||||
|
|
||||||
// Catches Chrome on Android as well (i.e. the default
|
// Catches Chrome on Android as well (i.e. the default
|
||||||
// Android browser on Android >= 4.4).
|
// Android browser on Android >= 4.4).
|
||||||
expected = {
|
expected = {
|
||||||
@ -270,6 +271,7 @@ testIframeWithCallback(
|
|||||||
assert.expect( j );
|
assert.expect( j );
|
||||||
|
|
||||||
for ( i in expected ) {
|
for ( i in expected ) {
|
||||||
|
|
||||||
// TODO check for all modules containing support properties
|
// TODO check for all modules containing support properties
|
||||||
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
||||||
assert.equal( computedSupport[ i ], expected[ i ],
|
assert.equal( computedSupport[ i ], expected[ i ],
|
||||||
|
@ -279,7 +279,6 @@ QUnit.test("filter(jQuery)", function( assert ) {
|
|||||||
assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
|
assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
QUnit.test( "filter() with positional selectors", function( assert ) {
|
QUnit.test( "filter() with positional selectors", function( assert ) {
|
||||||
assert.expect( 19 );
|
assert.expect( 19 );
|
||||||
|
|
||||||
@ -734,7 +733,6 @@ QUnit.test("add(String html)", function( assert ) {
|
|||||||
|
|
||||||
assert.ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
|
assert.ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
|
||||||
|
|
||||||
|
|
||||||
x = jQuery( [] ).add( "<p id='x1'>xxx</p>" ).add( "<p id='x2'>xxx</p>" );
|
x = jQuery( [] ).add( "<p id='x1'>xxx</p>" ).add( "<p id='x2'>xxx</p>" );
|
||||||
assert.equal( x[ 0 ].id, "x1", "Check detached element1" );
|
assert.equal( x[ 0 ].id, "x1", "Check detached element1" );
|
||||||
assert.equal( x[ 1 ].id, "x2", "Check detached element2" );
|
assert.equal( x[ 1 ].id, "x2", "Check detached element2" );
|
||||||
|
@ -28,27 +28,45 @@ function testWrap( val , assert ) {
|
|||||||
defaultText = "Try them out:";
|
defaultText = "Try them out:";
|
||||||
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
||||||
|
|
||||||
assert.equal( defaultText, result, "Check for wrapping of on-the-fly html" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
defaultText, result, "Check for wrapping of on-the-fly html"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||||
|
);
|
||||||
|
|
||||||
result = jQuery( "#first" ).wrap( val( document.getElementById( "empty" ) ) ).parent();
|
result = jQuery( "#first" ).wrap( val( document.getElementById( "empty" ) ) ).parent();
|
||||||
assert.ok( result.is("ol"), "Check for element wrapping" );
|
assert.ok(
|
||||||
assert.equal( result.text(), defaultText, "Check for element wrapping" );
|
result.is( "ol" ), "Check for element wrapping"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
result.text(), defaultText, "Check for element wrapping"
|
||||||
|
);
|
||||||
|
|
||||||
jQuery( "#check1" ).on( "click", function() {
|
jQuery( "#check1" ).on( "click", function() {
|
||||||
var checkbox = this;
|
var checkbox = this;
|
||||||
|
|
||||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
assert.ok(
|
||||||
|
checkbox.checked, "Checkbox's state is erased after wrap() action, see #769"
|
||||||
|
);
|
||||||
jQuery( checkbox ).wrap( val( "<div id='c1' style='display:none;'></div>" ) );
|
jQuery( checkbox ).wrap( val( "<div id='c1' style='display:none;'></div>" ) );
|
||||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
assert.ok(
|
||||||
|
checkbox.checked, "Checkbox's state is erased after wrap() action, see #769"
|
||||||
|
);
|
||||||
} ).prop( "checked", false )[ 0 ].click();
|
} ).prop( "checked", false )[ 0 ].click();
|
||||||
|
|
||||||
// using contents will get comments regular, text, and comment nodes
|
// using contents will get comments regular, text, and comment nodes
|
||||||
j = jQuery( "#nonnodes" ).contents();
|
j = jQuery( "#nonnodes" ).contents();
|
||||||
j.wrap( val( "<i></i>" ) );
|
j.wrap( val( "<i></i>" ) );
|
||||||
|
|
||||||
assert.equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
|
assert.equal(
|
||||||
assert.equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
|
jQuery( "#nonnodes > i" ).length, jQuery( "#nonnodes" )[ 0 ].childNodes.length,
|
||||||
|
"Check node,textnode,comment wraps ok"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#nonnodes > i" ).text(), j.text(),
|
||||||
|
"Check node,textnode,comment wraps doesn't hurt text"
|
||||||
|
);
|
||||||
|
|
||||||
// Try wrapping a disconnected node
|
// Try wrapping a disconnected node
|
||||||
cacheLength = 0;
|
cacheLength = 0;
|
||||||
@ -57,32 +75,53 @@ function testWrap( val , assert ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
j = jQuery( "<label/>" ).wrap( val( "<li/>" ) );
|
j = jQuery( "<label/>" ).wrap( val( "<li/>" ) );
|
||||||
assert.equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
|
assert.equal(
|
||||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
|
j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped"
|
||||||
|
);
|
||||||
|
|
||||||
for ( i in jQuery.cache ) {
|
for ( i in jQuery.cache ) {
|
||||||
cacheLength--;
|
cacheLength--;
|
||||||
}
|
}
|
||||||
assert.equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
|
assert.equal(
|
||||||
|
cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)"
|
||||||
|
);
|
||||||
|
|
||||||
// Wrap an element containing a text node
|
// Wrap an element containing a text node
|
||||||
j = jQuery( "<span/>" ).wrap( "<div>test</div>" );
|
j = jQuery( "<span/>" ).wrap( "<div>test</div>" );
|
||||||
assert.equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
|
assert.equal(
|
||||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
|
j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element."
|
||||||
|
);
|
||||||
|
|
||||||
// Try to wrap an element with multiple elements (should fail)
|
// Try to wrap an element with multiple elements (should fail)
|
||||||
j = jQuery( "<div><span></span></div>" ).children().wrap( "<p></p><div></div>" );
|
j = jQuery( "<div><span></span></div>" ).children().wrap( "<p></p><div></div>" );
|
||||||
assert.equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
|
assert.equal(
|
||||||
assert.equal( j.length, 1, "There should only be one element (no cloning)." );
|
j[ 0 ].parentNode.parentNode.childNodes.length, 1,
|
||||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
|
"There should only be one element wrapping."
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
j.length, 1, "There should only be one element (no cloning)."
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph."
|
||||||
|
);
|
||||||
|
|
||||||
// Wrap an element with a jQuery set
|
// Wrap an element with a jQuery set
|
||||||
j = jQuery( "<span/>" ).wrap( jQuery( "<div></div>" ) );
|
j = jQuery( "<span/>" ).wrap( jQuery( "<div></div>" ) );
|
||||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
assert.equal(
|
||||||
|
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||||
|
);
|
||||||
|
|
||||||
// Wrap an element with a jQuery set and event
|
// Wrap an element with a jQuery set and event
|
||||||
result = jQuery( "<div></div>" ).on( "click", function() {
|
result = jQuery( "<div></div>" ).on( "click", function() {
|
||||||
assert.ok( true, "Event triggered." );
|
assert.ok(
|
||||||
|
true, "Event triggered."
|
||||||
|
);
|
||||||
|
|
||||||
// Remove handlers on detached elements
|
// Remove handlers on detached elements
|
||||||
result.off();
|
result.off();
|
||||||
@ -90,7 +129,9 @@ function testWrap( val , assert ) {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
j = jQuery( "<span/>" ).wrap( result );
|
j = jQuery( "<span/>" ).wrap( result );
|
||||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
assert.equal(
|
||||||
|
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||||
|
);
|
||||||
|
|
||||||
j.parent().trigger( "click" );
|
j.parent().trigger( "click" );
|
||||||
}
|
}
|
||||||
@ -109,7 +150,10 @@ QUnit.test( "wrap(Function) with index (#10177)", function( assert ) {
|
|||||||
|
|
||||||
assert.expect( targets.length );
|
assert.expect( targets.length );
|
||||||
targets.wrap( function( i ) {
|
targets.wrap( function( i ) {
|
||||||
assert.equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
|
assert.equal(
|
||||||
|
i, expectedIndex,
|
||||||
|
"Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")"
|
||||||
|
);
|
||||||
expectedIndex++;
|
expectedIndex++;
|
||||||
|
|
||||||
return "<div id='wrap_index_'" + i + "'></div>";
|
return "<div id='wrap_index_'" + i + "'></div>";
|
||||||
@ -125,8 +169,12 @@ QUnit.test( "wrap(String) consecutive elements (#10177)", function( assert ) {
|
|||||||
targets.each( function() {
|
targets.each( function() {
|
||||||
var $this = jQuery( this );
|
var $this = jQuery( this );
|
||||||
|
|
||||||
assert.ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
|
assert.ok(
|
||||||
assert.equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
|
$this.parent().is( ".wrapper" ), "Check each elements parent is correct (.wrapper)"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
$this.siblings().length, 0, "Each element should be wrapped individually"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -140,11 +188,21 @@ QUnit.test( "wrapAll(String)", function( assert ) {
|
|||||||
p = jQuery( "#firstp,#first" )[ 0 ].parentNode;
|
p = jQuery( "#firstp,#first" )[ 0 ].parentNode;
|
||||||
result = jQuery( "#firstp,#first" ).wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
result = jQuery( "#firstp,#first" ).wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
||||||
|
|
||||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||||
assert.ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
);
|
||||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
assert.ok(
|
||||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
|
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).parent().parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||||
|
);
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -157,11 +215,21 @@ QUnit.test( "wrapAll(Function)", function( assert ) {
|
|||||||
return "<div class='red'><div class='tmp'></div></div>";
|
return "<div class='red'><div class='tmp'></div></div>";
|
||||||
} );
|
} );
|
||||||
|
|
||||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
assert.equal(
|
||||||
assert.ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||||
assert.ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
);
|
||||||
assert.ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
assert.ok(
|
||||||
assert.strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent"
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) {
|
QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) {
|
||||||
@ -174,11 +242,17 @@ QUnit.test( "wrapAll(Function) check execution characteristics", function( asser
|
|||||||
return "";
|
return "";
|
||||||
} );
|
} );
|
||||||
|
|
||||||
assert.ok( !i, "should not execute function argument if target element does not exist" );
|
assert.ok(
|
||||||
|
!i, "should not execute function argument if target element does not exist"
|
||||||
|
);
|
||||||
|
|
||||||
jQuery( "#firstp" ).wrapAll( function( index ) {
|
jQuery( "#firstp" ).wrapAll( function( index ) {
|
||||||
assert.strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
assert.strictEqual(
|
||||||
assert.strictEqual( index, undefined, "index argument should not be included in function execution" );
|
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
index, undefined, "index argument should not be included in function execution"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -191,9 +265,15 @@ QUnit.test( "wrapAll(Element)", function( assert ) {
|
|||||||
p = jQuery( "#first" )[ 0 ].parentNode;
|
p = jQuery( "#first" )[ 0 ].parentNode;
|
||||||
jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) );
|
jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) );
|
||||||
|
|
||||||
assert.equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
|
assert.equal(
|
||||||
assert.equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
jQuery( "#first" ).parent()[ 0 ], jQuery( "#firstp" ).parent()[ 0 ], "Same Parent"
|
||||||
assert.equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapInner(String)", function( assert ) {
|
QUnit.test( "wrapInner(String)", function( assert ) {
|
||||||
@ -205,15 +285,27 @@ QUnit.test( "wrapInner(String)", function( assert ) {
|
|||||||
num = jQuery( "#first" ).children().length;
|
num = jQuery( "#first" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||||
|
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
|
|
||||||
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapInner(Element)", function( assert ) {
|
QUnit.test( "wrapInner(Element)", function( assert ) {
|
||||||
@ -225,13 +317,23 @@ QUnit.test( "wrapInner(Element)", function( assert ) {
|
|||||||
|
|
||||||
num = jQuery( "#first" ).children().length;
|
num = jQuery( "#first" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( document.getElementById( "empty" ) );
|
jQuery( "#first" ).wrapInner( document.getElementById( "empty" ) );
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
|
|
||||||
div.wrapInner( "<span></span>" );
|
div.wrapInner( "<span></span>" );
|
||||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
assert.equal(
|
||||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
div.children().length, 1, "The contents were wrapped."
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
||||||
@ -244,15 +346,27 @@ QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
|||||||
num = jQuery( "#first" ).children().length;
|
num = jQuery( "#first" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
||||||
|
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
|
|
||||||
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( ".red" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
||||||
@ -265,39 +379,78 @@ QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
|||||||
|
|
||||||
num = jQuery( "#first" ).children().length;
|
num = jQuery( "#first" ).children().length;
|
||||||
jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) );
|
jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) );
|
||||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
assert.equal(
|
||||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
);
|
||||||
|
assert.ok(
|
||||||
|
jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element"
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||||
|
);
|
||||||
|
|
||||||
div.wrapInner( val( "<span></span>" ) );
|
div.wrapInner( val( "<span></span>" ) );
|
||||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
assert.equal(
|
||||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
div.children().length, 1, "The contents were wrapped."
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "unwrap()", function( assert ) {
|
QUnit.test( "unwrap()", function( assert ) {
|
||||||
|
|
||||||
assert.expect( 9 );
|
assert.expect( 9 );
|
||||||
|
|
||||||
jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
|
jQuery( "body" ).append(
|
||||||
|
" <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
|
||||||
|
" <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'>" +
|
||||||
|
" <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'>" +
|
||||||
|
" <b><span class='unwrap unwrap3'>e</span></b>" +
|
||||||
|
" <b><span class='unwrap unwrap3'>f</span></b> </div> </div>"
|
||||||
|
);
|
||||||
|
|
||||||
var abcd = jQuery( "#unwrap1 > span, #unwrap2 > span" ).get(),
|
var abcd = jQuery( "#unwrap1 > span, #unwrap2 > span" ).get(),
|
||||||
abcdef = jQuery( "#unwrap span" ).get();
|
abcdef = jQuery( "#unwrap span" ).get();
|
||||||
|
|
||||||
assert.equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
assert.equal(
|
||||||
assert.deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
jQuery( "#unwrap1 span" ).add( "#unwrap2 span:first-child" ).unwrap().length, 3,
|
||||||
|
"make #unwrap1 and #unwrap2 go away"
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap > span" ).get(), abcd, "all four spans should still exist"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap3 > span" ).get(),
|
||||||
|
"make all b in #unwrap3 go away"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap > span.unwrap3" ).get(),
|
||||||
|
"make #unwrap3 go away"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap" ).children().get(), abcdef, "#unwrap only contains 6 child spans"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap > span" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(),
|
||||||
|
"make the 6 spans become children of body"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
assert.deepEqual(
|
||||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
jQuery( "body > span.unwrap" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(),
|
||||||
|
"can't unwrap children of body"
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
jQuery( "body > span.unwrap" ).unwrap().get(), abcdef, "can't unwrap children of body"
|
||||||
|
);
|
||||||
|
|
||||||
assert.deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
assert.deepEqual(
|
||||||
|
jQuery( "body > span.unwrap" ).get(), abcdef, "body contains 6 .unwrap child spans"
|
||||||
|
);
|
||||||
|
|
||||||
jQuery( "body > span.unwrap" ).remove();
|
jQuery( "body > span.unwrap" ).remove();
|
||||||
} );
|
} );
|
||||||
@ -306,23 +459,40 @@ QUnit.test( "unwrap( selector )", function( assert ) {
|
|||||||
|
|
||||||
assert.expect( 5 );
|
assert.expect( 5 );
|
||||||
|
|
||||||
jQuery( "body" ).append( " <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> </div>" );
|
jQuery( "body" ).append(
|
||||||
|
" <div id='unwrap' style='display: none;'> <div id='unwrap1'>" +
|
||||||
|
"<span class='unwrap'>a</span> <span class='unwrap'>b</span> </div>" +
|
||||||
|
" <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span>" +
|
||||||
|
" </div> </div>"
|
||||||
|
);
|
||||||
|
|
||||||
// Shouldn't unwrap, no match
|
// Shouldn't unwrap, no match
|
||||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" );
|
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" );
|
||||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
assert.equal(
|
||||||
|
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||||
|
);
|
||||||
|
|
||||||
// Shouldn't unwrap, no match
|
// Shouldn't unwrap, no match
|
||||||
jQuery( "#unwrap1 span" ) .unwrap( "span" );
|
jQuery( "#unwrap1 span" ) .unwrap( "span" );
|
||||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
assert.equal(
|
||||||
|
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||||
|
);
|
||||||
|
|
||||||
// Unwraps
|
// Unwraps
|
||||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" );
|
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" );
|
||||||
assert.equal( jQuery("#unwrap1").length, 0, "unwrapped match" );
|
assert.equal(
|
||||||
|
jQuery( "#unwrap1" ).length, 0, "unwrapped match"
|
||||||
|
);
|
||||||
|
|
||||||
// Check return values
|
// Check return values
|
||||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" );
|
assert.deepEqual(
|
||||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" );
|
jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(),
|
||||||
|
"return on unmatched unwrap"
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(),
|
||||||
|
"return on matched unwrap"
|
||||||
|
);
|
||||||
|
|
||||||
jQuery( "body > span.unwrap" ).remove();
|
jQuery( "body > span.unwrap" ).remove();
|
||||||
} );
|
} );
|
||||||
@ -336,8 +506,14 @@ QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", f
|
|||||||
|
|
||||||
$wraptarget.wrapAll( "<aside style='background-color:green'></aside>" );
|
$wraptarget.wrapAll( "<aside style='background-color:green'></aside>" );
|
||||||
|
|
||||||
assert.notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
|
assert.notEqual(
|
||||||
assert.notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
|
$wraptarget.parent( "aside" ).get( 0 ).style.backgroundColor, "transparent",
|
||||||
|
"HTML5 elements created with wrapAll inherit styles"
|
||||||
|
);
|
||||||
|
assert.notEqual(
|
||||||
|
$section.get( 0 ).style.backgroundColor, "transparent",
|
||||||
|
"HTML5 elements create with jQuery( string ) inherit styles"
|
||||||
|
);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "wrapping scripts (#10470)", function( assert ) {
|
QUnit.test( "wrapping scripts (#10470)", function( assert ) {
|
||||||
@ -345,12 +521,15 @@ QUnit.test( "wrapping scripts (#10470)", function( assert ) {
|
|||||||
assert.expect( 2 );
|
assert.expect( 2 );
|
||||||
|
|
||||||
var script = document.createElement( "script" );
|
var script = document.createElement( "script" );
|
||||||
script.text = script.textContent = "ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
|
script.text = script.textContent =
|
||||||
|
"ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
|
||||||
|
|
||||||
document.eval10470 = false;
|
document.eval10470 = false;
|
||||||
jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script );
|
jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script );
|
||||||
jQuery( "#qunit-fixture script" ).wrap( "<b></b>" );
|
jQuery( "#qunit-fixture script" ).wrap( "<b></b>" );
|
||||||
assert.strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
|
assert.strictEqual(
|
||||||
|
script.parentNode, jQuery( "#qunit-fixture > b" )[ 0 ], "correctly wrapped"
|
||||||
|
);
|
||||||
jQuery( script ).remove();
|
jQuery( script ).remove();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user