mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
parent
fa8a5a90e1
commit
20ddbe4f59
11
.jscsrc
11
.jscsrc
@ -1,6 +1,13 @@
|
||||
{
|
||||
"preset": "jquery",
|
||||
|
||||
"excludeFiles": [ "external", "src/intro.js", "src/outro.js",
|
||||
"test/node_smoke_tests/lib/ensure_iterability.js" ]
|
||||
// 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",
|
||||
"node_modules",
|
||||
"test/node_smoke_tests/lib/ensure_iterability.js"
|
||||
]
|
||||
}
|
||||
|
@ -107,7 +107,12 @@ module.exports = function( grunt ) {
|
||||
gruntfile: "Gruntfile.js",
|
||||
|
||||
// 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"
|
||||
],
|
||||
build: "build"
|
||||
},
|
||||
testswarm: {
|
||||
|
@ -48,6 +48,7 @@ module.exports = function( Release ) {
|
||||
* for publishing the distribution repo instead
|
||||
*/
|
||||
npmTags: function() {
|
||||
|
||||
// origRepo is not defined if dist was skipped
|
||||
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
|
||||
return npmTags();
|
||||
|
@ -40,6 +40,7 @@ function makeReleaseCopies( Release ) {
|
||||
releaseFile = cdnFolder + "/" + unpathedFile;
|
||||
|
||||
if ( /\.map$/.test( releaseFile ) ) {
|
||||
|
||||
// Map files need to reference the new uncompressed name;
|
||||
// assume that all files reside in the same directory.
|
||||
// "file":"jquery.min.js","sources":["jquery.js"]
|
||||
@ -90,6 +91,7 @@ function makeArchives( Release, callback ) {
|
||||
} );
|
||||
|
||||
sum = Release.exec(
|
||||
|
||||
// Read jQuery files
|
||||
"md5sum " + files.join( " " ).replace( rcompat, "." ),
|
||||
"Error retrieving md5sum"
|
||||
@ -98,6 +100,7 @@ function makeArchives( Release, callback ) {
|
||||
files.push( md5file );
|
||||
|
||||
files.forEach( function( file ) {
|
||||
|
||||
// For Google, read jquery.js, write jquery-compat.js
|
||||
archiver.append( fs.createReadStream( file.replace( rcompat, "." ) ),
|
||||
{ name: path.basename( file ) } );
|
||||
|
@ -5,6 +5,7 @@ module.exports = function( Release, complete ) {
|
||||
shell = require( "shelljs" ),
|
||||
pkg = require( Release.dir.repo + "/package.json" ),
|
||||
distRemote = Release.remote.replace( "jquery.git", "jquery-compat-dist.git" ),
|
||||
|
||||
// These files are included with the distribution
|
||||
files = [
|
||||
"src",
|
||||
|
@ -34,6 +34,7 @@ function ensureSizzle( Release, callback ) {
|
||||
version = match ? match[ 1 ] : "Not Found";
|
||||
|
||||
if ( version !== latest ) {
|
||||
|
||||
// colors is inherited from jquery-release
|
||||
console.log(
|
||||
"The Sizzle version in the src folder (" + version.red +
|
||||
|
@ -38,7 +38,9 @@ http.request({
|
||||
console.log( "</ul>" );
|
||||
}
|
||||
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>" );
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,16 @@ module.exports = function( grunt ) {
|
||||
baseUrl: "src",
|
||||
name: "jquery",
|
||||
out: "dist/jquery.js",
|
||||
|
||||
// We have multiple minify steps
|
||||
optimize: "none",
|
||||
|
||||
// Include dependencies loaded with require
|
||||
findNestedDependencies: true,
|
||||
|
||||
// Avoid inserting define() placeholder
|
||||
skipModuleInsertion: true,
|
||||
|
||||
// Avoid breaking semicolons inserted by r.js
|
||||
skipSemiColonInsertion: true,
|
||||
wrap: {
|
||||
@ -47,6 +51,7 @@ module.exports = function( grunt ) {
|
||||
*/
|
||||
function convert( name, path, contents ) {
|
||||
var amdName;
|
||||
|
||||
// Convert var modules
|
||||
if ( /.\/var\//.test( path ) ) {
|
||||
contents = contents
|
||||
@ -56,6 +61,7 @@ module.exports = function( grunt ) {
|
||||
// Sizzle treatment
|
||||
} else if ( /^sizzle$/.test( name ) ) {
|
||||
contents = "var Sizzle =\n" + contents
|
||||
|
||||
// Remove EXPOSE lines from Sizzle
|
||||
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
|
||||
|
||||
@ -63,6 +69,7 @@ module.exports = function( grunt ) {
|
||||
|
||||
contents = contents
|
||||
.replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" )
|
||||
|
||||
// Multiple exports
|
||||
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
|
||||
|
||||
@ -82,6 +89,7 @@ module.exports = function( grunt ) {
|
||||
contents = contents
|
||||
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
|
||||
}
|
||||
|
||||
// AMD Name
|
||||
if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
|
||||
if ( amdName ) {
|
||||
@ -89,6 +97,7 @@ module.exports = function( grunt ) {
|
||||
} else {
|
||||
grunt.log.writeln( "AMD name now anonymous" );
|
||||
}
|
||||
|
||||
// Remove the comma for anonymous defines
|
||||
contents = contents
|
||||
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
|
||||
@ -122,6 +131,7 @@ module.exports = function( grunt ) {
|
||||
if ( list ) {
|
||||
prepend = prepend ? prepend + "/" : "";
|
||||
list.forEach( function( module ) {
|
||||
|
||||
// Exclude var modules as well
|
||||
if ( module === "var" ) {
|
||||
excludeList(
|
||||
@ -130,10 +140,12 @@ module.exports = function( grunt ) {
|
||||
return;
|
||||
}
|
||||
if ( prepend ) {
|
||||
|
||||
// Skip if this is not a js file and we're walking files in a dir
|
||||
if ( !( module = /([\w-\/]+)\.js$/.exec( module ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepend folder name if passed
|
||||
// Remove .js extension
|
||||
module = prepend + module[ 1 ];
|
||||
@ -158,16 +170,19 @@ module.exports = function( grunt ) {
|
||||
module = m[ 2 ];
|
||||
|
||||
if ( exclude ) {
|
||||
|
||||
// Can't exclude sizzle on this branch
|
||||
if ( module === "sizzle" ) {
|
||||
grunt.log.error( "Sizzle cannot be excluded on the compat branch." );
|
||||
|
||||
// Can't exclude certain modules
|
||||
} else if ( minimum.indexOf( module ) === -1 ) {
|
||||
|
||||
// Add to excluded
|
||||
if ( excluded.indexOf( module ) === -1 ) {
|
||||
grunt.log.writeln( flag );
|
||||
excluded.push( module );
|
||||
|
||||
// Exclude all files in the folder of the same name
|
||||
// These are the removable dependencies
|
||||
// It's fine if the directory is not there
|
||||
@ -177,6 +192,7 @@ module.exports = function( grunt ) {
|
||||
grunt.verbose.writeln( e );
|
||||
}
|
||||
}
|
||||
|
||||
// Check removeWith list
|
||||
excludeList( removeWith[ module ] );
|
||||
} else {
|
||||
@ -225,9 +241,11 @@ module.exports = function( grunt ) {
|
||||
// append excluded modules to version
|
||||
if ( excluded.length ) {
|
||||
version += " -" + excluded.join( ",-" );
|
||||
|
||||
// set pkg.version to version with excludes, so minified file picks it up
|
||||
grunt.config.set( "pkg.version", version );
|
||||
grunt.verbose.writeln( "Version changed to " + version );
|
||||
|
||||
// Have to use shallow or core will get excluded since it is a dependency
|
||||
config.excludeShallow = excluded;
|
||||
}
|
||||
@ -239,8 +257,10 @@ module.exports = function( grunt ) {
|
||||
*/
|
||||
config.out = function( compiled ) {
|
||||
compiled = compiled
|
||||
|
||||
// Embed Version
|
||||
.replace( /@VERSION/g, version )
|
||||
|
||||
// Embed Date
|
||||
// yyyy-mm-ddThh:mmZ
|
||||
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
|
||||
@ -251,6 +271,7 @@ module.exports = function( grunt ) {
|
||||
|
||||
// Turn off opt-in if necessary
|
||||
if ( !optIn ) {
|
||||
|
||||
// Overwrite the default inclusions with the explicit ones provided
|
||||
config.rawText.jquery = "define([" +
|
||||
( included.length ? included.join( "," ) : "" ) +
|
||||
|
@ -3,6 +3,7 @@ var fs = require( "fs" );
|
||||
module.exports = function( grunt ) {
|
||||
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
|
||||
grunt.registerTask( "remove_map_comment", function() {
|
||||
|
||||
// Remove the source map comment; it causes way too many problems.
|
||||
// The map file is still generated for manual associations
|
||||
// https://github.com/jquery/jquery/issues/1707
|
||||
|
@ -14,6 +14,7 @@ module.exports = function( grunt ) {
|
||||
config = grunt.file.readJSON( configFile )[ projectName ];
|
||||
browserSets = browserSets || config.browserSets;
|
||||
if ( browserSets[ 0 ] === "[" ) {
|
||||
|
||||
// We got an array, parse it
|
||||
browserSets = JSON.parse( browserSets );
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
"grunt-contrib-uglify": "0.7.0",
|
||||
"grunt-contrib-watch": "0.6.1",
|
||||
"grunt-git-authors": "2.0.1",
|
||||
"grunt-jscs-checker": "0.8.1",
|
||||
"grunt-jscs": "2.1.0",
|
||||
"grunt-jsonlint": "1.0.4",
|
||||
"grunt-npmcopy": "0.1.0",
|
||||
"gzip-js": "0.3.2",
|
||||
|
35
src/ajax.js
35
src/ajax.js
@ -15,6 +15,7 @@ var
|
||||
rhash = /#.*$/,
|
||||
rts = /([?&])_=[^&]*/,
|
||||
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
|
||||
|
||||
// #7653, #8125, #8152: local protocol detection
|
||||
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
|
||||
rnoContent = /^(?:GET|HEAD)$/,
|
||||
@ -62,8 +63,10 @@ function addToPrefiltersOrTransports( structure ) {
|
||||
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
|
||||
|
||||
if ( jQuery.isFunction( func ) ) {
|
||||
|
||||
// For each dataType in the dataTypeExpression
|
||||
while ( ( dataType = dataTypes[ i++ ] ) ) {
|
||||
|
||||
// Prepend if requested
|
||||
if ( dataType[ 0 ] === "+" ) {
|
||||
dataType = dataType.slice( 1 ) || "*";
|
||||
@ -155,6 +158,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
|
||||
if ( dataTypes[ 0 ] in responses ) {
|
||||
finalDataType = dataTypes[ 0 ];
|
||||
} else {
|
||||
|
||||
// Try convertible dataTypes
|
||||
for ( type in responses ) {
|
||||
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
|
||||
@ -165,6 +169,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
|
||||
firstDataType = type;
|
||||
}
|
||||
}
|
||||
|
||||
// Or just use first one
|
||||
finalDataType = finalDataType || firstDataType;
|
||||
}
|
||||
@ -186,6 +191,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
|
||||
function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
||||
var conv2, current, conv, tmp, prev,
|
||||
converters = {},
|
||||
|
||||
// Work with a copy of dataTypes in case we need to modify it for conversion
|
||||
dataTypes = s.dataTypes.slice();
|
||||
|
||||
@ -238,6 +244,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
||||
conv = converters[ prev + " " + tmp[ 0 ] ] ||
|
||||
converters[ "* " + tmp[ 0 ] ];
|
||||
if ( conv ) {
|
||||
|
||||
// Condense equivalence converters
|
||||
if ( conv === true ) {
|
||||
conv = converters[ conv2 ];
|
||||
@ -257,7 +264,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
||||
if ( conv !== true ) {
|
||||
|
||||
// Unless errors are allowed to bubble, catch and return them
|
||||
if ( conv && s[ "throws" ] ) {
|
||||
if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
|
||||
response = conv( response );
|
||||
} else {
|
||||
try {
|
||||
@ -382,43 +389,59 @@ jQuery.extend({
|
||||
options = options || {};
|
||||
|
||||
var
|
||||
|
||||
// Loop variable
|
||||
i,
|
||||
|
||||
// URL without anti-cache param
|
||||
cacheURL,
|
||||
|
||||
// Response headers as string
|
||||
responseHeadersString,
|
||||
|
||||
// timeout handle
|
||||
timeoutTimer,
|
||||
|
||||
// Url cleanup var
|
||||
urlAnchor,
|
||||
|
||||
// To know if global events are to be dispatched
|
||||
fireGlobals,
|
||||
|
||||
transport,
|
||||
|
||||
// Response headers
|
||||
responseHeaders,
|
||||
|
||||
// Create the final options object
|
||||
s = jQuery.ajaxSetup( {}, options ),
|
||||
|
||||
// Callbacks context
|
||||
callbackContext = s.context || s,
|
||||
|
||||
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
||||
globalEventContext = s.context &&
|
||||
( callbackContext.nodeType || callbackContext.jquery ) ?
|
||||
jQuery( callbackContext ) :
|
||||
jQuery.event,
|
||||
|
||||
// Deferreds
|
||||
deferred = jQuery.Deferred(),
|
||||
completeDeferred = jQuery.Callbacks( "once memory" ),
|
||||
|
||||
// Status-dependent callbacks
|
||||
statusCode = s.statusCode || {},
|
||||
|
||||
// Headers (they are sent all at once)
|
||||
requestHeaders = {},
|
||||
requestHeadersNames = {},
|
||||
|
||||
// The jqXHR state
|
||||
state = 0,
|
||||
|
||||
// Default abort message
|
||||
strAbort = "canceled",
|
||||
|
||||
// Fake xhr
|
||||
jqXHR = {
|
||||
readyState: 0,
|
||||
@ -467,10 +490,12 @@ jQuery.extend({
|
||||
if ( map ) {
|
||||
if ( state < 2 ) {
|
||||
for ( code in map ) {
|
||||
|
||||
// Lazy-add the new callback in a way that preserves old ones
|
||||
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
|
||||
}
|
||||
} else {
|
||||
|
||||
// Execute the appropriate callbacks
|
||||
jqXHR.always( map[ jqXHR.status ] );
|
||||
}
|
||||
@ -513,12 +538,14 @@ jQuery.extend({
|
||||
// IE throws exception if url is malformed, e.g. http://example.com:80x/
|
||||
try {
|
||||
urlAnchor.href = s.url;
|
||||
|
||||
// Support: IE8-11+
|
||||
// Anchor's host property isn't correctly set when s.url is relative
|
||||
urlAnchor.href = urlAnchor.href;
|
||||
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
|
||||
urlAnchor.protocol + "//" + urlAnchor.host;
|
||||
} catch ( e ) {
|
||||
|
||||
// If there is an error parsing the URL, assume it is crossDomain,
|
||||
// it can be rejected by the transport if it is invalid
|
||||
s.crossDomain = true;
|
||||
@ -563,6 +590,7 @@ jQuery.extend({
|
||||
// If data is available, append data to url
|
||||
if ( s.data ) {
|
||||
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
|
||||
|
||||
// #9682: remove data so that it's not used in an eventual retry
|
||||
delete s.data;
|
||||
}
|
||||
@ -654,9 +682,11 @@ jQuery.extend({
|
||||
state = 1;
|
||||
transport.send( requestHeaders, done );
|
||||
} catch ( e ) {
|
||||
|
||||
// Propagate exception as error if not done
|
||||
if ( state < 2 ) {
|
||||
done( -1, e );
|
||||
|
||||
// Simply rethrow otherwise
|
||||
} else {
|
||||
throw e;
|
||||
@ -734,6 +764,7 @@ jQuery.extend({
|
||||
isSuccess = !error;
|
||||
}
|
||||
} else {
|
||||
|
||||
// We extract error from statusText
|
||||
// then normalize statusText and status for non-aborts
|
||||
error = statusText;
|
||||
@ -770,6 +801,7 @@ jQuery.extend({
|
||||
|
||||
if ( fireGlobals ) {
|
||||
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
||||
|
||||
// Handle the global AJAX counter
|
||||
if ( !( --jQuery.active ) ) {
|
||||
jQuery.event.trigger( "ajaxStop" );
|
||||
@ -791,6 +823,7 @@ jQuery.extend({
|
||||
|
||||
jQuery.each( [ "get", "post" ], function( i, method ) {
|
||||
jQuery[ method ] = function( url, data, callback, type ) {
|
||||
|
||||
// shift arguments if data argument was omitted
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = type || callback;
|
||||
|
@ -64,6 +64,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||
|
||||
// Clean-up function (fires after converters)
|
||||
jqXHR.always( function() {
|
||||
|
||||
// If previous value didn't exist - remove it
|
||||
if ( overwritten === undefined ) {
|
||||
jQuery( window ).removeProp( callbackName );
|
||||
@ -75,6 +76,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||
|
||||
// Save back as free
|
||||
if ( s[ callbackName ] ) {
|
||||
|
||||
// make sure that re-using the options doesn't screw things around
|
||||
s.jsonpCallback = originalSettings.jsonpCallback;
|
||||
|
||||
|
@ -8,6 +8,7 @@ define([
|
||||
// Create the request object
|
||||
// (This is still attached to ajaxSettings for backward compatibility)
|
||||
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
|
||||
|
||||
// Support: IE8
|
||||
function() {
|
||||
|
||||
@ -35,6 +36,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
|
||||
return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
|
||||
createStandardXHR() || createActiveXHR();
|
||||
} :
|
||||
|
||||
// For all other browsers, use the standard XMLHttpRequest object
|
||||
createStandardXHR;
|
||||
|
||||
@ -48,6 +50,7 @@ xhrSupported = support.ajax = !!xhrSupported;
|
||||
if ( xhrSupported ) {
|
||||
|
||||
jQuery.ajaxTransport( function( options ) {
|
||||
|
||||
// Cross domain only allowed if supported through XMLHttpRequest
|
||||
if ( !options.crossDomain || support.cors ) {
|
||||
|
||||
@ -90,6 +93,7 @@ if ( xhrSupported ) {
|
||||
|
||||
// Set headers
|
||||
for ( i in headers ) {
|
||||
|
||||
// Support: IE<9
|
||||
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
|
||||
// request header to a null-value.
|
||||
@ -112,6 +116,7 @@ if ( xhrSupported ) {
|
||||
|
||||
// Was never called and is aborted or complete
|
||||
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
||||
|
||||
// Clean up
|
||||
callback = undefined;
|
||||
xhr.onreadystatechange = jQuery.noop;
|
||||
@ -137,6 +142,7 @@ if ( xhrSupported ) {
|
||||
try {
|
||||
statusText = xhr.statusText;
|
||||
} catch ( e ) {
|
||||
|
||||
// We normalize with Webkit giving an empty statusText
|
||||
statusText = "";
|
||||
}
|
||||
@ -148,6 +154,7 @@ if ( xhrSupported ) {
|
||||
// can do given current implementations)
|
||||
if ( !status && options.isLocal && !options.crossDomain ) {
|
||||
status = responses.text ? 200 : 404;
|
||||
|
||||
// IE - #1450: sometimes returns 1223 when it should be 204
|
||||
} else if ( status === 1223 ) {
|
||||
status = 204;
|
||||
@ -162,9 +169,11 @@ if ( xhrSupported ) {
|
||||
};
|
||||
|
||||
if ( !options.async ) {
|
||||
|
||||
// if we're in sync mode we fire the callback
|
||||
callback();
|
||||
} else {
|
||||
|
||||
// Add to the list of active xhr callbacks
|
||||
xhr.onreadystatechange = callback;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ jQuery.fn.extend({
|
||||
}
|
||||
|
||||
if ( proceed ) {
|
||||
|
||||
// The disjunction here is for better compressibility (see removeClass)
|
||||
classes = ( value || "" ).match( rnotwhite ) || [];
|
||||
|
||||
@ -78,6 +79,7 @@ jQuery.fn.extend({
|
||||
if ( cur ) {
|
||||
j = 0;
|
||||
while ( ( clazz = classes[ j++ ] ) ) {
|
||||
|
||||
// Remove *all* instances
|
||||
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
|
||||
cur = cur.replace( " " + clazz + " ", " " );
|
||||
|
@ -16,6 +16,7 @@ jQuery.fn.extend({
|
||||
removeProp: function( name ) {
|
||||
name = jQuery.propFix[ name ] || name;
|
||||
return this.each( function() {
|
||||
|
||||
// try/catch handles cases where IE balks (such as removing a property on window)
|
||||
try {
|
||||
this[ name ] = undefined;
|
||||
@ -61,6 +62,7 @@ jQuery.extend({
|
||||
propHooks: {
|
||||
tabIndex: {
|
||||
get: function( elem ) {
|
||||
|
||||
// elem.tabIndex doesn't always return the
|
||||
// correct value when it hasn't been explicitly set
|
||||
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
||||
|
@ -12,6 +12,7 @@ define([
|
||||
|
||||
// Setup
|
||||
div.innerHTML = " <link/><a href='/a'>a</a>";
|
||||
|
||||
// Support: Windows Web Apps (WWA)
|
||||
// `type` must use .setAttribute for WWA (#14901)
|
||||
input.setAttribute( "type", "checkbox" );
|
||||
|
@ -16,15 +16,21 @@ jQuery.fn.extend({
|
||||
hooks = jQuery.valHooks[ elem.type ] ||
|
||||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
||||
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
||||
if (
|
||||
hooks &&
|
||||
"get" in hooks &&
|
||||
( ret = hooks.get( elem, "value" ) ) !== undefined
|
||||
) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = elem.value;
|
||||
|
||||
return typeof ret === "string" ?
|
||||
|
||||
// handle most common string cases
|
||||
ret.replace( rreturn, "" ) :
|
||||
|
||||
// handle cases where value is null/undef or number
|
||||
ret == null ? "" : ret;
|
||||
}
|
||||
@ -72,6 +78,7 @@ jQuery.extend({
|
||||
valHooks: {
|
||||
option: {
|
||||
get: function( elem ) {
|
||||
|
||||
// Support: IE<11
|
||||
// option.value not trimmed (#14858)
|
||||
return jQuery.trim( elem.value );
|
||||
@ -96,6 +103,7 @@ jQuery.extend({
|
||||
// Support: IE<10
|
||||
// IE8-9 doesn't update selected after form reset (#2551)
|
||||
if ( ( option.selected || i === index ) &&
|
||||
|
||||
// Don't return options that are disabled or in a disabled optgroup
|
||||
( support.optDisabled ?
|
||||
!option.disabled :
|
||||
@ -127,8 +135,10 @@ jQuery.extend({
|
||||
|
||||
while ( i-- ) {
|
||||
option = options[ i ];
|
||||
if ( (option.selected =
|
||||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1) ) {
|
||||
if (
|
||||
option.selected =
|
||||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
|
||||
) {
|
||||
optionSet = true;
|
||||
}
|
||||
}
|
||||
|
@ -44,18 +44,25 @@ jQuery.Callbacks = function( options ) {
|
||||
|
||||
var // Flag to know if list is currently firing
|
||||
firing,
|
||||
|
||||
// Last fire value for non-forgettable lists
|
||||
memory,
|
||||
|
||||
// Flag to know if list was already fired
|
||||
fired,
|
||||
|
||||
// Flag to prevent firing
|
||||
locked,
|
||||
|
||||
// Actual callback list
|
||||
list = [],
|
||||
|
||||
// Queue of execution data for repeatable lists
|
||||
queue = [],
|
||||
|
||||
// Index of currently firing callback (modified by add/remove as needed)
|
||||
firingIndex = -1,
|
||||
|
||||
// Fire callbacks
|
||||
fire = function() {
|
||||
|
||||
@ -121,6 +128,7 @@ jQuery.Callbacks = function( options ) {
|
||||
list.push( arg );
|
||||
}
|
||||
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
|
||||
|
||||
// Inspect recursively
|
||||
add( arg );
|
||||
}
|
||||
|
10
src/core.js
10
src/core.js
@ -17,6 +17,7 @@ var
|
||||
|
||||
// Define a local copy of jQuery
|
||||
jQuery = function( selector, context ) {
|
||||
|
||||
// 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)
|
||||
return new jQuery.fn.init( selector, context );
|
||||
@ -36,6 +37,7 @@ var
|
||||
};
|
||||
|
||||
jQuery.fn = jQuery.prototype = {
|
||||
|
||||
// The current version of jQuery being used
|
||||
jquery: version,
|
||||
|
||||
@ -142,8 +144,10 @@ jQuery.extend = jQuery.fn.extend = function() {
|
||||
}
|
||||
|
||||
for ( ; i < length; i++ ) {
|
||||
|
||||
// Only deal with non-null/undefined values
|
||||
if ( ( options = arguments[ i ] ) != null ) {
|
||||
|
||||
// Extend the base object
|
||||
for ( name in options ) {
|
||||
src = target[ name ];
|
||||
@ -182,6 +186,7 @@ jQuery.extend = jQuery.fn.extend = function() {
|
||||
};
|
||||
|
||||
jQuery.extend( {
|
||||
|
||||
// Unique for each copy of jQuery on the page
|
||||
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
|
||||
|
||||
@ -211,6 +216,7 @@ jQuery.extend({
|
||||
},
|
||||
|
||||
isNumeric: function( obj ) {
|
||||
|
||||
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
|
||||
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
|
||||
// subtraction forces infinities to NaN
|
||||
@ -237,6 +243,7 @@ jQuery.extend({
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Not own constructor property must be Object
|
||||
if ( obj.constructor &&
|
||||
!hasOwn.call( obj, "constructor" ) &&
|
||||
@ -244,6 +251,7 @@ jQuery.extend({
|
||||
return false;
|
||||
}
|
||||
} catch ( e ) {
|
||||
|
||||
// IE8,9 Will throw exceptions on certain host objects #9897
|
||||
return false;
|
||||
}
|
||||
@ -274,6 +282,7 @@ jQuery.extend({
|
||||
|
||||
// Evaluates a script in a global context
|
||||
globalEval: function( data ) {
|
||||
|
||||
// Inspired by code by Andrea Giammarchi
|
||||
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
||||
var head = document.head || jQuery( "head" )[ 0 ] || document.documentElement,
|
||||
@ -353,6 +362,7 @@ jQuery.extend({
|
||||
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
||||
|
||||
for ( ; i < len; i++ ) {
|
||||
|
||||
// Skip accessing in sparse arrays
|
||||
if ( i in arr && arr[ i ] === elem ) {
|
||||
return i;
|
||||
|
@ -25,6 +25,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
||||
}
|
||||
|
||||
if ( bulk ) {
|
||||
|
||||
// Bulk operations run against the entire set
|
||||
if ( raw ) {
|
||||
fn.call( elems, value );
|
||||
@ -41,7 +42,11 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
|
||||
|
||||
if ( fn ) {
|
||||
for ( ; i < length; 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 ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ var rootjQuery,
|
||||
// HANDLE: $(html, props)
|
||||
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
|
||||
for ( match in context ) {
|
||||
|
||||
// Properties of context are called as methods if possible
|
||||
if ( jQuery.isFunction( this[ match ] ) ) {
|
||||
this[ match ]( context[ match ] );
|
||||
@ -76,6 +77,7 @@ var rootjQuery,
|
||||
elem = document.getElementById( match[ 2 ] );
|
||||
|
||||
if ( elem ) {
|
||||
|
||||
// Inject the element directly into the jQuery object
|
||||
this[ 0 ] = elem;
|
||||
this.length = 1;
|
||||
@ -104,6 +106,7 @@ var rootjQuery,
|
||||
} else if ( jQuery.isFunction( selector ) ) {
|
||||
return typeof root.ready !== "undefined" ?
|
||||
root.ready( selector ) :
|
||||
|
||||
// Execute immediately if ready is not present
|
||||
selector( jQuery );
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
|
||||
keepScripts = context;
|
||||
context = false;
|
||||
}
|
||||
|
||||
// document.implementation stops scripts or inline event handlers from
|
||||
// being executed immediately
|
||||
context = context || ( support.createHTMLDocument ?
|
||||
|
@ -8,6 +8,7 @@ define([
|
||||
var readyList;
|
||||
|
||||
jQuery.fn.ready = function( fn ) {
|
||||
|
||||
// Add the callback
|
||||
jQuery.ready.promise().done( fn );
|
||||
|
||||
@ -15,6 +16,7 @@ jQuery.fn.ready = function( fn ) {
|
||||
};
|
||||
|
||||
jQuery.extend( {
|
||||
|
||||
// Is the DOM ready to be used? Set to true once it occurs.
|
||||
isReady: false,
|
||||
|
||||
@ -71,6 +73,7 @@ function detach() {
|
||||
* The ready event handler and self cleanup method
|
||||
*/
|
||||
function completed() {
|
||||
|
||||
// readyState === "complete" is good enough for us to call the dom ready in oldIE
|
||||
if ( document.addEventListener ||
|
||||
window.event.type === "load" ||
|
||||
@ -93,11 +96,13 @@ jQuery.ready.promise = function( obj ) {
|
||||
// discovered by ChrisS here:
|
||||
// http://bugs.jquery.com/ticket/12282#comment:15
|
||||
if ( document.readyState === "complete" ) {
|
||||
|
||||
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
||||
window.setTimeout( jQuery.ready );
|
||||
|
||||
// Standards-based browsers support DOMContentLoaded
|
||||
} else if ( document.addEventListener ) {
|
||||
|
||||
// Use the handy event callback
|
||||
document.addEventListener( "DOMContentLoaded", completed );
|
||||
|
||||
@ -107,6 +112,7 @@ jQuery.ready.promise = function( obj ) {
|
||||
// Support: IE<9
|
||||
// If IE event model is used
|
||||
} else {
|
||||
|
||||
// Ensure firing before onload, maybe late but safe also for iframes
|
||||
document.attachEvent( "onreadystatechange", completed );
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
define( function() {
|
||||
|
||||
// Match a standalone tag
|
||||
return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
|
||||
} );
|
||||
|
19
src/css.js
19
src/css.js
@ -22,6 +22,7 @@ define([
|
||||
isHidden, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) {
|
||||
|
||||
var
|
||||
|
||||
// BuildExclude
|
||||
getStyles = curCSS.getStyles,
|
||||
ralpha = /alpha\([^)]*\)/i,
|
||||
@ -69,6 +70,7 @@ function vendorPropName( name ) {
|
||||
function setPositiveNumber( elem, value, subtract ) {
|
||||
var matches = rnumsplit.exec( value );
|
||||
return matches ?
|
||||
|
||||
// Guard against undefined "subtract", e.g., when used as in cssHooks
|
||||
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
|
||||
value;
|
||||
@ -76,20 +78,24 @@ function setPositiveNumber( elem, value, subtract ) {
|
||||
|
||||
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
||||
var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
||||
|
||||
// If we already have the right measurement, avoid augmentation
|
||||
4 :
|
||||
|
||||
// Otherwise initialize for horizontal or vertical properties
|
||||
name === "width" ? 1 : 0,
|
||||
|
||||
val = 0;
|
||||
|
||||
for ( ; i < 4; i += 2 ) {
|
||||
|
||||
// both box models exclude margin, so add it if we want it
|
||||
if ( extra === "margin" ) {
|
||||
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
|
||||
}
|
||||
|
||||
if ( isBorderBox ) {
|
||||
|
||||
// border-box includes padding, so remove it if we want content
|
||||
if ( extra === "content" ) {
|
||||
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
||||
@ -100,6 +106,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
|
||||
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
|
||||
}
|
||||
} else {
|
||||
|
||||
// at this point, extra isn't content, so add padding
|
||||
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
|
||||
|
||||
@ -122,6 +129,7 @@ function getWidthOrHeight( elem, name, extra ) {
|
||||
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
||||
|
||||
if ( support.gBCRDimensions() ) {
|
||||
|
||||
// Support: IE <= 11 only
|
||||
// Running getBoundingClientRect on a disconnected node
|
||||
// in IE throws an error.
|
||||
@ -129,6 +137,7 @@ function getWidthOrHeight( elem, name, extra ) {
|
||||
val = elem.getBoundingClientRect()[ name ];
|
||||
}
|
||||
} else {
|
||||
|
||||
// In IE8 gBCR doesn't report width & height; we need to fall back to offset*.
|
||||
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
|
||||
}
|
||||
@ -144,6 +153,7 @@ function getWidthOrHeight( elem, name, extra ) {
|
||||
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
|
||||
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
|
||||
if ( val <= 0 || val == null ) {
|
||||
|
||||
// Fall back to computed then uncomputed css if necessary
|
||||
val = curCSS( elem, name, styles );
|
||||
if ( val < 0 || val == null ) {
|
||||
@ -177,12 +187,14 @@ function getWidthOrHeight( elem, name, extra ) {
|
||||
}
|
||||
|
||||
jQuery.extend( {
|
||||
|
||||
// Add in style property hooks for overriding the default
|
||||
// behavior of getting and setting a style property
|
||||
cssHooks: {
|
||||
opacity: {
|
||||
get: function( elem, computed ) {
|
||||
if ( computed ) {
|
||||
|
||||
// We should always get a number back from opacity
|
||||
var ret = curCSS( elem, "opacity" );
|
||||
return ret === "" ? "1" : ret;
|
||||
@ -210,12 +222,14 @@ jQuery.extend({
|
||||
// Add in properties whose names you wish to fix before
|
||||
// setting or getting the value
|
||||
cssProps: {
|
||||
|
||||
// normalize float css property
|
||||
"float": support.cssFloat ? "cssFloat" : "styleFloat"
|
||||
},
|
||||
|
||||
// Get and set the style property on a DOM Node
|
||||
style: function( elem, name, value, extra ) {
|
||||
|
||||
// Don't set styles on text and comment nodes
|
||||
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
||||
return;
|
||||
@ -240,6 +254,7 @@ jQuery.extend({
|
||||
// Convert "+=" or "-=" to relative numbers (#7345)
|
||||
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
|
||||
value = adjustCSS( elem, name, ret );
|
||||
|
||||
// Fixes bug #9237
|
||||
type = "number";
|
||||
}
|
||||
@ -273,6 +288,7 @@ jQuery.extend({
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// If a hook was provided get the non-computed value from there
|
||||
if ( hooks && "get" in hooks &&
|
||||
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
|
||||
@ -325,9 +341,11 @@ jQuery.each([ "height", "width" ], function( i, name ) {
|
||||
jQuery.cssHooks[ name ] = {
|
||||
get: function( elem, computed, extra ) {
|
||||
if ( computed ) {
|
||||
|
||||
// certain elements can have dimension info if we invisibly show them
|
||||
// however, it must have a current display style that would benefit from this
|
||||
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
|
||||
|
||||
// Support: Safari 8+
|
||||
// Table columns in Safari have non-zero offsetWidth & zero
|
||||
// getBoundingClientRect().width unless display is changed.
|
||||
@ -360,6 +378,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
|
||||
if ( !support.opacity ) {
|
||||
jQuery.cssHooks.opacity = {
|
||||
get: function( elem, computed ) {
|
||||
|
||||
// IE uses filters for opacity
|
||||
return ropacity.test( ( computed && elem.currentStyle ?
|
||||
elem.currentStyle.filter :
|
||||
|
@ -1,10 +1,12 @@
|
||||
define( function() {
|
||||
|
||||
function addGetHookIf( conditionFn, hookFn ) {
|
||||
|
||||
// Define the hook, we'll check on the first run if it's really needed.
|
||||
return {
|
||||
get: function() {
|
||||
if ( conditionFn() ) {
|
||||
|
||||
// Hook not needed (or it's not possible to use it due
|
||||
// to missing dependency), remove it.
|
||||
delete this.get;
|
||||
|
@ -12,11 +12,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
|
||||
function() { return jQuery.css( elem, prop, "" ); },
|
||||
initial = currentValue(),
|
||||
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
|
||||
|
||||
// Starting value computation is required for potential unit mismatches
|
||||
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
|
||||
rcssNum.exec( jQuery.css( elem, prop ) );
|
||||
|
||||
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
|
||||
|
||||
// Trust units reported by jQuery.css
|
||||
unit = unit || initialInUnit[ 3 ];
|
||||
|
||||
@ -27,6 +29,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
|
||||
initialInUnit = +initial || 1;
|
||||
|
||||
do {
|
||||
|
||||
// If previous iteration zeroed out, double until we get *something*.
|
||||
// Use string for doubling so we don't accidentally see scale as unchanged below
|
||||
scale = scale || ".5";
|
||||
@ -44,6 +47,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
|
||||
|
||||
if ( valueParts ) {
|
||||
initialInUnit = +initialInUnit || +initial || 0;
|
||||
|
||||
// Apply relative offset (+=/-=) if specified
|
||||
adjusted = valueParts[ 1 ] ?
|
||||
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
|
||||
|
@ -13,6 +13,7 @@ var getStyles, curCSS,
|
||||
|
||||
if ( window.getComputedStyle ) {
|
||||
getStyles = function( elem ) {
|
||||
|
||||
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
|
||||
// IE throws on elements created in popups
|
||||
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
|
||||
|
@ -16,6 +16,7 @@ function showHide( elements, show ) {
|
||||
display = elem.style.display;
|
||||
if ( show ) {
|
||||
if ( display === "none" ) {
|
||||
|
||||
// Restore a pre-hide() value if we have one
|
||||
values[ index ] = jQuery._data( elem, "display" ) || "";
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ define([
|
||||
},
|
||||
|
||||
boxSizingReliable: function() {
|
||||
|
||||
// We're checking for pixelPositionVal here instead of boxSizingReliableVal
|
||||
// since that compresses better and they're computed together anyway.
|
||||
if ( pixelPositionVal == null ) {
|
||||
@ -61,6 +62,7 @@ define([
|
||||
},
|
||||
|
||||
pixelMarginRight: function() {
|
||||
|
||||
// Support: Android 4.0-4.3
|
||||
if ( pixelPositionVal == null ) {
|
||||
computeStyleTests();
|
||||
@ -76,6 +78,7 @@ define([
|
||||
},
|
||||
|
||||
reliableMarginRight: function() {
|
||||
|
||||
// Support: Android 2.3
|
||||
if ( pixelPositionVal == null ) {
|
||||
computeStyleTests();
|
||||
@ -92,6 +95,7 @@ define([
|
||||
documentElement.appendChild( container );
|
||||
|
||||
div.style.cssText =
|
||||
|
||||
// Support: Android 2.3
|
||||
// Vendor-prefix box-sizing
|
||||
"-webkit-box-sizing:border-box;box-sizing:border-box;" +
|
||||
@ -124,6 +128,7 @@ define([
|
||||
|
||||
// Reset CSS: box-sizing; display; margin; border; padding
|
||||
contents.style.cssText = div.style.cssText =
|
||||
|
||||
// Support: Android 2.3
|
||||
// Vendor-prefix box-sizing
|
||||
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
|
||||
|
@ -1,10 +1,12 @@
|
||||
define( [
|
||||
"../../core",
|
||||
"../../selector"
|
||||
|
||||
// css is assumed
|
||||
], function( jQuery ) {
|
||||
|
||||
return function( elem, el ) {
|
||||
|
||||
// isHidden might be called from jQuery#filter function;
|
||||
// in that case, element will be second argument
|
||||
elem = el || elem;
|
||||
|
@ -9,6 +9,7 @@ var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
|
||||
rmultiDash = /([A-Z])/g;
|
||||
|
||||
function dataAttr( elem, key, data ) {
|
||||
|
||||
// If nothing was found internally, try to fetch any
|
||||
// data from the HTML5 data-* attribute
|
||||
if ( data === undefined && elem.nodeType === 1 ) {
|
||||
@ -22,6 +23,7 @@ function dataAttr( elem, key, data ) {
|
||||
data = data === "true" ? true :
|
||||
data === "false" ? false :
|
||||
data === "null" ? null :
|
||||
|
||||
// Only convert to a number if it doesn't change the string
|
||||
+data + "" === data ? +data :
|
||||
rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
||||
@ -84,6 +86,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
|
||||
}
|
||||
|
||||
if ( !id ) {
|
||||
|
||||
// Only DOM nodes need a new unique ID for each element since their data
|
||||
// ends up in the global cache
|
||||
if ( isNode ) {
|
||||
@ -94,6 +97,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
|
||||
}
|
||||
|
||||
if ( !cache[ id ] ) {
|
||||
|
||||
// Avoid exposing jQuery metadata on plain JS objects when the object
|
||||
// is serialized using JSON.stringify
|
||||
cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
|
||||
@ -118,6 +122,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
|
||||
for ( prop in key ) {
|
||||
thisCache[ jQuery.camelCase( prop ) ] = key[ prop ];
|
||||
}
|
||||
|
||||
// Stop here, ignore other arguments
|
||||
return thisCache;
|
||||
}
|
||||
@ -129,6 +134,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
|
||||
// We always set camelCased properties (gh-2257)
|
||||
return typeof key === "string" ?
|
||||
thisCache[ jQuery.camelCase( key ) ] :
|
||||
|
||||
// Return the whole cache if no key was specified
|
||||
thisCache;
|
||||
}
|
||||
@ -219,6 +225,7 @@ jQuery.extend({
|
||||
noData: {
|
||||
"applet ": true,
|
||||
"embed ": true,
|
||||
|
||||
// ...but Flash objects (which have this classid) *can* handle expandos
|
||||
"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
||||
},
|
||||
@ -289,6 +296,7 @@ jQuery.fn.extend({
|
||||
}
|
||||
|
||||
return arguments.length > 1 ?
|
||||
|
||||
// Sets one value
|
||||
this.each( function() {
|
||||
jQuery.data( this, key, value );
|
||||
|
@ -15,6 +15,7 @@ jQuery.extend({
|
||||
|
||||
Deferred: function( func ) {
|
||||
var tuples = [
|
||||
|
||||
// action, add listener, callbacks,
|
||||
// ... .then handlers, argument index, [final state]
|
||||
[ "notify", "progress", jQuery.Callbacks( "memory" ),
|
||||
@ -36,12 +37,14 @@ jQuery.extend({
|
||||
"catch": function( fn ) {
|
||||
return promise.then( null, fn );
|
||||
},
|
||||
|
||||
// Keep pipe for back-compat
|
||||
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
|
||||
var fns = arguments;
|
||||
|
||||
return jQuery.Deferred( function( newDefer ) {
|
||||
jQuery.each( tuples, function( i, tuple ) {
|
||||
|
||||
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
|
||||
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
|
||||
|
||||
@ -105,6 +108,7 @@ jQuery.extend({
|
||||
|
||||
// Handle a returned thenable
|
||||
if ( jQuery.isFunction( then ) ) {
|
||||
|
||||
// Special processors (notify) just wait for resolution
|
||||
if ( special ) {
|
||||
then.call(
|
||||
@ -130,6 +134,7 @@ jQuery.extend({
|
||||
|
||||
// Handle all other returned values
|
||||
} else {
|
||||
|
||||
// Only substitue handlers pass on context
|
||||
// and multiple values (non-spec behavior)
|
||||
if ( handler !== Identity ) {
|
||||
@ -156,6 +161,7 @@ jQuery.extend({
|
||||
// https://promisesaplus.com/#point-61
|
||||
// Ignore post-resolution exceptions
|
||||
if ( depth + 1 >= maxDepth ) {
|
||||
|
||||
// Only substitue handlers pass on context
|
||||
// and multiple values (non-spec behavior)
|
||||
if ( handler !== Thrower ) {
|
||||
@ -182,6 +188,7 @@ jQuery.extend({
|
||||
}
|
||||
|
||||
return jQuery.Deferred( function( newDefer ) {
|
||||
|
||||
// progress_handlers.add( ... )
|
||||
tuples[ 0 ][ 3 ].add(
|
||||
resolve(
|
||||
@ -217,6 +224,7 @@ jQuery.extend({
|
||||
);
|
||||
} ).promise();
|
||||
},
|
||||
|
||||
// Get a promise for this deferred
|
||||
// If obj is provided, the promise aspect is added to the object
|
||||
promise: function( obj ) {
|
||||
@ -239,6 +247,7 @@ jQuery.extend({
|
||||
if ( stateString ) {
|
||||
list.add(
|
||||
function() {
|
||||
|
||||
// state = "resolved" (i.e., fulfilled)
|
||||
// state = "rejected"
|
||||
state = stateString;
|
||||
|
@ -8,6 +8,7 @@ define([
|
||||
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
|
||||
function( defaultExtra, funcName ) {
|
||||
|
||||
// margin is only for outerHeight, outerWidth
|
||||
jQuery.fn[ funcName ] = function( margin, value ) {
|
||||
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
||||
@ -17,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||
var doc;
|
||||
|
||||
if ( jQuery.isWindow( elem ) ) {
|
||||
|
||||
// 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:
|
||||
// https://github.com/jquery/jquery/pull/764
|
||||
@ -39,6 +41,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||
}
|
||||
|
||||
return value === undefined ?
|
||||
|
||||
// Get width or height on the element, requesting but not forcing parseFloat
|
||||
jQuery.css( elem, type, extra ) :
|
||||
|
||||
|
10
src/effects.js
vendored
10
src/effects.js
vendored
@ -99,6 +99,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
hooks.unqueued++;
|
||||
|
||||
anim.always( function() {
|
||||
|
||||
// doing this makes sure that the complete handler will be called
|
||||
// before this completes
|
||||
anim.always( function() {
|
||||
@ -140,6 +141,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
|
||||
// Restrict "overflow" and "display" styles during box animations
|
||||
if ( isBox && elem.nodeType === 1 ) {
|
||||
|
||||
// Support: IE 9 - 11
|
||||
// Record all 3 overflow attributes because IE does not infer the shorthand
|
||||
// from identically-valued overflowX and overflowY
|
||||
@ -211,6 +213,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
|
||||
/* jshint -W083 */
|
||||
anim.done( function() {
|
||||
|
||||
// The final step of a "hide" animation is actually hiding the element
|
||||
if ( !hidden ) {
|
||||
showHide( [ elem ] );
|
||||
@ -277,6 +280,7 @@ function Animation( elem, properties, options ) {
|
||||
index = 0,
|
||||
length = Animation.prefilters.length,
|
||||
deferred = jQuery.Deferred().always( function() {
|
||||
|
||||
// don't match elem in the :animated selector
|
||||
delete tick.elem;
|
||||
} ),
|
||||
@ -286,6 +290,7 @@ function Animation( elem, properties, options ) {
|
||||
}
|
||||
var currentTime = fxNow || createFxNow(),
|
||||
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
||||
|
||||
// Support: Android 2.3
|
||||
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
|
||||
temp = remaining / animation.duration || 0,
|
||||
@ -326,6 +331,7 @@ function Animation( elem, properties, options ) {
|
||||
},
|
||||
stop: function( gotoEnd ) {
|
||||
var index = 0,
|
||||
|
||||
// if we are going to the end, we want to run all the tweens
|
||||
// otherwise we skip this part
|
||||
length = gotoEnd ? animation.tweens.length : 0;
|
||||
@ -464,6 +470,7 @@ jQuery.speed = function( speed, easing, fn ) {
|
||||
|
||||
jQuery.fn.extend( {
|
||||
fadeTo: function( speed, to, easing, callback ) {
|
||||
|
||||
// show any hidden elements after setting opacity to 0
|
||||
return this.filter( isHidden ).css( "opacity", 0 ).show()
|
||||
|
||||
@ -474,6 +481,7 @@ jQuery.fn.extend({
|
||||
var empty = jQuery.isEmptyObject( prop ),
|
||||
optall = jQuery.speed( speed, easing, callback ),
|
||||
doAnimation = function() {
|
||||
|
||||
// Operate on a copy of prop so per-property easing won't be lost
|
||||
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
||||
|
||||
@ -616,6 +624,7 @@ jQuery.fx.tick = function() {
|
||||
|
||||
for ( ; i < timers.length; i++ ) {
|
||||
timer = timers[ i ];
|
||||
|
||||
// Checks the timer has not already been removed
|
||||
if ( !timer() && timers[ i ] === timer ) {
|
||||
timers.splice( i--, 1 );
|
||||
@ -658,6 +667,7 @@ jQuery.fx.stop = function() {
|
||||
jQuery.fx.speeds = {
|
||||
slow: 600,
|
||||
fast: 200,
|
||||
|
||||
// Default speed
|
||||
_default: 400
|
||||
};
|
||||
|
@ -71,10 +71,12 @@ Tween.propHooks = {
|
||||
// so, simple values such as "10px" are parsed to Float.
|
||||
// complex values such as "rotate(1rad)" are returned as is.
|
||||
result = jQuery.css( tween.elem, tween.prop, "" );
|
||||
|
||||
// Empty strings, null, undefined and "auto" are converted to 0.
|
||||
return !result || result === "auto" ? 0 : result;
|
||||
},
|
||||
set: function( tween ) {
|
||||
|
||||
// use step hook for back compat - use cssHook if its there - use .style if its
|
||||
// available and use plain properties where available
|
||||
if ( jQuery.fx.step[ tween.prop ] ) {
|
||||
|
43
src/event.js
43
src/event.js
@ -38,8 +38,10 @@ function on( elem, types, selector, data, fn, one ) {
|
||||
|
||||
// Types can be a map of types/handlers
|
||||
if ( typeof types === "object" ) {
|
||||
|
||||
// ( types-Object, selector, data )
|
||||
if ( typeof selector !== "string" ) {
|
||||
|
||||
// ( types-Object, data )
|
||||
data = data || selector;
|
||||
selector = undefined;
|
||||
@ -51,15 +53,18 @@ function on( elem, types, selector, data, fn, one ) {
|
||||
}
|
||||
|
||||
if ( data == null && fn == null ) {
|
||||
|
||||
// ( types, fn )
|
||||
fn = selector;
|
||||
data = selector = undefined;
|
||||
} else if ( fn == null ) {
|
||||
if ( typeof selector === "string" ) {
|
||||
|
||||
// ( types, selector, fn )
|
||||
fn = data;
|
||||
data = undefined;
|
||||
} else {
|
||||
|
||||
// ( types, data, fn )
|
||||
fn = data;
|
||||
data = selector;
|
||||
@ -73,10 +78,12 @@ function on( elem, types, selector, data, fn, one ) {
|
||||
if ( one === 1 ) {
|
||||
origFn = fn;
|
||||
fn = function( event ) {
|
||||
|
||||
// Can use an empty set, since event contains the info
|
||||
jQuery().off( event );
|
||||
return origFn.apply( this, arguments );
|
||||
};
|
||||
|
||||
// Use same guid so caller can remove using origFn
|
||||
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
||||
}
|
||||
@ -122,12 +129,15 @@ jQuery.event = {
|
||||
}
|
||||
if ( !( eventHandle = elemData.handle ) ) {
|
||||
eventHandle = elemData.handle = function( e ) {
|
||||
|
||||
// Discard the second event of a jQuery.event.trigger() and
|
||||
// when an event is called after a page has unloaded
|
||||
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
|
||||
return typeof jQuery !== "undefined" &&
|
||||
( !e || jQuery.event.triggered !== e.type ) ?
|
||||
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
||||
undefined;
|
||||
};
|
||||
|
||||
// Add elem as a property of the handle fn to prevent a memory leak
|
||||
// with IE non-native events
|
||||
eventHandle.elem = elem;
|
||||
@ -240,7 +250,8 @@ jQuery.event = {
|
||||
special = jQuery.event.special[ type ] || {};
|
||||
type = ( selector ? special.delegateType : special.bindType ) || type;
|
||||
handlers = events[ type ] || [];
|
||||
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
|
||||
tmp = tmp[ 2 ] &&
|
||||
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
|
||||
|
||||
// Remove matching events
|
||||
origCount = j = handlers.length;
|
||||
@ -306,6 +317,7 @@ jQuery.event = {
|
||||
}
|
||||
|
||||
if ( type.indexOf( "." ) > -1 ) {
|
||||
|
||||
// Namespaced trigger; create a regexp to match event type in handle()
|
||||
namespaces = type.split( "." );
|
||||
type = namespaces.shift();
|
||||
@ -391,8 +403,11 @@ jQuery.event = {
|
||||
// If nobody prevented the default action, do it now
|
||||
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
||||
|
||||
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
|
||||
jQuery.acceptData( elem ) ) {
|
||||
if (
|
||||
( !special._default ||
|
||||
special._default.apply( eventPath.pop(), data ) === false
|
||||
) && jQuery.acceptData( elem )
|
||||
) {
|
||||
|
||||
// Call a native DOM method on the target with the same name name as the event.
|
||||
// Don't do default actions on window, that's where global variables be (#6170)
|
||||
@ -412,6 +427,7 @@ jQuery.event = {
|
||||
try {
|
||||
elem[ type ]();
|
||||
} catch ( e ) {
|
||||
|
||||
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
|
||||
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
|
||||
}
|
||||
@ -645,10 +661,12 @@ jQuery.event = {
|
||||
|
||||
special: {
|
||||
load: {
|
||||
|
||||
// Prevent triggered image.load events from bubbling to window.load
|
||||
noBubble: true
|
||||
},
|
||||
focus: {
|
||||
|
||||
// Fire native event if possible so blur/focus sequence is correct
|
||||
trigger: function() {
|
||||
if ( this !== safeActiveElement() && this.focus ) {
|
||||
@ -656,6 +674,7 @@ jQuery.event = {
|
||||
this.focus();
|
||||
return false;
|
||||
} catch ( e ) {
|
||||
|
||||
// Support: IE<9
|
||||
// If we error on focus to hidden element (#1486, #12518),
|
||||
// let .trigger() run the handlers
|
||||
@ -674,6 +693,7 @@ jQuery.event = {
|
||||
delegateType: "focusout"
|
||||
},
|
||||
click: {
|
||||
|
||||
// For checkbox, fire native event so checked state will be right
|
||||
trigger: function() {
|
||||
if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
|
||||
@ -708,6 +728,7 @@ jQuery.event = {
|
||||
{
|
||||
type: type,
|
||||
isSimulated: true
|
||||
|
||||
// Previously, `originalEvent: {}` was set here, so stopPropagation call
|
||||
// would not be triggered on donor event, since in our own
|
||||
// jQuery.event.stopPropagation function we had a check for existence of
|
||||
@ -752,6 +773,7 @@ jQuery.removeEvent = document.removeEventListener ?
|
||||
};
|
||||
|
||||
jQuery.Event = function( src, props ) {
|
||||
|
||||
// Allow instantiation without the 'new' keyword
|
||||
if ( !( this instanceof jQuery.Event ) ) {
|
||||
return new jQuery.Event( src, props );
|
||||
@ -766,6 +788,7 @@ jQuery.Event = function( src, props ) {
|
||||
// by a handler lower down the tree; reflect the correct value.
|
||||
this.isDefaultPrevented = src.defaultPrevented ||
|
||||
src.defaultPrevented === undefined &&
|
||||
|
||||
// Support: IE < 9, Android < 4.0
|
||||
src.returnValue === false ?
|
||||
returnTrue :
|
||||
@ -822,6 +845,7 @@ jQuery.Event.prototype = {
|
||||
if ( !e || this.isSimulated ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If stopPropagation exists, run it on the original event
|
||||
if ( e.stopPropagation ) {
|
||||
e.stopPropagation();
|
||||
@ -885,6 +909,7 @@ if ( !support.submit ) {
|
||||
|
||||
jQuery.event.special.submit = {
|
||||
setup: function() {
|
||||
|
||||
// Only need this for delegated form submit events
|
||||
if ( jQuery.nodeName( this, "form" ) ) {
|
||||
return false;
|
||||
@ -892,6 +917,7 @@ if ( !support.submit ) {
|
||||
|
||||
// Lazy-add a submit handler when a descendant form may potentially be submitted
|
||||
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
||||
|
||||
// Node name check avoids a VML-related crash in IE (#9807)
|
||||
var elem = e.target,
|
||||
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
|
||||
@ -905,10 +931,12 @@ if ( !support.submit ) {
|
||||
jQuery._data( form, "submit", true );
|
||||
}
|
||||
} );
|
||||
|
||||
// return undefined since we don't need an event listener
|
||||
},
|
||||
|
||||
postDispatch: function( event ) {
|
||||
|
||||
// If form was submitted by the user, bubble the event up the tree
|
||||
if ( event._submitBubble ) {
|
||||
delete event._submitBubble;
|
||||
@ -919,6 +947,7 @@ if ( !support.submit ) {
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
|
||||
// Only need this for delegated form submit events
|
||||
if ( jQuery.nodeName( this, "form" ) ) {
|
||||
return false;
|
||||
@ -938,6 +967,7 @@ if ( !support.change ) {
|
||||
setup: function() {
|
||||
|
||||
if ( rformElems.test( this.nodeName ) ) {
|
||||
|
||||
// IE doesn't fire change on a check/radio until blur; trigger it on click
|
||||
// after a propertychange. Eat the blur-change in special.change.handle.
|
||||
// This still fires onchange a second time for check/radio after blur.
|
||||
@ -951,12 +981,14 @@ if ( !support.change ) {
|
||||
if ( this._justChanged && !event.isTrigger ) {
|
||||
this._justChanged = false;
|
||||
}
|
||||
|
||||
// Allow triggered, simulated change events (#11500)
|
||||
jQuery.event.simulate( "change", this, event );
|
||||
} );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delegated event; lazy-add a change handler on descendant inputs
|
||||
jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
||||
var elem = e.target;
|
||||
@ -1043,6 +1075,7 @@ jQuery.fn.extend({
|
||||
off: function( types, selector, fn ) {
|
||||
var handleObj, type;
|
||||
if ( types && types.preventDefault && types.handleObj ) {
|
||||
|
||||
// ( event ) dispatched jQuery.Event
|
||||
handleObj = types.handleObj;
|
||||
jQuery( types.delegateTarget ).off(
|
||||
@ -1055,6 +1088,7 @@ jQuery.fn.extend({
|
||||
return this;
|
||||
}
|
||||
if ( typeof types === "object" ) {
|
||||
|
||||
// ( types-object [, selector] )
|
||||
for ( type in types ) {
|
||||
this.off( type, selector, types[ type ] );
|
||||
@ -1062,6 +1096,7 @@ jQuery.fn.extend({
|
||||
return this;
|
||||
}
|
||||
if ( selector === false || typeof selector === "function" ) {
|
||||
|
||||
// ( types [, fn] )
|
||||
fn = selector;
|
||||
selector = undefined;
|
||||
|
@ -32,6 +32,7 @@ jQuery.fn.extend({
|
||||
return this.on( types, selector, data, fn );
|
||||
},
|
||||
undelegate: function( selector, types, fn ) {
|
||||
|
||||
// ( namespace ) or ( selector, types [, fn] )
|
||||
return arguments.length === 1 ?
|
||||
this.off( selector, "**" ) :
|
||||
|
@ -12,6 +12,7 @@ define([
|
||||
eventName = "on" + i;
|
||||
|
||||
if ( !( support[ i ] = eventName in window ) ) {
|
||||
|
||||
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
|
||||
div.setAttribute( eventName, "t" );
|
||||
support[ i ] = div.attributes[ eventName ].expando === false;
|
||||
|
@ -1,4 +1,5 @@
|
||||
var
|
||||
|
||||
// Map over jQuery in case of overwrite
|
||||
_jQuery = window.jQuery,
|
||||
|
||||
|
@ -32,6 +32,7 @@ var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
|
||||
rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
|
||||
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
|
||||
rnoInnerhtml = /<(?:script|style|link)/i,
|
||||
|
||||
// checked="checked" or checked
|
||||
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
||||
rscriptTypeMasked = /^true\/(.*)/,
|
||||
@ -189,6 +190,7 @@ function domManip( collection, args, callback, ignored ) {
|
||||
|
||||
// Keep references to cloned scripts for later restoration
|
||||
if ( hasScripts ) {
|
||||
|
||||
// Support: Android<4.1, PhantomJS<2
|
||||
// push.apply(_, arraylike) throws on ancient WebKit
|
||||
jQuery.merge( scripts, getAll( node, "script" ) );
|
||||
@ -212,6 +214,7 @@ function domManip( collection, args, callback, ignored ) {
|
||||
jQuery.contains( doc, node ) ) {
|
||||
|
||||
if ( node.src ) {
|
||||
|
||||
// Optional AJAX dependency, but won't run scripts if not present
|
||||
if ( jQuery._evalUrl ) {
|
||||
jQuery._evalUrl( node.src );
|
||||
@ -285,6 +288,7 @@ jQuery.extend({
|
||||
|
||||
// Fix all IE cloning issues
|
||||
for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
|
||||
|
||||
// Ensure that the destination node is not null; Fixes #9587
|
||||
if ( destElements[ i ] ) {
|
||||
fixCloneNodeIssues( node, destElements[ i ] );
|
||||
@ -430,6 +434,7 @@ jQuery.fn.extend({
|
||||
i = 0;
|
||||
|
||||
for ( ; ( elem = this[ i ] ) != null; i++ ) {
|
||||
|
||||
// Remove element nodes and prevent memory leaks
|
||||
if ( elem.nodeType === 1 ) {
|
||||
jQuery.cleanData( getAll( elem, false ) );
|
||||
@ -481,6 +486,7 @@ jQuery.fn.extend({
|
||||
|
||||
try {
|
||||
for ( ; i < l; i++ ) {
|
||||
|
||||
// Remove element nodes and prevent memory leaks
|
||||
elem = this[ i ] || {};
|
||||
if ( elem.nodeType === 1 ) {
|
||||
|
@ -31,6 +31,7 @@ define([
|
||||
|
||||
// #11217 - WebKit loses check when the name is after the checked attribute
|
||||
fragment.appendChild( div );
|
||||
|
||||
// Support: Windows Web Apps (WWA)
|
||||
// `name` and `type` must use .setAttribute for WWA (#14901)
|
||||
input.setAttribute( "type", "radio" );
|
||||
|
@ -81,6 +81,7 @@ jQuery.offset = {
|
||||
|
||||
jQuery.fn.extend( {
|
||||
offset: function( options ) {
|
||||
|
||||
// Preserve chaining for setter
|
||||
if ( arguments.length ) {
|
||||
return options === undefined ?
|
||||
@ -138,9 +139,11 @@ jQuery.fn.extend({
|
||||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0},
|
||||
// because it is its only offset parent
|
||||
if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
||||
|
||||
// we assume that getBoundingClientRect is available when computed position is fixed
|
||||
offset = elem.getBoundingClientRect();
|
||||
} else {
|
||||
|
||||
// Get *real* offsetParent
|
||||
offsetParent = this.offsetParent();
|
||||
|
||||
@ -227,6 +230,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
|
||||
function( elem, computed ) {
|
||||
if ( computed ) {
|
||||
computed = curCSS( elem, prop );
|
||||
|
||||
// if curCSS returns percentage, fallback to offset
|
||||
return rnumnonpx.test( computed ) ?
|
||||
jQuery( elem ).position()[ prop ] + "px" :
|
||||
|
@ -107,6 +107,7 @@ jQuery.fn.extend({
|
||||
clearQueue: function( type ) {
|
||||
return this.queue( type || "fx", [] );
|
||||
},
|
||||
|
||||
// Get a promise resolved when queues of a certain type
|
||||
// are emptied (fx is the type by default)
|
||||
promise: function( type, obj ) {
|
||||
|
@ -16,13 +16,16 @@ function buildParams( prefix, obj, traditional, add ) {
|
||||
var name;
|
||||
|
||||
if ( jQuery.isArray( obj ) ) {
|
||||
|
||||
// Serialize array item.
|
||||
jQuery.each( obj, function( i, v ) {
|
||||
if ( traditional || rbracket.test( prefix ) ) {
|
||||
|
||||
// Treat each array item as a scalar.
|
||||
add( prefix, v );
|
||||
|
||||
} else {
|
||||
|
||||
// Item is non-scalar (array or object), encode its numeric index.
|
||||
buildParams(
|
||||
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]",
|
||||
@ -34,12 +37,14 @@ function buildParams( prefix, obj, traditional, add ) {
|
||||
} );
|
||||
|
||||
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
|
||||
|
||||
// Serialize object item.
|
||||
for ( name in obj ) {
|
||||
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Serialize scalar item.
|
||||
add( prefix, obj );
|
||||
}
|
||||
@ -51,6 +56,7 @@ jQuery.param = function( a, traditional ) {
|
||||
var prefix,
|
||||
s = [],
|
||||
add = function( key, value ) {
|
||||
|
||||
// If value is a function, invoke it and return its value
|
||||
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : 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 ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
||||
|
||||
// Serialize the form elements
|
||||
jQuery.each( a, function() {
|
||||
add( this.name, this.value );
|
||||
} );
|
||||
|
||||
} else {
|
||||
|
||||
// If traditional, encode the "old" way (the way 1.3.2 or older
|
||||
// did it), otherwise encode params recursively.
|
||||
for ( prefix in a ) {
|
||||
@ -86,12 +94,14 @@ jQuery.fn.extend({
|
||||
},
|
||||
serializeArray: function() {
|
||||
return this.map( function() {
|
||||
|
||||
// Can add propHook for "elements" to filter or add form elements
|
||||
var elements = jQuery.prop( this, "elements" );
|
||||
return elements ? jQuery.makeArray( elements ) : this;
|
||||
} )
|
||||
.filter( function() {
|
||||
var type = this.type;
|
||||
|
||||
// Use .is(":disabled") so that fieldset[disabled] works
|
||||
return this.name && !jQuery( this ).is( ":disabled" ) &&
|
||||
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
|
||||
|
@ -7,6 +7,7 @@ define([
|
||||
], function( jQuery, rneedsContext ) {
|
||||
|
||||
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
|
||||
|
||||
// methods guaranteed to produce a unique set when starting from a unique set
|
||||
guaranteedUnique = {
|
||||
children: true,
|
||||
@ -70,6 +71,7 @@ jQuery.fn.extend({
|
||||
|
||||
for ( ; i < l; i++ ) {
|
||||
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
|
||||
|
||||
// Always skip document fragments
|
||||
if ( cur.nodeType < 11 && ( pos ?
|
||||
pos.index( cur ) > -1 :
|
||||
@ -103,6 +105,7 @@ jQuery.fn.extend({
|
||||
|
||||
// Locate the position of the desired element
|
||||
return jQuery.inArray(
|
||||
|
||||
// If it receives a jQuery object, the first element is used
|
||||
elem.jquery ? elem[ 0 ] : elem, this );
|
||||
},
|
||||
@ -181,6 +184,7 @@ jQuery.each({
|
||||
}
|
||||
|
||||
if ( this.length > 1 ) {
|
||||
|
||||
// Remove duplicates
|
||||
if ( !guaranteedUnique[ name ] ) {
|
||||
ret = jQuery.uniqueSort( ret );
|
||||
|
@ -1,4 +1,5 @@
|
||||
define( function() {
|
||||
|
||||
// [[Class]] -> type pairs
|
||||
return {};
|
||||
} );
|
||||
|
@ -1,4 +1,5 @@
|
||||
define( function() {
|
||||
|
||||
// All support tests are defined in their respective modules.
|
||||
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$,
|
||||
baseURL = "",
|
||||
supportjQuery = this.jQuery,
|
||||
|
||||
// see RFC 2606
|
||||
externalHost = "example.com";
|
||||
|
||||
@ -112,13 +113,13 @@ this.createXMLFragment = function() {
|
||||
|
||||
fireNative = document.createEvent ?
|
||||
function( node, type ) {
|
||||
var event = document.createEvent('HTMLEvents');
|
||||
var event = document.createEvent( "HTMLEvents" );
|
||||
event.initEvent( type, true, true );
|
||||
node.dispatchEvent( event );
|
||||
} :
|
||||
function( node, type ) {
|
||||
var event = document.createEventObject();
|
||||
node.fireEvent( 'on' + type, event );
|
||||
node.fireEvent( "on" + type, event );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -68,6 +68,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
||||
// 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.
|
||||
if ( !elem.nodeType ) {
|
||||
|
||||
// Fixes false positives for dataTests(window), dataTests({}).
|
||||
continue;
|
||||
}
|
||||
@ -75,6 +76,7 @@ QUnit.expectJqData = function( env, elems, key ) {
|
||||
expando = elem[ jQuery.expando ];
|
||||
|
||||
if ( expando === undefined ) {
|
||||
|
||||
// In this case the element exists fine, but
|
||||
// jQuery.data (or internal data) was never (in)directly
|
||||
// called.
|
||||
@ -126,6 +128,7 @@ window.moduleTeardown = function() {
|
||||
delete jQuery.cache[ i ];
|
||||
delete expectedDataKeys[ i ];
|
||||
}
|
||||
|
||||
// In case it was removed from cache before (or never there in the first place)
|
||||
for ( i in expectedDataKeys ) {
|
||||
deepEqual(
|
||||
@ -171,6 +174,7 @@ window.moduleTeardown = function() {
|
||||
};
|
||||
|
||||
QUnit.done( function() {
|
||||
|
||||
// Remove our own fixtures outside #qunit-fixture
|
||||
supportjQuery( "#qunit ~ *" ).remove();
|
||||
} );
|
||||
@ -180,6 +184,7 @@ reset = function() {
|
||||
|
||||
// Ensure jQuery events and data on the fixture are properly removed
|
||||
jQuery( "#qunit-fixture" ).empty();
|
||||
|
||||
// ...even if the jQuery under test has a broken .empty()
|
||||
supportjQuery( "#qunit-fixture" ).empty();
|
||||
|
||||
|
2
test/jquery.js
vendored
2
test/jquery.js
vendored
@ -26,6 +26,7 @@
|
||||
label: "Load with AMD",
|
||||
tooltip: "Load the AMD jQuery file (and its dependencies)"
|
||||
} );
|
||||
|
||||
// If QUnit is on window, this is the main window
|
||||
// This detection allows AMD tests to be run in an iframe
|
||||
if ( QUnit.urlParams.amd && window.QUnit ) {
|
||||
@ -36,6 +37,7 @@
|
||||
}
|
||||
} );
|
||||
src = "src/jquery";
|
||||
|
||||
// Include tests if specified
|
||||
if ( typeof loadTests !== "undefined" ) {
|
||||
require( [ src ], loadTests );
|
||||
|
@ -258,6 +258,7 @@ module( "ajax", {
|
||||
url: url( "data/headers.php?keys=content-type" ),
|
||||
contentType: false,
|
||||
success: function( data ) {
|
||||
|
||||
// Some server/interpreter combinations always supply a Content-Type to scripts
|
||||
data = data || "content-type: \n";
|
||||
strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" );
|
||||
@ -835,7 +836,6 @@ module( "ajax", {
|
||||
}
|
||||
] );
|
||||
|
||||
|
||||
ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [
|
||||
{
|
||||
type: "POST",
|
||||
@ -1088,6 +1088,7 @@ module( "ajax", {
|
||||
);
|
||||
|
||||
ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, {
|
||||
|
||||
// see RFC 2606
|
||||
url: "http://example.invalid",
|
||||
error: function( xhr, _, e ) {
|
||||
@ -1115,6 +1116,7 @@ module( "ajax", {
|
||||
ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" );
|
||||
jQuery.ajax( url( "data/statusText.php?status=404&text=World" ) ).fail( function( jqXHR, statusText ) {
|
||||
strictEqual( statusText, "error", "callback status text ok for error" );
|
||||
|
||||
// ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" );
|
||||
start();
|
||||
} );
|
||||
@ -1491,6 +1493,7 @@ module( "ajax", {
|
||||
} );
|
||||
|
||||
asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function() {
|
||||
|
||||
// Support: Android 2.3 only
|
||||
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||
@ -1554,6 +1557,7 @@ module( "ajax", {
|
||||
var parsedXML = jQuery( jQuery.parseXML( "<tab title=\"Added\">blibli</tab>" ) ).find( "tab" );
|
||||
ajaxXML = jQuery( ajaxXML );
|
||||
try {
|
||||
|
||||
// Android 2.3 doesn't automatically adopt nodes from foreign documents.
|
||||
// (see the comment in test/manipulation.js)
|
||||
// Support: Android 2.3
|
||||
@ -1648,6 +1652,7 @@ module( "ajax", {
|
||||
ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, {
|
||||
dataType: "prefix",
|
||||
setup: function() {
|
||||
|
||||
// Ensure prefix does not throw an error
|
||||
jQuery.ajaxPrefilter( "+prefix", function( options, _, jqXHR ) {
|
||||
if ( options.abortInPrefilter ) {
|
||||
|
@ -79,6 +79,7 @@ test( "attr(String)", function() {
|
||||
equal( jQuery( "#testForm" ).attr( "target" ), undefined, "Retrieving target does not equal the input with name=target" );
|
||||
equal( jQuery( "#testForm" ).attr( "target", "newTarget" ).attr( "target" ), "newTarget", "Set target successfully on a form" );
|
||||
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")
|
||||
equal( jQuery( "#testForm" ).attr( "name" ), undefined, "Retrieving name does not retrieve input with name=name" );
|
||||
extras.remove();
|
||||
@ -814,6 +815,7 @@ test( "val()", function() {
|
||||
|
||||
var checks, $button;
|
||||
equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" );
|
||||
|
||||
// ticket #1714 this caused a JS error in IE
|
||||
equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" );
|
||||
ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" );
|
||||
@ -1159,7 +1161,6 @@ var testRemoveClass = function(valueObj) {
|
||||
$set.removeClass( valueObj( "asdf" ) );
|
||||
ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" );
|
||||
|
||||
|
||||
jQuery( div ).removeClass( valueObj( "foo" ) );
|
||||
strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" );
|
||||
|
||||
|
@ -520,6 +520,7 @@ test("XSS via location.hash", function() {
|
||||
start();
|
||||
};
|
||||
try {
|
||||
|
||||
// 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" );
|
||||
} catch ( err ) {
|
||||
@ -590,6 +591,7 @@ test("jQuery('html')", function() {
|
||||
|
||||
equal( jQuery( "element[attribute='<div></div>']" ).length, 0,
|
||||
"When html is within brackets, do not recognize as html." );
|
||||
|
||||
//equal( jQuery( "element[attribute=<div></div>]" ).length, 0,
|
||||
// "When html is within brackets, do not recognize as html." );
|
||||
equal( jQuery( "element:not(<div></div>)" ).length, 0,
|
||||
@ -639,6 +641,7 @@ test("jQuery(selector, xml).text(str) - loaded via xml document", function() {
|
||||
expect( 2 );
|
||||
|
||||
var xml = createDashboardXML(),
|
||||
|
||||
// tests for #1419 where ie was a problem
|
||||
tab = jQuery( "tab", xml ).eq( 0 );
|
||||
equal( tab.text(), "blabla", "verify initial text correct" );
|
||||
@ -697,6 +700,7 @@ test("inArray()", function() {
|
||||
|
||||
jQuery.each( tests, function( key, obj ) {
|
||||
equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
|
||||
|
||||
// Third argument (fromIndex)
|
||||
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" );
|
||||
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" );
|
||||
|
@ -131,7 +131,6 @@ test( "css(String) computed values", function() {
|
||||
strictEqual( div.css( "font-size" ), "32px", "should get computed value for font-size property" );
|
||||
} );
|
||||
|
||||
|
||||
test( "css() explicit and relative values", function() {
|
||||
expect( 29 );
|
||||
|
||||
@ -366,6 +365,7 @@ test( "css(Array)", function() {
|
||||
if ( !jQuery.support.opacity ) {
|
||||
test( "css(String, Object) for MSIE", function() {
|
||||
expect( 5 );
|
||||
|
||||
// for #1438, IE throws JS error when filter exists but doesn't have opacity in it
|
||||
jQuery( "#foo" ).css( "filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');" );
|
||||
equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" );
|
||||
@ -789,6 +789,7 @@ test("jQuery.cssProps behavior, (bug #8402)", function() {
|
||||
equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
|
||||
div.css( "top", "100px" );
|
||||
equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
|
||||
|
||||
// cleanup jQuery.cssProps
|
||||
jQuery.cssProps.top = undefined;
|
||||
} );
|
||||
@ -813,7 +814,6 @@ test("widows & orphans #8936", function () {
|
||||
ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE" );
|
||||
}
|
||||
|
||||
|
||||
$p.remove();
|
||||
} );
|
||||
|
||||
@ -874,6 +874,7 @@ test("Do not append px (#9548, #12990)", function() {
|
||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
$div.css( "fill-opacity", 1 );
|
||||
|
||||
// Support: Android 2.3 (no support for fill-opacity)
|
||||
if ( $div.css( "fill-opacity" ) ) {
|
||||
equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
||||
@ -1092,6 +1093,7 @@ test( "Keep the last style if the new one isn't recognized by the browser (#1483
|
||||
test( "Reset the style if set to an empty string", function() {
|
||||
expect( 1 );
|
||||
var el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "" );
|
||||
|
||||
// Some browsers return an empty string; others "static". Both those cases mean the style
|
||||
// was reset successfully so accept them both.
|
||||
equal( el.css( "position" ) || "static", "static",
|
||||
@ -1109,6 +1111,7 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
|
||||
value: [ "rgb(255, 0, 0)", "rgb(255,0,0)", "#ff0000" ],
|
||||
expected: [ "transparent" ]
|
||||
}, {
|
||||
|
||||
// Firefox returns auto's value
|
||||
name: "backgroundImage",
|
||||
value: [ "url('test.png')", "url(" + baseUrl + "test.png)", "url(\"" + baseUrl + "test.png\")" ],
|
||||
@ -1118,6 +1121,7 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
|
||||
value: [ "5% 5%" ],
|
||||
expected: [ "0% 0%", "-1000px 0px", "-1000px 0%" ]
|
||||
}, {
|
||||
|
||||
// Firefox returns no-repeat
|
||||
name: "backgroundRepeat",
|
||||
value: [ "repeat-y" ],
|
||||
@ -1249,7 +1253,6 @@ test( "get upper case alpha opacity in IE8", function() {
|
||||
fixture.removeChild( div );
|
||||
} );
|
||||
|
||||
|
||||
( function() {
|
||||
var vendorPrefixes = [ "Webkit", "Moz", "ms" ];
|
||||
|
||||
@ -1261,6 +1264,7 @@ test( "get upper case alpha opacity in IE8", function() {
|
||||
}
|
||||
|
||||
test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function() {
|
||||
|
||||
// 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
|
||||
// use -(webkit|moz)-appearance as well as those two are not on a standards track.
|
||||
|
@ -625,6 +625,7 @@ test(".data supports interoperable hyphenated/camelCase get/set of properties wi
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
@ -655,6 +656,7 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
@ -687,6 +689,7 @@ test(".data supports interoperable removal of properties SET TWICE #13850", func
|
||||
"an-object": {},
|
||||
"bool-true": true,
|
||||
"bool-false": false,
|
||||
|
||||
// JSHint enforces double quotes,
|
||||
// but JSON strings need double quotes to parse
|
||||
// so we need escaped double quotes here
|
||||
@ -715,8 +718,10 @@ test( ".removeData supports removal of hyphenated properties via array (#12786,
|
||||
|
||||
// Properties should always be camelCased
|
||||
compare = {
|
||||
|
||||
// From batch assignment .data({ "a-a": 1 })
|
||||
"aA": 1,
|
||||
|
||||
// From property, value assignment .data( "b-b", 1 )
|
||||
"bB": 1
|
||||
};
|
||||
@ -744,6 +749,7 @@ test("Triggering the removeData should not throw exceptions. (#10080)", function
|
||||
ok( true, "called unload" );
|
||||
start();
|
||||
} );
|
||||
|
||||
// change the url to trigger unload
|
||||
frame.attr( "src", "data/iframe.html?param=true" );
|
||||
} );
|
||||
|
@ -77,7 +77,6 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
} );
|
||||
} );
|
||||
|
||||
|
||||
test( "jQuery.Deferred - chainability", function() {
|
||||
|
||||
var defer = jQuery.Deferred();
|
||||
@ -643,6 +642,7 @@ test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
notifiedResolved.then( null, null, function() {
|
||||
return jQuery.Deferred().notify( "baz" ).resolve( "quux" );
|
||||
} ).progress( function( v ) {
|
||||
|
||||
// Progress from the surrogate deferred is ignored
|
||||
assert.strictEqual( v, "quux", "deferred replaced then'd progress value" );
|
||||
done.pop().call();
|
||||
|
@ -456,6 +456,7 @@ test("setters with and without box-sizing:border-box", function(){
|
||||
} );
|
||||
|
||||
testIframe( "dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) {
|
||||
|
||||
// this test is practically tautological, but there is a bug in IE8
|
||||
// with no simple workaround, so this test exposes the bug and works around it
|
||||
if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) {
|
||||
@ -464,6 +465,7 @@ testIframe( "dimensions/documentSmall", "window vs. small document", function( j
|
||||
equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
|
||||
equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
|
||||
} else {
|
||||
|
||||
// all tests should have at least one assertion
|
||||
expect( 1 );
|
||||
ok( true, "skipping test (conditions not satisfied)" );
|
||||
|
27
test/unit/effects.js
vendored
27
test/unit/effects.js
vendored
@ -513,7 +513,6 @@ test( "animate option { queue: 'name' }", function() {
|
||||
deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
|
||||
} );
|
||||
|
||||
|
||||
// this is the first callback function that should be called
|
||||
order.push( 1 );
|
||||
equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." );
|
||||
@ -537,7 +536,6 @@ test("animate with no properties", function() {
|
||||
|
||||
equal( divs.length, count, "Make sure that callback is called for each element in the set." );
|
||||
|
||||
|
||||
foo = jQuery( "#foo" );
|
||||
|
||||
foo.animate( {} );
|
||||
@ -550,7 +548,6 @@ test("animate with no properties", function() {
|
||||
test( "animate duration 0", function() {
|
||||
expect( 11 );
|
||||
|
||||
|
||||
var $elem,
|
||||
$elems = jQuery( [ { a:0 },{ a:0 } ] ),
|
||||
counter = 0;
|
||||
@ -580,6 +577,7 @@ test("animate duration 0", function() {
|
||||
} );
|
||||
$elems.eq( 1 ).animate( { a:3 }, 200, function() {
|
||||
counter++;
|
||||
|
||||
// Failed until [6115]
|
||||
equal( counter, 5, "One synchronic and one asynchronic" );
|
||||
} );
|
||||
@ -605,6 +603,7 @@ test("animate hyphenated properties", function() {
|
||||
.animate( { "font-size": 20 }, 200, function() {
|
||||
equal( this.style.fontSize, "20px", "The font-size property was animated." );
|
||||
} );
|
||||
|
||||
// FIXME why is this double only when run with other tests
|
||||
this.clock.tick( 400 );
|
||||
|
||||
@ -654,6 +653,7 @@ test("stop()", function() {
|
||||
this.clock.tick( 100 );
|
||||
$two.fadeTo( 100, 0, function() {
|
||||
equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" );
|
||||
|
||||
// Reset styles
|
||||
$one.add( $two ).css( "opacity", "" );
|
||||
} );
|
||||
@ -732,10 +732,12 @@ test("stop(clearQueue, gotoEnd)", function() {
|
||||
$foo.stop( false, true );
|
||||
|
||||
nw = $foo.css( "width" );
|
||||
|
||||
// Disabled, being flaky
|
||||
//equal( nw, 1, "Stop() reset the animation" );
|
||||
|
||||
this.clock.tick( 100 );
|
||||
|
||||
// Disabled, being flaky
|
||||
//equal( $foo.queue().length, 2, "The next animation continued" );
|
||||
$foo.stop( true );
|
||||
@ -942,6 +944,7 @@ jQuery.each({
|
||||
}
|
||||
|
||||
num = 0;
|
||||
|
||||
// TODO: uncrowd this
|
||||
if ( t_h === "show" ) { num++; }
|
||||
if ( t_w === "show" ) { num++; }
|
||||
@ -987,6 +990,7 @@ jQuery.each({
|
||||
if ( f_o === "" ) {
|
||||
f_o = 1;
|
||||
}
|
||||
|
||||
// See above
|
||||
if ( cur_o === "" ) {
|
||||
cur_o = 1;
|
||||
@ -1129,6 +1133,7 @@ test( "interrupt toggle", function() {
|
||||
|
||||
jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) {
|
||||
var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each( function() {
|
||||
|
||||
// Don't end test until we're done with this element
|
||||
remaining++;
|
||||
|
||||
@ -1265,7 +1270,6 @@ test("animate with CSS shorthand properties", function(){
|
||||
test( "hide hidden elements, with animation (bug #7141)", function() {
|
||||
expect( 3 );
|
||||
|
||||
|
||||
var div = jQuery( "<div style='display:none'></div>" ).appendTo( "#qunit-fixture" );
|
||||
equal( div.css( "display" ), "none", "Element is hidden by default" );
|
||||
div.hide( 1, function() {
|
||||
@ -1325,6 +1329,7 @@ test("callbacks should fire in correct order (#9100)", function() {
|
||||
|
||||
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
|
||||
.animate( { fontSize: 12 }, 13, function() {
|
||||
a *= jQuery( this ).data( "operation" ) === "*2" ? 2 : a;
|
||||
@ -1395,6 +1400,7 @@ test("Do not append px to 'fill-opacity' #9548", function() {
|
||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
$div.css( "fill-opacity", 0 ).animate( { "fill-opacity": 1.0 }, 0, function() {
|
||||
|
||||
// Support: Android 2.3 (no support for fill-opacity)
|
||||
if ( jQuery( this ).css( "fill-opacity" ) ) {
|
||||
equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
|
||||
@ -1508,6 +1514,7 @@ test( "Animate Option: step: function( percent, tween )", function() {
|
||||
duration: 1,
|
||||
step: function( value, tween ) {
|
||||
var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
|
||||
|
||||
// in case this is called multiple times for either, lets store it in
|
||||
// 0 or 1 in the array
|
||||
calls[ value === 0 ? 0 : 1 ] = value;
|
||||
@ -1778,6 +1785,7 @@ test( "multiple unqueued and promise", function() {
|
||||
duration: 2000,
|
||||
queue: false,
|
||||
complete: function() {
|
||||
|
||||
// no properties is a non-op and finishes immediately
|
||||
strictEqual( step++, 1, "Step 1" );
|
||||
}
|
||||
@ -1903,11 +1911,13 @@ test("Animation callbacks (#11797)", function() {
|
||||
ok( true, "async: start" );
|
||||
},
|
||||
progress: function( anim, percent ) {
|
||||
|
||||
// occasionally the progress handler is called twice in first frame.... *shrug*
|
||||
if ( percent === 0 && expectedProgress === 1 ) {
|
||||
return;
|
||||
}
|
||||
equal( percent, expectedProgress, "async: progress " + expectedProgress );
|
||||
|
||||
// once at 0, once at 1
|
||||
expectedProgress++;
|
||||
},
|
||||
@ -1988,6 +1998,7 @@ test( "Animations with 0 duration don't ease (#12273)", function() {
|
||||
} );
|
||||
|
||||
jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) {
|
||||
|
||||
// this test would look a lot better if we were using something to override
|
||||
// the default timers
|
||||
var duration = 1500;
|
||||
@ -2029,6 +2040,7 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
|
||||
},
|
||||
always: secondToggle
|
||||
} );
|
||||
|
||||
//FIXME figure out why 470
|
||||
this.clock.tick( 470 );
|
||||
} );
|
||||
@ -2050,9 +2062,11 @@ test( "jQuery.fx.start & jQuery.fx.stop hook points", function() {
|
||||
|
||||
// calls start
|
||||
foo.animate( { foo: 1 }, { queue: false } );
|
||||
|
||||
// calls start
|
||||
foo.animate( { foo: 2 }, { queue: false } );
|
||||
foo.stop();
|
||||
|
||||
// calls stop
|
||||
jQuery.fx.tick();
|
||||
|
||||
@ -2075,6 +2089,7 @@ test( ".finish() completes all queued animations", function() {
|
||||
jQuery.each( animations, function( prop, value ) {
|
||||
var anim = {};
|
||||
anim[ prop ] = value;
|
||||
|
||||
// the delay shouldn't matter at all!
|
||||
div.css( prop, 1 ).animate( anim, function() {
|
||||
ok( true, "Called animation callback for " + prop );
|
||||
@ -2090,6 +2105,7 @@ test( ".finish() completes all queued animations", function() {
|
||||
|
||||
// cleanup
|
||||
div.remove();
|
||||
|
||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||
jQuery.fx.tick();
|
||||
} );
|
||||
@ -2124,6 +2140,7 @@ test( ".finish( false ) - unqueued animations", function() {
|
||||
|
||||
// cleanup
|
||||
div.remove();
|
||||
|
||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||
jQuery.fx.tick();
|
||||
} );
|
||||
@ -2150,6 +2167,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() {
|
||||
} );
|
||||
} );
|
||||
equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
|
||||
|
||||
// start the first animation
|
||||
div.dequeue( "custom" );
|
||||
equal( div.is( ":animated" ), true, ":animated matches" );
|
||||
@ -2161,6 +2179,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() {
|
||||
|
||||
// cleanup
|
||||
div.remove();
|
||||
|
||||
// leaves a "shadow timer" which does nothing around, need to force a tick
|
||||
jQuery.fx.tick();
|
||||
} );
|
||||
|
@ -36,6 +36,7 @@ test("Handler changes and .trigger() order", function() {
|
||||
path += this.nodeName.toLowerCase() + " ";
|
||||
} )
|
||||
.filter( "b" ).on( "click", function( e ) {
|
||||
|
||||
// Removing span should not stop propagation to original parents
|
||||
if ( e.target === this ) {
|
||||
jQuery( this ).parent().remove();
|
||||
@ -98,8 +99,7 @@ test("on(), multiple events at once", function() {
|
||||
handler = function( event ) {
|
||||
if ( event.type === "click" ) {
|
||||
clickCounter += 1;
|
||||
}
|
||||
else if (event.type === "mouseover") {
|
||||
} else if ( event.type === "mouseover" ) {
|
||||
mouseoverCounter += 1;
|
||||
}
|
||||
};
|
||||
@ -268,11 +268,13 @@ test("on/one/off(Object)", function(){
|
||||
}
|
||||
|
||||
$elem = jQuery( "#firstp" )
|
||||
|
||||
// Regular bind
|
||||
.on( {
|
||||
"click":handler,
|
||||
"mouseover":handler
|
||||
} )
|
||||
|
||||
// Bind with data
|
||||
.one( {
|
||||
"click":handlerWithData,
|
||||
@ -380,13 +382,13 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
|
||||
ok( false, "immediate propagation should have been stopped" );
|
||||
},
|
||||
fakeClick = function( $jq ) {
|
||||
|
||||
// Use a native click so we don't get jQuery simulated bubbling
|
||||
if ( document.createEvent ) {
|
||||
var e = document.createEvent( "MouseEvents" );
|
||||
e.initEvent( "click", true, true );
|
||||
$jq[ 0 ].dispatchEvent( e );
|
||||
}
|
||||
else if ( $jq[0].click ) {
|
||||
} else if ( $jq[ 0 ].click ) {
|
||||
$jq[ 0 ].click(); // IE
|
||||
}
|
||||
};
|
||||
@ -400,6 +402,7 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
|
||||
$anchor2.off( "click" );
|
||||
$main.off( "click", "**" );
|
||||
$anchor2.on( "click", function() {
|
||||
|
||||
// Let the default action occur
|
||||
} );
|
||||
$main.on( "click", "#foo", function( e ) {
|
||||
@ -791,6 +794,7 @@ test("off(eventObject)", function() {
|
||||
}
|
||||
|
||||
$elem
|
||||
|
||||
// This handler shouldn't be unbound
|
||||
.on( "foo", function() {
|
||||
num += 1;
|
||||
@ -799,6 +803,7 @@ test("off(eventObject)", function() {
|
||||
$elem.off( e );
|
||||
num += 2;
|
||||
} )
|
||||
|
||||
// Neither this one
|
||||
.on( "bar", function() {
|
||||
num += 4;
|
||||
@ -1012,7 +1017,6 @@ test("trigger(type, [data], [fn])", function() {
|
||||
ok( true, "Native call was triggered" );
|
||||
};
|
||||
|
||||
|
||||
jQuery( document ).on( "mouseenter", "#firstp", function() {
|
||||
ok( true, "Trigger mouseenter bound by on" );
|
||||
} );
|
||||
@ -1180,6 +1184,7 @@ test("trigger(eventObject, [data], [fn])", function() {
|
||||
equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
|
||||
|
||||
$parent.on( "foo", function( e ) {
|
||||
|
||||
// Tries bubbling
|
||||
equal( e.type, "foo", "Verify event type when passed passing an event object" );
|
||||
equal( e.target.id, "child", "Verify event.target when passed passing an event object" );
|
||||
@ -2199,7 +2204,6 @@ test(".on and .off", function() {
|
||||
.off( "click", "em" );
|
||||
equal( counter, 54, "delegated event bindings with data" );
|
||||
|
||||
|
||||
// Mixed event bindings and types
|
||||
counter = 0;
|
||||
mixfn = function( e, trig ) {
|
||||
@ -2295,6 +2299,7 @@ test("special on name mapping", function() {
|
||||
delegateType: "click",
|
||||
handle: function( event ) {
|
||||
equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" );
|
||||
|
||||
// Need to call the handler since .one() uses it to unbind
|
||||
return event.handleObj.handler.call( this, event );
|
||||
}
|
||||
@ -2572,6 +2577,7 @@ asyncTest("trigger click on checkbox, fires change event", function() {
|
||||
var check = jQuery( "#check2" );
|
||||
|
||||
check.on( "change", function() {
|
||||
|
||||
// get it?
|
||||
check.off( "change" );
|
||||
ok( true, "Change event fired as a result of triggered click" );
|
||||
|
@ -580,6 +580,7 @@ test( "append(xml)", function() {
|
||||
var xmlDoc, xml1, xml2;
|
||||
|
||||
function createXMLDoc() {
|
||||
|
||||
// Initialize DOM based upon latest installed MSXML or Netscape
|
||||
var elem, n, len,
|
||||
aActiveX =
|
||||
@ -592,6 +593,7 @@ test( "append(xml)", function() {
|
||||
if ( document.implementation && "createDocument" in document.implementation ) {
|
||||
return document.implementation.createDocument( "", "", null );
|
||||
} else {
|
||||
|
||||
// IE
|
||||
for ( n = 0, len = aActiveX.length; n < len; n++ ) {
|
||||
try {
|
||||
@ -1236,7 +1238,6 @@ function testReplaceWith( val ) {
|
||||
jQuery( "#anchor1" ).contents().replaceWith( val( tmp ) );
|
||||
deepEqual( jQuery( "#anchor1" ).contents().get(), [ tmp ], "Replace text node with element" );
|
||||
|
||||
|
||||
tmp = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
||||
ok( true, "Newly bound click run." );
|
||||
} );
|
||||
@ -1254,7 +1255,6 @@ function testReplaceWith( val ) {
|
||||
y.trigger( "click" ); // Shouldn't be run
|
||||
child.trigger( "click" ); // Shouldn't be run
|
||||
|
||||
|
||||
y = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() {
|
||||
ok( false, "Previously bound click run." );
|
||||
} );
|
||||
@ -1267,13 +1267,11 @@ function testReplaceWith( val ) {
|
||||
|
||||
child2.trigger( "click" );
|
||||
|
||||
|
||||
set = jQuery( "<div/>" ).replaceWith( val( "<span>test</span>" ) );
|
||||
equal( set[ 0 ].nodeName.toLowerCase(), "div", "No effect on a disconnected node." );
|
||||
equal( set.length, 1, "No effect on a disconnected node." );
|
||||
equal( set[ 0 ].childNodes.length, 0, "No effect on a disconnected node." );
|
||||
|
||||
|
||||
child = jQuery( "#qunit-fixture" ).children().first();
|
||||
$div = jQuery( "<div class='pathological'/>" ).insertBefore( child );
|
||||
$div.replaceWith( $div );
|
||||
@ -1285,7 +1283,6 @@ function testReplaceWith( val ) {
|
||||
deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [],
|
||||
"Replacement with following sibling (context removed)" );
|
||||
|
||||
|
||||
non_existent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) );
|
||||
equal( non_existent.length, 0, "Length of non existent element." );
|
||||
|
||||
@ -1517,6 +1514,7 @@ test( "clone()", function() {
|
||||
equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||
div = div.find( "object" );
|
||||
clone = clone.find( "object" );
|
||||
|
||||
// oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
|
||||
jQuery.each( [ "height", "width", "classid" ], function( i, attr ) {
|
||||
equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
|
||||
@ -2263,9 +2261,11 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() {
|
||||
|
||||
// Infer that the test is being run in IE<=8
|
||||
if ( $clone[ 0 ].outerHTML && !jQuery.support.opacity ) {
|
||||
|
||||
// This branch tests cloning nodes by reading the outerHTML, used only in IE<=8
|
||||
equal( $clone[ 0 ].outerHTML, "<section></section>", "detached clone outerHTML matches '<section></section>'" );
|
||||
} else {
|
||||
|
||||
// This branch tests a known behaviour in modern browsers that should never fail.
|
||||
// Included for expected test count symmetry (expecting 1)
|
||||
equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" );
|
||||
@ -2349,6 +2349,7 @@ test( "Ensure oldIE creates a new set on appendTo (#8894)", function() {
|
||||
} );
|
||||
|
||||
asyncTest( "html() - script exceptions bubble (#11743)", 2, function() {
|
||||
|
||||
// Support: Android 2.3 only
|
||||
// Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
|
||||
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
|
||||
|
@ -7,6 +7,7 @@ if ( !jQuery.fn.offset ) {
|
||||
var supportsScroll, supportsFixedPosition,
|
||||
forceScroll = jQuery( "<div/>" ).css( { width: 2000, height: 2000 } ),
|
||||
checkSupport = function() {
|
||||
|
||||
// Only run once
|
||||
checkSupport = false;
|
||||
|
||||
@ -90,7 +91,6 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
||||
@ -118,7 +118,6 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
||||
@ -136,7 +135,6 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
||||
@ -204,7 +202,6 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#relative-1", "top": 6, "left": 6 },
|
||||
@ -216,7 +213,6 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} );
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#relative-2", "top": 200, "left": 50 },
|
||||
@ -265,7 +261,6 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
} );
|
||||
|
||||
|
||||
// get position
|
||||
tests = [
|
||||
{ "id": "#static-1", "top": 6, "left": 6 },
|
||||
@ -278,7 +273,6 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" );
|
||||
} );
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ "id": "#static-2", "top": 200, "left": 200 },
|
||||
@ -349,6 +343,7 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" );
|
||||
equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
@ -381,6 +376,7 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
|
||||
equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
@ -395,6 +391,7 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||
equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||
} else {
|
||||
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
@ -588,6 +585,7 @@ test("iframe scrollTop/Left (see gh-1945)", function() {
|
||||
equal( true, true, "Can't scroll iframes in this environment" );
|
||||
|
||||
} else {
|
||||
|
||||
// Tests scrollTop/Left with iframes
|
||||
jQuery( "#iframe" ).css( "width", "50px" ).css( "height", "50px" );
|
||||
|
||||
|
@ -188,6 +188,7 @@ asyncTest( "fn.promise() - called when fx queue is empty", 3, function() {
|
||||
promised = false;
|
||||
|
||||
foo.queue( function( next ) {
|
||||
|
||||
// called twice!
|
||||
ok( !promised, "Promised hasn't been called" );
|
||||
setTimeout( next, 10 );
|
||||
@ -253,7 +254,6 @@ test( ".promise(obj)", function() {
|
||||
strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
||||
} );
|
||||
|
||||
|
||||
if ( jQuery.fn.stop ) {
|
||||
test( "delay() can be stopped", function() {
|
||||
expect( 3 );
|
||||
|
@ -33,6 +33,7 @@ if ( jQuery.css ) {
|
||||
ok( okValue[ color ], "color was not reset (" + color + ")" );
|
||||
|
||||
stop();
|
||||
|
||||
// Run doc ready tests as well
|
||||
jQuery( function() {
|
||||
deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
|
||||
@ -46,7 +47,6 @@ testIframeWithCallback( "A background on the testElement does not cause IE8 to c
|
||||
ok( true, "IE8 does not crash" );
|
||||
} );
|
||||
|
||||
|
||||
// This test checks CSP only for browsers with "Content-Security-Policy" header support
|
||||
// i.e. no old WebKit or old Firefox
|
||||
testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
|
||||
@ -201,6 +201,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
|
||||
"submit": false
|
||||
};
|
||||
} else if ( /chrome/i.test( userAgent ) ) {
|
||||
|
||||
// Catches Chrome on Android as well (i.e. the default
|
||||
// Android browser on Android >= 4.4).
|
||||
expected = {
|
||||
|
@ -279,7 +279,6 @@ test("filter(jQuery)", function() {
|
||||
deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
|
||||
} );
|
||||
|
||||
|
||||
test( "filter() with positional selectors", function() {
|
||||
expect( 19 );
|
||||
|
||||
@ -734,7 +733,6 @@ test("add(String html)", function() {
|
||||
|
||||
ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
|
||||
|
||||
|
||||
x = jQuery( [] ).add( "<p id='x1'>xxx</p>" ).add( "<p id='x2'>xxx</p>" );
|
||||
equal( x[ 0 ].id, "x1", "Check detached element1" );
|
||||
equal( x[ 1 ].id, "x2", "Check detached element2" );
|
||||
|
@ -28,12 +28,16 @@ function testWrap( val ) {
|
||||
defaultText = "Try them out:";
|
||||
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
||||
|
||||
equal( defaultText, result, "Check for wrapping of on-the-fly html" );
|
||||
equal(
|
||||
defaultText, result, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
|
||||
result = jQuery( "#first" ).wrap( val( document.getElementById( "empty" ) ) ).parent();
|
||||
ok( result.is( "ol" ), "Check for element wrapping" );
|
||||
equal( result.text(), defaultText, "Check for element wrapping" );
|
||||
equal(
|
||||
result.text(), defaultText, "Check for element wrapping"
|
||||
);
|
||||
|
||||
jQuery( "#check1" ).on( "click", function() {
|
||||
var checkbox = this;
|
||||
@ -47,8 +51,14 @@ function testWrap( val ) {
|
||||
j = jQuery( "#nonnodes" ).contents();
|
||||
j.wrap( val( "<i></i>" ) );
|
||||
|
||||
equal( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
|
||||
equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
|
||||
equal(
|
||||
jQuery( "#nonnodes > i" ).length, 3, "Check node,textnode,comment wraps ok"
|
||||
);
|
||||
equal(
|
||||
jQuery( "#nonnodes > i" ).text(),
|
||||
j.text(),
|
||||
"Check node,textnode,comment wraps doesn't hurt text"
|
||||
);
|
||||
|
||||
// Try wrapping a disconnected node
|
||||
cacheLength = 0;
|
||||
@ -57,28 +67,48 @@ function testWrap( val ) {
|
||||
}
|
||||
|
||||
j = jQuery( "<label/>" ).wrap( val( "<li/>" ) );
|
||||
equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
|
||||
equal(
|
||||
j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label"
|
||||
);
|
||||
equal(
|
||||
j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped"
|
||||
);
|
||||
|
||||
for ( i in jQuery.cache ) {
|
||||
cacheLength--;
|
||||
}
|
||||
equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
|
||||
equal(
|
||||
cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)"
|
||||
);
|
||||
|
||||
// Wrap an element containing a text node
|
||||
j = jQuery( "<span/>" ).wrap( "<div>test</div>" );
|
||||
equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
|
||||
equal(
|
||||
j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element"
|
||||
);
|
||||
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)
|
||||
j = jQuery( "<div><span></span></div>" ).children().wrap( "<p></p><div></div>" );
|
||||
equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
|
||||
equal( j.length, 1, "There should only be one element (no cloning)." );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
|
||||
equal(
|
||||
j[ 0 ].parentNode.parentNode.childNodes.length,
|
||||
1,
|
||||
"There should only be one element wrapping."
|
||||
);
|
||||
equal(
|
||||
j.length, 1, "There should only be one element (no cloning)."
|
||||
);
|
||||
equal(
|
||||
j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph."
|
||||
);
|
||||
|
||||
// Wrap an element with a jQuery set
|
||||
j = jQuery( "<span/>" ).wrap( jQuery( "<div></div>" ) );
|
||||
equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
equal(
|
||||
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||
);
|
||||
|
||||
// Wrap an element with a jQuery set and event
|
||||
result = jQuery( "<div></div>" ).on( "click", function() {
|
||||
@ -90,7 +120,9 @@ function testWrap( val ) {
|
||||
} );
|
||||
|
||||
j = jQuery( "<span/>" ).wrap( result );
|
||||
equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
equal(
|
||||
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
|
||||
);
|
||||
|
||||
j.parent().trigger( "click" );
|
||||
|
||||
@ -110,7 +142,11 @@ test( "wrap(Function) with index (#10177)", function() {
|
||||
|
||||
expect( targets.length );
|
||||
targets.wrap( function( i ) {
|
||||
equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
|
||||
equal(
|
||||
i,
|
||||
expectedIndex,
|
||||
"Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")"
|
||||
);
|
||||
expectedIndex++;
|
||||
|
||||
return "<div id='wrap_index_'" + i + "'></div>";
|
||||
@ -127,7 +163,9 @@ test( "wrap(String) consecutive elements (#10177)", function() {
|
||||
var $this = jQuery( this );
|
||||
|
||||
ok( $this.parent().is( ".wrapper" ), "Check each elements parent is correct (.wrapper)" );
|
||||
equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
|
||||
equal(
|
||||
$this.siblings().length, 0, "Each element should be wrapped individually"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
@ -141,11 +179,17 @@ test( "wrapAll(String)", function() {
|
||||
p = jQuery( "#firstp,#first" )[ 0 ].parentNode;
|
||||
result = jQuery( "#firstp,#first" ).wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
||||
|
||||
equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
equal(
|
||||
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
equal(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
equal(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||
);
|
||||
|
||||
} );
|
||||
|
||||
@ -158,11 +202,15 @@ test( "wrapAll(Function)", function() {
|
||||
return "<div class='red'><div class='tmp'></div></div>";
|
||||
} );
|
||||
|
||||
equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
equal(
|
||||
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
||||
strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
strictEqual(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapAll(Function) check execution characteristics", function() {
|
||||
@ -178,8 +226,12 @@ test( "wrapAll(Function) check execution characteristics", function() {
|
||||
ok( !i, "should not execute function argument if target element does not exist" );
|
||||
|
||||
jQuery( "#firstp" ).wrapAll( function( index ) {
|
||||
strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
||||
strictEqual( index, undefined, "index argument should not be included in function execution" );
|
||||
strictEqual(
|
||||
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
|
||||
);
|
||||
strictEqual(
|
||||
index, undefined, "index argument should not be included in function execution"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
@ -192,11 +244,15 @@ test( "wrapAll(Function)", function() {
|
||||
return "<div class='red'><div class='tmp'></div></div>";
|
||||
} );
|
||||
|
||||
equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
equal(
|
||||
result.parent().length, 1, "Check for wrapping of on-the-fly html"
|
||||
);
|
||||
ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
||||
strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
strictEqual(
|
||||
jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapAll(Function) check execution characteristics", function() {
|
||||
@ -212,8 +268,12 @@ test( "wrapAll(Function) check execution characteristics", function() {
|
||||
ok( !i, "should not execute function argument if target element does not exist" );
|
||||
|
||||
jQuery( "#firstp" ).wrapAll( function( index ) {
|
||||
strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
||||
strictEqual( index, undefined, "index argument should not be included in function execution" );
|
||||
strictEqual(
|
||||
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
|
||||
);
|
||||
strictEqual(
|
||||
index, undefined, "index argument should not be included in function execution"
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
@ -227,9 +287,15 @@ test( "wrapAll(Element)", function() {
|
||||
p = jQuery( "#first" )[ 0 ].parentNode;
|
||||
jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) );
|
||||
|
||||
equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
|
||||
equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
equal(
|
||||
jQuery( "#first" ).parent()[ 0 ], jQuery( "#firstp" ).parent()[ 0 ], "Same Parent"
|
||||
);
|
||||
equal(
|
||||
jQuery( "#first" ).parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
|
||||
);
|
||||
equal(
|
||||
jQuery( "#first" ).parent()[ 0 ].parentNode, p, "Correct Parent"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapInner(String)", function() {
|
||||
@ -241,15 +307,23 @@ test( "wrapInner(String)", function() {
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapInner(Element)", function() {
|
||||
@ -261,13 +335,21 @@ test( "wrapInner(Element)", function() {
|
||||
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( document.getElementById( "empty" ) );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
div.wrapInner( "<span></span>" );
|
||||
equal( div.children().length, 1, "The contents were wrapped." );
|
||||
equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
equal(
|
||||
div.children().length, 1, "The contents were wrapped."
|
||||
);
|
||||
equal(
|
||||
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapInner(Function) returns String", function() {
|
||||
@ -280,15 +362,23 @@ test( "wrapInner(Function) returns String", function() {
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) );
|
||||
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
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>" ) );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapInner(Function) returns Element", function() {
|
||||
@ -301,39 +391,83 @@ test( "wrapInner(Function) returns Element", function() {
|
||||
|
||||
num = jQuery( "#first" ).children().length;
|
||||
jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().length, 1, "Only one child"
|
||||
);
|
||||
ok( jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
equal(
|
||||
jQuery( "#first" ).children().children().length, num, "Verify Elements Intact"
|
||||
);
|
||||
|
||||
div.wrapInner( val( "<span></span>" ) );
|
||||
equal( div.children().length, 1, "The contents were wrapped." );
|
||||
equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
equal(
|
||||
div.children().length, 1, "The contents were wrapped."
|
||||
);
|
||||
equal(
|
||||
div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted."
|
||||
);
|
||||
} );
|
||||
|
||||
test( "unwrap()", function() {
|
||||
|
||||
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(),
|
||||
abcdef = jQuery( "#unwrap span" ).get();
|
||||
|
||||
equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
||||
deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
||||
equal(
|
||||
jQuery( "#unwrap1 span" ).add( "#unwrap2 span:first-child" ).unwrap().length,
|
||||
3,
|
||||
"make #unwrap1 and #unwrap2 go away"
|
||||
);
|
||||
deepEqual(
|
||||
jQuery( "#unwrap > span" ).get(), abcd, "all four spans should still exist"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
||||
deepEqual(
|
||||
jQuery( "#unwrap3 span" ).unwrap().get(),
|
||||
jQuery( "#unwrap3 > span" ).get(),
|
||||
"make all b in #unwrap3 go away"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
||||
deepEqual(
|
||||
jQuery( "#unwrap3 span" ).unwrap().get(),
|
||||
jQuery( "#unwrap > span.unwrap3" ).get(),
|
||||
"make #unwrap3 go away"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
||||
deepEqual(
|
||||
jQuery( "#unwrap" ).children().get(),
|
||||
abcdef,
|
||||
"#unwrap only contains 6 child spans"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
||||
deepEqual(
|
||||
jQuery( "#unwrap > span" ).unwrap().get(),
|
||||
jQuery( "body > span.unwrap" ).get(),
|
||||
"make the 6 spans become children of body"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
||||
deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
||||
deepEqual(
|
||||
jQuery( "body > span.unwrap" ).unwrap().get(),
|
||||
jQuery( "body > span.unwrap" ).get(),
|
||||
"can't unwrap children of body"
|
||||
);
|
||||
deepEqual(
|
||||
jQuery( "body > span.unwrap" ).unwrap().get(), abcdef, "can't unwrap children of body"
|
||||
);
|
||||
|
||||
deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
||||
deepEqual(
|
||||
jQuery( "body > span.unwrap" ).get(), abcdef, "body contains 6 .unwrap child spans"
|
||||
);
|
||||
|
||||
jQuery( "body > span.unwrap" ).remove();
|
||||
} );
|
||||
@ -342,23 +476,42 @@ test( "unwrap( selector )", function() {
|
||||
|
||||
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
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" );
|
||||
equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
equal(
|
||||
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||
);
|
||||
|
||||
// Shouldn't unwrap, no match
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "span" );
|
||||
equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
equal(
|
||||
jQuery( "#unwrap1" ).length, 1, "still wrapped"
|
||||
);
|
||||
|
||||
// Unwraps
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" );
|
||||
equal( jQuery("#unwrap1").length, 0, "unwrapped match" );
|
||||
equal(
|
||||
jQuery( "#unwrap1" ).length, 0, "unwrapped match"
|
||||
);
|
||||
|
||||
// Check return values
|
||||
deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" );
|
||||
deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" );
|
||||
deepEqual(
|
||||
jQuery( "#unwrap2 span" ).get(),
|
||||
jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(),
|
||||
"return on unmatched unwrap"
|
||||
);
|
||||
deepEqual(
|
||||
jQuery( "#unwrap2 span" ).get(),
|
||||
jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(),
|
||||
"return on matched unwrap"
|
||||
);
|
||||
|
||||
jQuery( "body > span.unwrap" ).remove();
|
||||
} );
|
||||
@ -372,8 +525,16 @@ test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", functio
|
||||
|
||||
$wraptarget.wrapAll( "<aside style='background-color:green'></aside>" );
|
||||
|
||||
notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
|
||||
notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
|
||||
notEqual(
|
||||
$wraptarget.parent( "aside" ).get( 0 ).style.backgroundColor,
|
||||
"transparent",
|
||||
"HTML5 elements created with wrapAll inherit styles"
|
||||
);
|
||||
notEqual(
|
||||
$section.get( 0 ).style.backgroundColor,
|
||||
"transparent",
|
||||
"HTML5 elements create with jQuery( string ) inherit styles"
|
||||
);
|
||||
} );
|
||||
|
||||
test( "wrapping scripts (#10470)", function() {
|
||||
@ -381,12 +542,15 @@ test( "wrapping scripts (#10470)", function() {
|
||||
expect( 2 );
|
||||
|
||||
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;
|
||||
jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script );
|
||||
jQuery( "#qunit-fixture script" ).wrap( "<b></b>" );
|
||||
strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
|
||||
strictEqual(
|
||||
script.parentNode, jQuery( "#qunit-fixture > b" )[ 0 ], "correctly wrapped"
|
||||
);
|
||||
jQuery( script ).remove();
|
||||
} );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user