mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Build: update grunt-jscs-checker and pass with the new rules
This commit is contained in:
parent
8e3a0ceafa
commit
c869a1ef8a
32
Gruntfile.js
32
Gruntfile.js
@ -19,7 +19,7 @@ module.exports = function( grunt ) {
|
|||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
pkg: grunt.file.readJSON( "package.json" ),
|
pkg: grunt.file.readJSON( "package.json" ),
|
||||||
dst: readOptionalJSON( "dist/.destination.json" ),
|
dst: readOptionalJSON( "dist/.destination.json" ),
|
||||||
compare_size: {
|
"compare_size": {
|
||||||
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
||||||
options: {
|
options: {
|
||||||
compress: {
|
compress: {
|
||||||
@ -93,13 +93,31 @@ module.exports = function( grunt ) {
|
|||||||
src: "src/**/*.js",
|
src: "src/**/*.js",
|
||||||
gruntfile: "Gruntfile.js",
|
gruntfile: "Gruntfile.js",
|
||||||
|
|
||||||
// Right know, check only test helpers
|
// Right now, check only test helpers
|
||||||
test: [ "test/data/testrunner.js", "test/data/testinit.js" ],
|
test: [ "test/data/testrunner.js" ],
|
||||||
release: "build/*.js",
|
release: [ "build/*.js", "!build/release-notes.js" ],
|
||||||
tasks: "build/tasks/*.js"
|
tasks: "build/tasks/*.js"
|
||||||
},
|
},
|
||||||
testswarm: {
|
testswarm: {
|
||||||
tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing".split( " " )
|
tests: [
|
||||||
|
"ajax",
|
||||||
|
"attributes",
|
||||||
|
"callbacks",
|
||||||
|
"core",
|
||||||
|
"css",
|
||||||
|
"data",
|
||||||
|
"deferred",
|
||||||
|
"dimensions",
|
||||||
|
"effects",
|
||||||
|
"event",
|
||||||
|
"manipulation",
|
||||||
|
"offset",
|
||||||
|
"queue",
|
||||||
|
"selector",
|
||||||
|
"serialize",
|
||||||
|
"support",
|
||||||
|
"traversing"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: [ "<%= jshint.all.src %>" ],
|
files: [ "<%= jshint.all.src %>" ],
|
||||||
@ -116,13 +134,13 @@ module.exports = function( grunt ) {
|
|||||||
sourceMappingURL: "jquery.min.map",
|
sourceMappingURL: "jquery.min.map",
|
||||||
report: "min",
|
report: "min",
|
||||||
beautify: {
|
beautify: {
|
||||||
ascii_only: true
|
"ascii_only": true
|
||||||
},
|
},
|
||||||
banner: "/*! jQuery v<%= pkg.version %> | " +
|
banner: "/*! jQuery v<%= pkg.version %> | " +
|
||||||
"(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
|
"(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
|
||||||
"jquery.org/license */",
|
"jquery.org/license */",
|
||||||
compress: {
|
compress: {
|
||||||
hoist_funs: false,
|
"hoist_funs": false,
|
||||||
loops: false,
|
loops: false,
|
||||||
unused: false
|
unused: false
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ http.request({
|
|||||||
host: "bugs.jquery.com",
|
host: "bugs.jquery.com",
|
||||||
port: 80,
|
port: 80,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
path: "/query?status=closed&resolution=fixed&max=400&component=!web&order=component&milestone=" + version
|
path: "/query?status=closed&resolution=fixed&max=400&" +
|
||||||
|
"component=!web&order=component&milestone=" + version
|
||||||
}, function( res ) {
|
}, function( res ) {
|
||||||
var data = [];
|
var data = [];
|
||||||
|
|
||||||
|
@ -89,7 +89,9 @@ module.exports = function( Release ) {
|
|||||||
|
|
||||||
var archiver = require( "archiver" )( "zip" ),
|
var archiver = require( "archiver" )( "zip" ),
|
||||||
md5file = cdnFolder + "/" + cdn + "-md5.txt",
|
md5file = cdnFolder + "/" + cdn + "-md5.txt",
|
||||||
output = fs.createWriteStream( cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip" );
|
output = fs.createWriteStream(
|
||||||
|
cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
|
||||||
|
);
|
||||||
|
|
||||||
output.on( "error", function( err ) {
|
output.on( "error", function( err ) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Special concat/build task to handle various jQuery build requirements
|
* Special concat/build task to handle various jQuery build requirements
|
||||||
* Concats AMD modules, removes their definitions, and includes/excludes specified modules
|
* Concats AMD modules, removes their definitions,
|
||||||
|
* and includes/excludes specified modules
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = function( grunt ) {
|
module.exports = function( grunt ) {
|
||||||
@ -35,7 +36,8 @@ module.exports = function( grunt ) {
|
|||||||
/**
|
/**
|
||||||
* Strip all definitions generated by requirejs
|
* Strip all definitions generated by requirejs
|
||||||
* Convert "var" modules to var declarations
|
* Convert "var" modules to var declarations
|
||||||
* "var module" means the module only contains a return statement that should be converted to a var declaration
|
* "var module" means the module only contains a return
|
||||||
|
* statement that should be converted to a var declaration
|
||||||
* This is indicated by including the file in any "var" folder
|
* This is indicated by including the file in any "var" folder
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @param {String} path
|
* @param {String} path
|
||||||
@ -98,7 +100,8 @@ module.exports = function( grunt ) {
|
|||||||
|
|
||||||
grunt.registerMultiTask(
|
grunt.registerMultiTask(
|
||||||
"build",
|
"build",
|
||||||
"Concatenate source, remove sub AMD definitions, (include/exclude modules with +/- flags), embed date/version",
|
"Concatenate source, remove sub AMD definitions, " +
|
||||||
|
"(include/exclude modules with +/- flags), embed date/version",
|
||||||
function() {
|
function() {
|
||||||
var flag, index,
|
var flag, index,
|
||||||
done = this.async(),
|
done = this.async(),
|
||||||
@ -113,7 +116,8 @@ module.exports = function( grunt ) {
|
|||||||
/**
|
/**
|
||||||
* Recursively calls the excluder to remove on all modules in the list
|
* Recursively calls the excluder to remove on all modules in the list
|
||||||
* @param {Array} list
|
* @param {Array} list
|
||||||
* @param {String} [prepend] Prepend this to the module name. Indicates we're walking a directory
|
* @param {String} [prepend] Prepend this to the module name.
|
||||||
|
* Indicates we're walking a directory
|
||||||
*/
|
*/
|
||||||
excludeList = function( list, prepend ) {
|
excludeList = function( list, prepend ) {
|
||||||
if ( list ) {
|
if ( list ) {
|
||||||
@ -121,7 +125,9 @@ module.exports = function( grunt ) {
|
|||||||
list.forEach(function( module ) {
|
list.forEach(function( module ) {
|
||||||
// Exclude var modules as well
|
// Exclude var modules as well
|
||||||
if ( module === "var" ) {
|
if ( module === "var" ) {
|
||||||
excludeList( fs.readdirSync( srcFolder + prepend + module ), prepend + module );
|
excludeList(
|
||||||
|
fs.readdirSync( srcFolder + prepend + module ), prepend + module
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( prepend ) {
|
if ( prepend ) {
|
||||||
@ -143,7 +149,9 @@ module.exports = function( grunt ) {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Adds the specified module to the excluded or included list, depending on the flag
|
* Adds the specified module to the excluded or included list, depending on the flag
|
||||||
* @param {String} flag A module path relative to the src directory starting with + or - to indicate whether it should included or excluded
|
* @param {String} flag A module path relative to
|
||||||
|
* the src directory starting with + or - to indicate
|
||||||
|
* whether it should included or excluded
|
||||||
*/
|
*/
|
||||||
excluder = function( flag ) {
|
excluder = function( flag ) {
|
||||||
var m = /^(\+|\-|)([\w\/-]+)$/.exec( flag ),
|
var m = /^(\+|\-|)([\w\/-]+)$/.exec( flag ),
|
||||||
@ -162,7 +170,7 @@ module.exports = function( grunt ) {
|
|||||||
// It's fine if the directory is not there
|
// It's fine if the directory is not there
|
||||||
try {
|
try {
|
||||||
excludeList( fs.readdirSync( srcFolder + module ), module );
|
excludeList( fs.readdirSync( srcFolder + module ), module );
|
||||||
} catch( e ) {
|
} catch ( e ) {
|
||||||
grunt.verbose.writeln( e );
|
grunt.verbose.writeln( e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +179,9 @@ module.exports = function( grunt ) {
|
|||||||
} else {
|
} else {
|
||||||
grunt.log.error( "Module \"" + module + "\" is a mimimum requirement.");
|
grunt.log.error( "Module \"" + module + "\" is a mimimum requirement.");
|
||||||
if ( module === "selector" ) {
|
if ( module === "selector" ) {
|
||||||
grunt.log.error( "If you meant to replace Sizzle, use -sizzle instead." );
|
grunt.log.error(
|
||||||
|
"If you meant to replace Sizzle, use -sizzle instead."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -195,8 +205,10 @@ module.exports = function( grunt ) {
|
|||||||
// * none (implicit exclude)
|
// * none (implicit exclude)
|
||||||
// *:* all (implicit include)
|
// *:* all (implicit include)
|
||||||
// *:*:-css all except css and dependents (explicit > implicit)
|
// *:*:-css all except css and dependents (explicit > implicit)
|
||||||
// *:*:-css:+effects same (excludes effects because explicit include is trumped by explicit exclude of dependency)
|
// *:*:-css:+effects same (excludes effects because explicit include is
|
||||||
// *:+effects none except effects and its dependencies (explicit include trumps implicit exclude of dependency)
|
// trumped by explicit exclude of dependency)
|
||||||
|
// *:+effects none except effects and its dependencies
|
||||||
|
// (explicit include trumps implicit exclude of dependency)
|
||||||
delete flags[ "*" ];
|
delete flags[ "*" ];
|
||||||
for ( flag in flags ) {
|
for ( flag in flags ) {
|
||||||
excluder( flag );
|
excluder( flag );
|
||||||
@ -249,7 +261,9 @@ module.exports = function( grunt ) {
|
|||||||
// Turn off opt-in if necessary
|
// Turn off opt-in if necessary
|
||||||
if ( !optIn ) {
|
if ( !optIn ) {
|
||||||
// Overwrite the default inclusions with the explicit ones provided
|
// Overwrite the default inclusions with the explicit ones provided
|
||||||
config.rawText.jquery = "define([" + (included.length ? included.join(",") : "") + "]);";
|
config.rawText.jquery = "define([" +
|
||||||
|
(included.length ? included.join(",") : "") +
|
||||||
|
"]);";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trace dependencies and concatenate files
|
// Trace dependencies and concatenate files
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
"grunt-contrib-uglify": "0.5.0",
|
"grunt-contrib-uglify": "0.5.0",
|
||||||
"grunt-contrib-watch": "0.6.1",
|
"grunt-contrib-watch": "0.6.1",
|
||||||
"grunt-git-authors": "1.2.0",
|
"grunt-git-authors": "1.2.0",
|
||||||
"grunt-jscs-checker": "0.4.1",
|
"grunt-jscs-checker": "0.6.1",
|
||||||
"grunt-jsonlint": "1.0.4",
|
"grunt-jsonlint": "1.0.4",
|
||||||
"grunt-npmcopy": "0.1.0",
|
"grunt-npmcopy": "0.1.0",
|
||||||
"gzip-js": "0.3.2",
|
"gzip-js": "0.3.2",
|
||||||
|
23
src/ajax.js
23
src/ajax.js
@ -89,7 +89,9 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
|
|||||||
inspected[ dataType ] = true;
|
inspected[ dataType ] = true;
|
||||||
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
||||||
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
||||||
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
if ( typeof dataTypeOrTransport === "string" &&
|
||||||
|
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
||||||
|
|
||||||
options.dataTypes.unshift( dataTypeOrTransport );
|
options.dataTypes.unshift( dataTypeOrTransport );
|
||||||
inspect( dataTypeOrTransport );
|
inspect( dataTypeOrTransport );
|
||||||
return false;
|
return false;
|
||||||
@ -262,7 +264,10 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
|||||||
try {
|
try {
|
||||||
response = conv( response );
|
response = conv( response );
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
|
return {
|
||||||
|
state: "parsererror",
|
||||||
|
error: conv ? e : "No conversion from " + prev + " to " + current
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,9 +401,10 @@ jQuery.extend({
|
|||||||
// Callbacks context
|
// Callbacks context
|
||||||
callbackContext = s.context || s,
|
callbackContext = s.context || s,
|
||||||
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
// Context for global events is callbackContext if it is a DOM node or jQuery collection
|
||||||
globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
|
globalEventContext = s.context &&
|
||||||
jQuery( callbackContext ) :
|
( callbackContext.nodeType || callbackContext.jquery ) ?
|
||||||
jQuery.event,
|
jQuery( callbackContext ) :
|
||||||
|
jQuery.event,
|
||||||
// Deferreds
|
// Deferreds
|
||||||
deferred = jQuery.Deferred(),
|
deferred = jQuery.Deferred(),
|
||||||
completeDeferred = jQuery.Callbacks("once memory"),
|
completeDeferred = jQuery.Callbacks("once memory"),
|
||||||
@ -582,7 +588,8 @@ jQuery.extend({
|
|||||||
jqXHR.setRequestHeader(
|
jqXHR.setRequestHeader(
|
||||||
"Accept",
|
"Accept",
|
||||||
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
||||||
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
s.accepts[ s.dataTypes[0] ] +
|
||||||
|
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
||||||
s.accepts[ "*" ]
|
s.accepts[ "*" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -592,7 +599,9 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allow custom headers/mimetypes and early abort
|
// Allow custom headers/mimetypes and early abort
|
||||||
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
if ( s.beforeSend &&
|
||||||
|
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
||||||
|
|
||||||
// Abort if not done already and return
|
// Abort if not done already and return
|
||||||
return jqXHR.abort();
|
return jqXHR.abort();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||||||
var callbackName, overwritten, responseContainer,
|
var callbackName, overwritten, responseContainer,
|
||||||
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
|
||||||
"url" :
|
"url" :
|
||||||
typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
|
typeof s.data === "string" &&
|
||||||
|
!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
|
||||||
|
rjsonp.test( s.data ) && "data"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle iff the expected data type is "jsonp" or we have a parameter to set
|
// Handle iff the expected data type is "jsonp" or we have a parameter to set
|
||||||
|
@ -6,7 +6,8 @@ define([
|
|||||||
// Install script dataType
|
// Install script dataType
|
||||||
jQuery.ajaxSetup({
|
jQuery.ajaxSetup({
|
||||||
accepts: {
|
accepts: {
|
||||||
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
script: "text/javascript, application/javascript, " +
|
||||||
|
"application/ecmascript, application/x-ecmascript"
|
||||||
},
|
},
|
||||||
contents: {
|
contents: {
|
||||||
script: /(?:java|ecma)script/
|
script: /(?:java|ecma)script/
|
||||||
|
@ -7,7 +7,7 @@ define([
|
|||||||
jQuery.ajaxSettings.xhr = function() {
|
jQuery.ajaxSettings.xhr = function() {
|
||||||
try {
|
try {
|
||||||
return new XMLHttpRequest();
|
return new XMLHttpRequest();
|
||||||
} catch( e ) {}
|
} catch ( e ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
var xhrId = 0,
|
var xhrId = 0,
|
||||||
@ -45,7 +45,13 @@ jQuery.ajaxTransport(function( options ) {
|
|||||||
xhr = options.xhr(),
|
xhr = options.xhr(),
|
||||||
id = ++xhrId;
|
id = ++xhrId;
|
||||||
|
|
||||||
xhr.open( options.type, options.url, options.async, options.username, options.password );
|
xhr.open(
|
||||||
|
options.type,
|
||||||
|
options.url,
|
||||||
|
options.async,
|
||||||
|
options.username,
|
||||||
|
options.password
|
||||||
|
);
|
||||||
|
|
||||||
// Apply custom fields if provided
|
// Apply custom fields if provided
|
||||||
if ( options.xhrFields ) {
|
if ( options.xhrFields ) {
|
||||||
|
@ -50,7 +50,9 @@ jQuery.extend({
|
|||||||
if ( value === null ) {
|
if ( value === null ) {
|
||||||
jQuery.removeAttr( elem, name );
|
jQuery.removeAttr( elem, name );
|
||||||
|
|
||||||
} else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
} else if ( hooks && "set" in hooks &&
|
||||||
|
(ret = hooks.set( elem, value, name )) !== undefined ) {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,9 +2,9 @@ define([
|
|||||||
"../core",
|
"../core",
|
||||||
"../var/rnotwhite",
|
"../var/rnotwhite",
|
||||||
"../var/strundefined",
|
"../var/strundefined",
|
||||||
"../data/var/data_priv",
|
"../data/var/dataPriv",
|
||||||
"../core/init"
|
"../core/init"
|
||||||
], function( jQuery, rnotwhite, strundefined, data_priv ) {
|
], function( jQuery, rnotwhite, strundefined, dataPriv ) {
|
||||||
|
|
||||||
var rclass = /[\t\r\n\f]/g;
|
var rclass = /[\t\r\n\f]/g;
|
||||||
|
|
||||||
@ -104,7 +104,9 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
if ( jQuery.isFunction( value ) ) {
|
if ( jQuery.isFunction( value ) ) {
|
||||||
return this.each(function( i ) {
|
return this.each(function( i ) {
|
||||||
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
jQuery( this ).toggleClass(
|
||||||
|
value.call(this, i, this.className, stateVal), stateVal
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,14 +131,16 @@ jQuery.fn.extend({
|
|||||||
} else if ( type === strundefined || type === "boolean" ) {
|
} else if ( type === strundefined || type === "boolean" ) {
|
||||||
if ( this.className ) {
|
if ( this.className ) {
|
||||||
// store className if set
|
// store className if set
|
||||||
data_priv.set( this, "__className__", this.className );
|
dataPriv.set( this, "__className__", this.className );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the element has a class name or if we're passed `false`,
|
// If the element has a class name or if we're passed `false`,
|
||||||
// then remove the whole classname (if there was one, the above saved it).
|
// then remove the whole classname (if there was one, the above saved it).
|
||||||
// Otherwise bring back whatever was previously saved (if anything),
|
// Otherwise bring back whatever was previously saved (if anything),
|
||||||
// falling back to the empty string if nothing was stored.
|
// falling back to the empty string if nothing was stored.
|
||||||
this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
|
this.className = this.className || value === false ?
|
||||||
|
"" :
|
||||||
|
dataPriv.get( this, "__className__" ) || "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -146,7 +150,9 @@ jQuery.fn.extend({
|
|||||||
i = 0,
|
i = 0,
|
||||||
l = this.length;
|
l = this.length;
|
||||||
for ( ; i < l; i++ ) {
|
for ( ; i < l; i++ ) {
|
||||||
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
if ( this[i].nodeType === 1 &&
|
||||||
|
(" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,10 @@ jQuery.extend({
|
|||||||
propHooks: {
|
propHooks: {
|
||||||
tabIndex: {
|
tabIndex: {
|
||||||
get: function( elem ) {
|
get: function( elem ) {
|
||||||
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
|
return elem.hasAttribute( "tabindex" ) ||
|
||||||
elem.tabIndex :
|
rfocusable.test( elem.nodeName ) || elem.href ?
|
||||||
-1;
|
elem.tabIndex :
|
||||||
|
-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
if ( !arguments.length ) {
|
if ( !arguments.length ) {
|
||||||
if ( elem ) {
|
if ( elem ) {
|
||||||
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
hooks = jQuery.valHooks[ elem.type ] ||
|
||||||
|
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
|
||||||
|
|
||||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -100,8 +101,10 @@ jQuery.extend({
|
|||||||
// IE6-9 doesn't update selected after form reset (#2551)
|
// IE6-9 doesn't update selected after form reset (#2551)
|
||||||
if ( ( option.selected || i === index ) &&
|
if ( ( option.selected || i === index ) &&
|
||||||
// Don't return options that are disabled or in a disabled optgroup
|
// Don't return options that are disabled or in a disabled optgroup
|
||||||
( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
|
( support.optDisabled ?
|
||||||
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
!option.disabled : option.getAttribute( "disabled" ) === null ) &&
|
||||||
|
( !option.parentNode.disabled ||
|
||||||
|
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
||||||
|
|
||||||
// Get the specific value for the option
|
// Get the specific value for the option
|
||||||
value = jQuery( option ).val();
|
value = jQuery( option ).val();
|
||||||
|
@ -70,7 +70,9 @@ jQuery.Callbacks = function( options ) {
|
|||||||
firingLength = list.length;
|
firingLength = list.length;
|
||||||
firing = true;
|
firing = true;
|
||||||
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
||||||
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
|
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false &&
|
||||||
|
options.stopOnFalse ) {
|
||||||
|
|
||||||
memory = false; // To prevent further calls using add
|
memory = false; // To prevent further calls using add
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,9 @@ jQuery.extend = jQuery.fn.extend = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recurse if we're merging plain objects or arrays
|
// Recurse if we're merging plain objects or arrays
|
||||||
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
if ( deep && copy && ( jQuery.isPlainObject(copy) ||
|
||||||
|
(copyIsArray = jQuery.isArray(copy)) ) ) {
|
||||||
|
|
||||||
if ( copyIsArray ) {
|
if ( copyIsArray ) {
|
||||||
copyIsArray = false;
|
copyIsArray = false;
|
||||||
clone = src && jQuery.isArray(src) ? src : [];
|
clone = src && jQuery.isArray(src) ? src : [];
|
||||||
@ -458,7 +460,8 @@ jQuery.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Populate the class2type map
|
// Populate the class2type map
|
||||||
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
|
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),
|
||||||
|
function(i, name) {
|
||||||
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,7 +23,10 @@ var rootjQuery,
|
|||||||
|
|
||||||
// Handle HTML strings
|
// Handle HTML strings
|
||||||
if ( typeof selector === "string" ) {
|
if ( typeof selector === "string" ) {
|
||||||
if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
|
if ( selector[0] === "<" &&
|
||||||
|
selector[ selector.length - 1 ] === ">" &&
|
||||||
|
selector.length >= 3 ) {
|
||||||
|
|
||||||
// Assume that strings that start and end with <> are HTML and skip the regex check
|
// Assume that strings that start and end with <> are HTML and skip the regex check
|
||||||
match = [ null, selector, null ];
|
match = [ null, selector, null ];
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@ define([
|
|||||||
], function( jQuery, rsingleTag ) {
|
], function( jQuery, rsingleTag ) {
|
||||||
|
|
||||||
// data: string of html
|
// data: string of html
|
||||||
// context (optional): If specified, the fragment will be created in this context, defaults to document
|
// context (optional): If specified, the fragment will be created in this context,
|
||||||
|
// defaults to document
|
||||||
// keepScripts (optional): If true, will include scripts passed in the html string
|
// keepScripts (optional): If true, will include scripts passed in the html string
|
||||||
jQuery.parseHTML = function( data, context, keepScripts ) {
|
jQuery.parseHTML = function( data, context, keepScripts ) {
|
||||||
if ( !data || typeof data !== "string" ) {
|
if ( !data || typeof data !== "string" ) {
|
||||||
|
@ -72,8 +72,10 @@ jQuery.ready.promise = function( obj ) {
|
|||||||
|
|
||||||
readyList = jQuery.Deferred();
|
readyList = jQuery.Deferred();
|
||||||
|
|
||||||
// Catch cases where $(document).ready() is called after the browser event has already occurred.
|
// Catch cases where $(document).ready() is called
|
||||||
// We once tried to use readyState "interactive" here, but it caused issues like the one
|
// after the browser event has already occurred.
|
||||||
|
// We once tried to use readyState "interactive" here,
|
||||||
|
// but it caused issues like the one
|
||||||
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
||||||
if ( document.readyState === "complete" ) {
|
if ( document.readyState === "complete" ) {
|
||||||
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
||||||
|
46
src/css.js
46
src/css.js
@ -11,17 +11,18 @@ define([
|
|||||||
"./css/defaultDisplay",
|
"./css/defaultDisplay",
|
||||||
"./css/addGetHookIf",
|
"./css/addGetHookIf",
|
||||||
"./css/support",
|
"./css/support",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
|
|
||||||
"./core/init",
|
"./core/init",
|
||||||
"./css/swap",
|
"./css/swap",
|
||||||
"./core/ready",
|
"./core/ready",
|
||||||
"./selector" // contains
|
"./selector" // contains
|
||||||
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden,
|
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden,
|
||||||
getStyles, curCSS, defaultDisplay, addGetHookIf, support, data_priv ) {
|
getStyles, curCSS, defaultDisplay, addGetHookIf, support, dataPriv ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
// Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
|
// Swappable if display is none or starts with table
|
||||||
|
// except "table", "table-cell", or "table-caption"
|
||||||
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
|
||||||
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
||||||
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
|
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
|
||||||
@ -161,7 +162,7 @@ function showHide( elements, show ) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
values[ index ] = data_priv.get( elem, "olddisplay" );
|
values[ index ] = dataPriv.get( elem, "olddisplay" );
|
||||||
display = elem.style.display;
|
display = elem.style.display;
|
||||||
if ( show ) {
|
if ( show ) {
|
||||||
// Reset the inline display of this element to learn if it is
|
// Reset the inline display of this element to learn if it is
|
||||||
@ -174,13 +175,21 @@ function showHide( elements, show ) {
|
|||||||
// in a stylesheet to whatever the default browser style is
|
// in a stylesheet to whatever the default browser style is
|
||||||
// for such an element
|
// for such an element
|
||||||
if ( elem.style.display === "" && isHidden( elem ) ) {
|
if ( elem.style.display === "" && isHidden( elem ) ) {
|
||||||
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
|
values[ index ] = dataPriv.access(
|
||||||
|
elem,
|
||||||
|
"olddisplay",
|
||||||
|
defaultDisplay(elem.nodeName)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hidden = isHidden( elem );
|
hidden = isHidden( elem );
|
||||||
|
|
||||||
if ( display !== "none" || !hidden ) {
|
if ( display !== "none" || !hidden ) {
|
||||||
data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
|
dataPriv.set(
|
||||||
|
elem,
|
||||||
|
"olddisplay",
|
||||||
|
hidden ? display : jQuery.css( elem, "display" )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +261,8 @@ jQuery.extend({
|
|||||||
origName = jQuery.camelCase( name ),
|
origName = jQuery.camelCase( name ),
|
||||||
style = elem.style;
|
style = elem.style;
|
||||||
|
|
||||||
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
name = jQuery.cssProps[ origName ] ||
|
||||||
|
( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
|
||||||
|
|
||||||
// Gets hook for the prefixed version, then unprefixed version
|
// Gets hook for the prefixed version, then unprefixed version
|
||||||
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
||||||
@ -285,13 +295,17 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a hook was provided, use that value, otherwise just set the specified value
|
// If a hook was provided, use that value, otherwise just set the specified value
|
||||||
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
|
if ( !hooks || !("set" in hooks) ||
|
||||||
|
(value = hooks.set( elem, value, extra )) !== undefined ) {
|
||||||
|
|
||||||
style[ name ] = value;
|
style[ name ] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If a hook was provided get the non-computed value from there
|
// If a hook was provided get the non-computed value from there
|
||||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
if ( hooks && "get" in hooks &&
|
||||||
|
(ret = hooks.get( elem, false, extra )) !== undefined ) {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +319,8 @@ jQuery.extend({
|
|||||||
origName = jQuery.camelCase( name );
|
origName = jQuery.camelCase( name );
|
||||||
|
|
||||||
// Make sure that we're working with the right name
|
// Make sure that we're working with the right name
|
||||||
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
name = jQuery.cssProps[ origName ] ||
|
||||||
|
( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
|
||||||
|
|
||||||
// Try prefixed name followed by the unprefixed name
|
// Try prefixed name followed by the unprefixed name
|
||||||
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
||||||
@ -341,11 +356,12 @@ jQuery.each([ "height", "width" ], function( i, name ) {
|
|||||||
|
|
||||||
// Certain elements can have dimension info if we invisibly show them
|
// Certain elements can have dimension info if we invisibly show them
|
||||||
// but it must have a current display style that would benefit
|
// but it must have a current display style that would benefit
|
||||||
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
|
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
|
||||||
jQuery.swap( elem, cssShow, function() {
|
elem.offsetWidth === 0 ?
|
||||||
return getWidthOrHeight( elem, name, extra );
|
jQuery.swap( elem, cssShow, function() {
|
||||||
}) :
|
return getWidthOrHeight( elem, name, extra );
|
||||||
getWidthOrHeight( elem, name, extra );
|
}) :
|
||||||
|
getWidthOrHeight( elem, name, extra );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,8 +26,10 @@ function curCSS( elem, name, computed ) {
|
|||||||
|
|
||||||
// Support: iOS < 6
|
// Support: iOS < 6
|
||||||
// A tribute to the "awesome hack by Dean Edwards"
|
// A tribute to the "awesome hack by Dean Edwards"
|
||||||
// iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
|
// iOS < 6 (at least) returns percentage for a larger set of values,
|
||||||
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
// but width seems to be reliably pixels
|
||||||
|
// this is against the CSSOM draft spec:
|
||||||
|
// http://dev.w3.org/csswg/cssom/#resolved-values
|
||||||
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
|
||||||
|
|
||||||
// Remember the original values
|
// Remember the original values
|
||||||
|
@ -17,11 +17,15 @@ function actualDisplay( name, doc ) {
|
|||||||
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
||||||
|
|
||||||
// getDefaultComputedStyle might be reliably used only on attached element
|
// getDefaultComputedStyle might be reliably used only on attached element
|
||||||
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
|
display = window.getDefaultComputedStyle &&
|
||||||
|
( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
|
||||||
|
|
||||||
// Use of this method is a temporary fix (more like optimization) until something better comes along,
|
// Use of this method is a temporary fix (more like optimization)
|
||||||
// since it was removed from specification and supported only in FF
|
// until something better comes along,
|
||||||
style.display : jQuery.css( elem[ 0 ], "display" );
|
// since it was removed from specification and supported only in FF
|
||||||
|
style.display :
|
||||||
|
|
||||||
|
jQuery.css( elem[ 0 ], "display" );
|
||||||
|
|
||||||
// We don't have any data stored on the element,
|
// We don't have any data stored on the element,
|
||||||
// so use "detach" method as fast way to get rid of the element
|
// so use "detach" method as fast way to get rid of the element
|
||||||
@ -45,7 +49,8 @@ function defaultDisplay( nodeName ) {
|
|||||||
if ( display === "none" || !display ) {
|
if ( display === "none" || !display ) {
|
||||||
|
|
||||||
// Use the already-created iframe if possible
|
// Use the already-created iframe if possible
|
||||||
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
|
iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ))
|
||||||
|
.appendTo( doc.documentElement );
|
||||||
|
|
||||||
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
|
||||||
doc = iframe[ 0 ].contentDocument;
|
doc = iframe[ 0 ].contentDocument;
|
||||||
|
@ -8,6 +8,7 @@ define([
|
|||||||
// isHidden might be called from jQuery#filter function;
|
// isHidden might be called from jQuery#filter function;
|
||||||
// in that case, element will be second argument
|
// in that case, element will be second argument
|
||||||
elem = el || elem;
|
elem = el || elem;
|
||||||
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
|
return jQuery.css( elem, "display" ) === "none" ||
|
||||||
|
!jQuery.contains( elem.ownerDocument, elem );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
42
src/data.js
42
src/data.js
@ -2,9 +2,9 @@ define([
|
|||||||
"./core",
|
"./core",
|
||||||
"./var/rnotwhite",
|
"./var/rnotwhite",
|
||||||
"./core/access",
|
"./core/access",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
"./data/var/data_user"
|
"./data/var/dataUser"
|
||||||
], function( jQuery, rnotwhite, access, data_priv, data_user ) {
|
], function( jQuery, rnotwhite, access, dataPriv, dataUser ) {
|
||||||
|
|
||||||
// Implementation Summary
|
// Implementation Summary
|
||||||
//
|
//
|
||||||
@ -37,10 +37,10 @@ function dataAttr( elem, key, data ) {
|
|||||||
+data + "" === data ? +data :
|
+data + "" === data ? +data :
|
||||||
rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
||||||
data;
|
data;
|
||||||
} catch( e ) {}
|
} catch ( e ) {}
|
||||||
|
|
||||||
// Make sure we set the data so it isn't changed later
|
// Make sure we set the data so it isn't changed later
|
||||||
data_user.set( elem, key, data );
|
dataUser.set( elem, key, data );
|
||||||
} else {
|
} else {
|
||||||
data = undefined;
|
data = undefined;
|
||||||
}
|
}
|
||||||
@ -50,25 +50,25 @@ function dataAttr( elem, key, data ) {
|
|||||||
|
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
hasData: function( elem ) {
|
hasData: function( elem ) {
|
||||||
return data_user.hasData( elem ) || data_priv.hasData( elem );
|
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function( elem, name, data ) {
|
data: function( elem, name, data ) {
|
||||||
return data_user.access( elem, name, data );
|
return dataUser.access( elem, name, data );
|
||||||
},
|
},
|
||||||
|
|
||||||
removeData: function( elem, name ) {
|
removeData: function( elem, name ) {
|
||||||
data_user.remove( elem, name );
|
dataUser.remove( elem, name );
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Now that all calls to _data and _removeData have been replaced
|
// TODO: Now that all calls to _data and _removeData have been replaced
|
||||||
// with direct calls to data_priv methods, these can be deprecated.
|
// with direct calls to dataPriv methods, these can be deprecated.
|
||||||
_data: function( elem, name, data ) {
|
_data: function( elem, name, data ) {
|
||||||
return data_priv.access( elem, name, data );
|
return dataPriv.access( elem, name, data );
|
||||||
},
|
},
|
||||||
|
|
||||||
_removeData: function( elem, name ) {
|
_removeData: function( elem, name ) {
|
||||||
data_priv.remove( elem, name );
|
dataPriv.remove( elem, name );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,9 +81,9 @@ jQuery.fn.extend({
|
|||||||
// Gets all values
|
// Gets all values
|
||||||
if ( key === undefined ) {
|
if ( key === undefined ) {
|
||||||
if ( this.length ) {
|
if ( this.length ) {
|
||||||
data = data_user.get( elem );
|
data = dataUser.get( elem );
|
||||||
|
|
||||||
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
|
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
|
||||||
i = attrs.length;
|
i = attrs.length;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data_priv.set( elem, "hasDataAttrs", true );
|
dataPriv.set( elem, "hasDataAttrs", true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ jQuery.fn.extend({
|
|||||||
// Sets multiple values
|
// Sets multiple values
|
||||||
if ( typeof key === "object" ) {
|
if ( typeof key === "object" ) {
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
data_user.set( this, key );
|
dataUser.set( this, key );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,14 +123,14 @@ jQuery.fn.extend({
|
|||||||
if ( elem && value === undefined ) {
|
if ( elem && value === undefined ) {
|
||||||
// Attempt to get data from the cache
|
// Attempt to get data from the cache
|
||||||
// with the key as-is
|
// with the key as-is
|
||||||
data = data_user.get( elem, key );
|
data = dataUser.get( elem, key );
|
||||||
if ( data !== undefined ) {
|
if ( data !== undefined ) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to get data from the cache
|
// Attempt to get data from the cache
|
||||||
// with the key camelized
|
// with the key camelized
|
||||||
data = data_user.get( elem, camelKey );
|
data = dataUser.get( elem, camelKey );
|
||||||
if ( data !== undefined ) {
|
if ( data !== undefined ) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -150,18 +150,18 @@ jQuery.fn.extend({
|
|||||||
this.each(function() {
|
this.each(function() {
|
||||||
// First, attempt to store a copy or reference of any
|
// First, attempt to store a copy or reference of any
|
||||||
// data that might've been store with a camelCased key.
|
// data that might've been store with a camelCased key.
|
||||||
var data = data_user.get( this, camelKey );
|
var data = dataUser.get( this, camelKey );
|
||||||
|
|
||||||
// For HTML5 data-* attribute interop, we have to
|
// For HTML5 data-* attribute interop, we have to
|
||||||
// store property names with dashes in a camelCase form.
|
// store property names with dashes in a camelCase form.
|
||||||
// This might not apply to all properties...*
|
// This might not apply to all properties...*
|
||||||
data_user.set( this, camelKey, value );
|
dataUser.set( this, camelKey, value );
|
||||||
|
|
||||||
// *... In the case of properties that might _actually_
|
// *... In the case of properties that might _actually_
|
||||||
// have dashes, we need to also store a copy of that
|
// have dashes, we need to also store a copy of that
|
||||||
// unchanged property.
|
// unchanged property.
|
||||||
if ( key.indexOf("-") !== -1 && data !== undefined ) {
|
if ( key.indexOf("-") !== -1 && data !== undefined ) {
|
||||||
data_user.set( this, key, value );
|
dataUser.set( this, key, value );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, null, value, arguments.length > 1, null, true );
|
}, null, value, arguments.length > 1, null, true );
|
||||||
@ -169,7 +169,7 @@ jQuery.fn.extend({
|
|||||||
|
|
||||||
removeData: function( key ) {
|
removeData: function( key ) {
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
data_user.remove( this, key );
|
dataUser.remove( this, key );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,10 @@ jQuery.extend({
|
|||||||
.fail( newDefer.reject )
|
.fail( newDefer.reject )
|
||||||
.progress( newDefer.notify );
|
.progress( newDefer.notify );
|
||||||
} else {
|
} else {
|
||||||
newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
|
newDefer[ tuple[ 0 ] + "With" ](
|
||||||
|
this === promise ? newDefer.promise() : this,
|
||||||
|
fn ? [ returned ] : arguments
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -99,9 +102,11 @@ jQuery.extend({
|
|||||||
length = resolveValues.length,
|
length = resolveValues.length,
|
||||||
|
|
||||||
// the count of uncompleted subordinates
|
// the count of uncompleted subordinates
|
||||||
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
remaining = length !== 1 ||
|
||||||
|
( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
|
||||||
|
|
||||||
// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
|
// the master Deferred.
|
||||||
|
// If resolveValues consist of only a single Deferred, just use that.
|
||||||
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
|
||||||
|
|
||||||
// Update function for both resolve and progress values
|
// Update function for both resolve and progress values
|
||||||
|
@ -6,7 +6,9 @@ define([
|
|||||||
|
|
||||||
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
||||||
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
||||||
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
|
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
|
||||||
|
function( defaultExtra, funcName ) {
|
||||||
|
|
||||||
// Margin is only for outerHeight, outerWidth
|
// Margin is only for outerHeight, outerWidth
|
||||||
jQuery.fn[ funcName ] = function( margin, value ) {
|
jQuery.fn[ funcName ] = function( margin, value ) {
|
||||||
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
|
||||||
|
29
src/effects.js
vendored
29
src/effects.js
vendored
@ -4,7 +4,7 @@ define([
|
|||||||
"./css/var/cssExpand",
|
"./css/var/cssExpand",
|
||||||
"./css/var/isHidden",
|
"./css/var/isHidden",
|
||||||
"./css/defaultDisplay",
|
"./css/defaultDisplay",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
|
|
||||||
"./core/init",
|
"./core/init",
|
||||||
"./effects/Tween",
|
"./effects/Tween",
|
||||||
@ -12,7 +12,7 @@ define([
|
|||||||
"./css",
|
"./css",
|
||||||
"./deferred",
|
"./deferred",
|
||||||
"./traversing"
|
"./traversing"
|
||||||
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) {
|
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, dataPriv ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
fxNow, timerId,
|
fxNow, timerId,
|
||||||
@ -54,7 +54,9 @@ var
|
|||||||
|
|
||||||
// Update scale, tolerating zero or NaN from tween.cur(),
|
// Update scale, tolerating zero or NaN from tween.cur(),
|
||||||
// break the loop if scale is unchanged or perfect, or if we've just had enough
|
// break the loop if scale is unchanged or perfect, or if we've just had enough
|
||||||
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
} while (
|
||||||
|
scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update tween properties
|
// Update tween properties
|
||||||
@ -128,7 +130,7 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
orig = {},
|
orig = {},
|
||||||
style = elem.style,
|
style = elem.style,
|
||||||
hidden = elem.nodeType && isHidden( elem ),
|
hidden = elem.nodeType && isHidden( elem ),
|
||||||
dataShow = data_priv.get( elem, "fxshow" );
|
dataShow = dataPriv.get( elem, "fxshow" );
|
||||||
|
|
||||||
// Handle queue: false promises
|
// Handle queue: false promises
|
||||||
if ( !opts.queue ) {
|
if ( !opts.queue ) {
|
||||||
@ -169,7 +171,7 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
|
|
||||||
// Test default display if display is currently "none"
|
// Test default display if display is currently "none"
|
||||||
checkDisplay = display === "none" ?
|
checkDisplay = display === "none" ?
|
||||||
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
|
dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
|
||||||
|
|
||||||
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
|
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
|
||||||
style.display = "inline-block";
|
style.display = "inline-block";
|
||||||
@ -193,7 +195,8 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
toggle = toggle || value === "toggle";
|
toggle = toggle || value === "toggle";
|
||||||
if ( value === ( hidden ? "hide" : "show" ) ) {
|
if ( value === ( hidden ? "hide" : "show" ) ) {
|
||||||
|
|
||||||
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
|
// If there is dataShow left over from a stopped hide or show
|
||||||
|
// and we are going to proceed with show, we should pretend to be hidden
|
||||||
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
|
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
|
||||||
hidden = true;
|
hidden = true;
|
||||||
} else {
|
} else {
|
||||||
@ -214,7 +217,7 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
hidden = dataShow.hidden;
|
hidden = dataShow.hidden;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataShow = data_priv.access( elem, "fxshow", {} );
|
dataShow = dataPriv.access( elem, "fxshow", {} );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store state if its toggle - enables .stop().toggle() to "reverse"
|
// Store state if its toggle - enables .stop().toggle() to "reverse"
|
||||||
@ -231,7 +234,7 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
anim.done(function() {
|
anim.done(function() {
|
||||||
var prop;
|
var prop;
|
||||||
|
|
||||||
data_priv.remove( elem, "fxshow" );
|
dataPriv.remove( elem, "fxshow" );
|
||||||
for ( prop in orig ) {
|
for ( prop in orig ) {
|
||||||
jQuery.style( elem, prop, orig[ prop ] );
|
jQuery.style( elem, prop, orig[ prop ] );
|
||||||
}
|
}
|
||||||
@ -481,7 +484,7 @@ jQuery.fn.extend({
|
|||||||
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
||||||
|
|
||||||
// Empty animations, or finishing resolves immediately
|
// Empty animations, or finishing resolves immediately
|
||||||
if ( empty || data_priv.get( this, "finish" ) ) {
|
if ( empty || dataPriv.get( this, "finish" ) ) {
|
||||||
anim.stop( true );
|
anim.stop( true );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -511,7 +514,7 @@ jQuery.fn.extend({
|
|||||||
var dequeue = true,
|
var dequeue = true,
|
||||||
index = type != null && type + "queueHooks",
|
index = type != null && type + "queueHooks",
|
||||||
timers = jQuery.timers,
|
timers = jQuery.timers,
|
||||||
data = data_priv.get( this );
|
data = dataPriv.get( this );
|
||||||
|
|
||||||
if ( index ) {
|
if ( index ) {
|
||||||
if ( data[ index ] && data[ index ].stop ) {
|
if ( data[ index ] && data[ index ].stop ) {
|
||||||
@ -526,7 +529,9 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ( index = timers.length; index--; ) {
|
for ( index = timers.length; index--; ) {
|
||||||
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
if ( timers[ index ].elem === this &&
|
||||||
|
(type == null || timers[ index ].queue === type) ) {
|
||||||
|
|
||||||
timers[ index ].anim.stop( gotoEnd );
|
timers[ index ].anim.stop( gotoEnd );
|
||||||
dequeue = false;
|
dequeue = false;
|
||||||
timers.splice( index, 1 );
|
timers.splice( index, 1 );
|
||||||
@ -547,7 +552,7 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
var index,
|
var index,
|
||||||
data = data_priv.get( this ),
|
data = dataPriv.get( this ),
|
||||||
queue = data[ type + "queue" ],
|
queue = data[ type + "queue" ],
|
||||||
hooks = data[ type + "queueHooks" ],
|
hooks = data[ type + "queueHooks" ],
|
||||||
timers = jQuery.timers,
|
timers = jQuery.timers,
|
||||||
|
@ -78,7 +78,9 @@ Tween.propHooks = {
|
|||||||
// Use .style if available and use plain properties where available.
|
// Use .style if available and use plain properties where available.
|
||||||
if ( jQuery.fx.step[ tween.prop ] ) {
|
if ( jQuery.fx.step[ tween.prop ] ) {
|
||||||
jQuery.fx.step[ tween.prop ]( tween );
|
jQuery.fx.step[ tween.prop ]( tween );
|
||||||
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
|
} else if ( tween.elem.style &&
|
||||||
|
( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
|
||||||
|
jQuery.cssHooks[ tween.prop ] ) ) {
|
||||||
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
|
||||||
} else {
|
} else {
|
||||||
tween.elem[ tween.prop ] = tween.now;
|
tween.elem[ tween.prop ] = tween.now;
|
||||||
|
65
src/event.js
65
src/event.js
@ -5,12 +5,12 @@ define([
|
|||||||
"./var/hasOwn",
|
"./var/hasOwn",
|
||||||
"./var/slice",
|
"./var/slice",
|
||||||
"./event/support",
|
"./event/support",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
|
|
||||||
"./core/init",
|
"./core/init",
|
||||||
"./data/accepts",
|
"./data/accepts",
|
||||||
"./selector"
|
"./selector"
|
||||||
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) {
|
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, dataPriv ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
rkeyEvent = /^key/,
|
rkeyEvent = /^key/,
|
||||||
@ -45,7 +45,7 @@ jQuery.event = {
|
|||||||
var handleObjIn, eventHandle, tmp,
|
var handleObjIn, eventHandle, tmp,
|
||||||
events, t, handleObj,
|
events, t, handleObj,
|
||||||
special, handlers, type, namespaces, origType,
|
special, handlers, type, namespaces, origType,
|
||||||
elemData = data_priv.get( elem );
|
elemData = dataPriv.get( elem );
|
||||||
|
|
||||||
// Don't attach events to noData or text/comment nodes (but allow plain objects)
|
// Don't attach events to noData or text/comment nodes (but allow plain objects)
|
||||||
if ( !elemData ) {
|
if ( !elemData ) {
|
||||||
@ -117,7 +117,9 @@ jQuery.event = {
|
|||||||
handlers.delegateCount = 0;
|
handlers.delegateCount = 0;
|
||||||
|
|
||||||
// Only use addEventListener if the special events handler returns false
|
// Only use addEventListener if the special events handler returns false
|
||||||
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
if ( !special.setup ||
|
||||||
|
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
||||||
|
|
||||||
if ( elem.addEventListener ) {
|
if ( elem.addEventListener ) {
|
||||||
elem.addEventListener( type, eventHandle, false );
|
elem.addEventListener( type, eventHandle, false );
|
||||||
}
|
}
|
||||||
@ -151,7 +153,7 @@ jQuery.event = {
|
|||||||
var j, origCount, tmp,
|
var j, origCount, tmp,
|
||||||
events, t, handleObj,
|
events, t, handleObj,
|
||||||
special, handlers, type, namespaces, origType,
|
special, handlers, type, namespaces, origType,
|
||||||
elemData = data_priv.hasData( elem ) && data_priv.get( elem );
|
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
|
||||||
|
|
||||||
if ( !elemData || !(events = elemData.events) ) {
|
if ( !elemData || !(events = elemData.events) ) {
|
||||||
return;
|
return;
|
||||||
@ -186,7 +188,8 @@ jQuery.event = {
|
|||||||
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
||||||
( !handler || handler.guid === handleObj.guid ) &&
|
( !handler || handler.guid === handleObj.guid ) &&
|
||||||
( !tmp || tmp.test( handleObj.namespace ) ) &&
|
( !tmp || tmp.test( handleObj.namespace ) ) &&
|
||||||
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
( !selector || selector === handleObj.selector ||
|
||||||
|
selector === "**" && handleObj.selector ) ) {
|
||||||
handlers.splice( j, 1 );
|
handlers.splice( j, 1 );
|
||||||
|
|
||||||
if ( handleObj.selector ) {
|
if ( handleObj.selector ) {
|
||||||
@ -201,7 +204,9 @@ jQuery.event = {
|
|||||||
// Remove generic event handler if we removed something and no more handlers exist
|
// Remove generic event handler if we removed something and no more handlers exist
|
||||||
// (avoids potential for endless recursion during removal of special event handlers)
|
// (avoids potential for endless recursion during removal of special event handlers)
|
||||||
if ( origCount && !handlers.length ) {
|
if ( origCount && !handlers.length ) {
|
||||||
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
if ( !special.teardown ||
|
||||||
|
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
|
||||||
|
|
||||||
jQuery.removeEvent( elem, type, elemData.handle );
|
jQuery.removeEvent( elem, type, elemData.handle );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +217,7 @@ jQuery.event = {
|
|||||||
// Remove the expando if it's no longer used
|
// Remove the expando if it's no longer used
|
||||||
if ( jQuery.isEmptyObject( events ) ) {
|
if ( jQuery.isEmptyObject( events ) ) {
|
||||||
delete elemData.handle;
|
delete elemData.handle;
|
||||||
data_priv.remove( elem, "events" );
|
dataPriv.remove( elem, "events" );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -251,7 +256,7 @@ jQuery.event = {
|
|||||||
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
|
||||||
event.isTrigger = onlyHandlers ? 2 : 3;
|
event.isTrigger = onlyHandlers ? 2 : 3;
|
||||||
event.namespace = namespaces.join(".");
|
event.namespace = namespaces.join(".");
|
||||||
event.namespace_re = event.namespace ?
|
event.rnamespace = event.namespace ?
|
||||||
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
@ -300,7 +305,8 @@ jQuery.event = {
|
|||||||
special.bindType || type;
|
special.bindType || type;
|
||||||
|
|
||||||
// jQuery handler
|
// jQuery handler
|
||||||
handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
|
handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
|
||||||
|
dataPriv.get( cur, "handle" );
|
||||||
if ( handle ) {
|
if ( handle ) {
|
||||||
handle.apply( cur, data );
|
handle.apply( cur, data );
|
||||||
}
|
}
|
||||||
@ -356,7 +362,7 @@ jQuery.event = {
|
|||||||
var i, j, ret, matched, handleObj,
|
var i, j, ret, matched, handleObj,
|
||||||
handlerQueue = [],
|
handlerQueue = [],
|
||||||
args = slice.call( arguments ),
|
args = slice.call( arguments ),
|
||||||
handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
|
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
|
||||||
special = jQuery.event.special[ event.type ] || {};
|
special = jQuery.event.special[ event.type ] || {};
|
||||||
|
|
||||||
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
||||||
@ -377,17 +383,18 @@ jQuery.event = {
|
|||||||
event.currentTarget = matched.elem;
|
event.currentTarget = matched.elem;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
|
while ( (handleObj = matched.handlers[ j++ ]) &&
|
||||||
|
!event.isImmediatePropagationStopped() ) {
|
||||||
|
|
||||||
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
|
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
|
||||||
// a subset or equal to those in the bound event (both can have no namespace).
|
// a subset or equal to those in the bound event (both can have no namespace).
|
||||||
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
|
if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
|
||||||
|
|
||||||
event.handleObj = handleObj;
|
event.handleObj = handleObj;
|
||||||
event.data = handleObj.data;
|
event.data = handleObj.data;
|
||||||
|
|
||||||
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle ||
|
||||||
.apply( matched.elem, args );
|
handleObj.handler ).apply( matched.elem, args );
|
||||||
|
|
||||||
if ( ret !== undefined ) {
|
if ( ret !== undefined ) {
|
||||||
if ( (event.result = ret) === false ) {
|
if ( (event.result = ret) === false ) {
|
||||||
@ -454,7 +461,8 @@ jQuery.event = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Includes some event props shared by KeyEvent and MouseEvent
|
// Includes some event props shared by KeyEvent and MouseEvent
|
||||||
props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
props: ( "altKey bubbles cancelable ctrlKey currentTarget eventPhase " +
|
||||||
|
"metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "),
|
||||||
|
|
||||||
fixHooks: {},
|
fixHooks: {},
|
||||||
|
|
||||||
@ -472,7 +480,8 @@ jQuery.event = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
mouseHooks: {
|
mouseHooks: {
|
||||||
props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " +
|
||||||
|
"screenX screenY toElement" ).split(" "),
|
||||||
filter: function( event, original ) {
|
filter: function( event, original ) {
|
||||||
var eventDoc, doc, body,
|
var eventDoc, doc, body,
|
||||||
button = original.button;
|
button = original.button;
|
||||||
@ -483,8 +492,12 @@ jQuery.event = {
|
|||||||
doc = eventDoc.documentElement;
|
doc = eventDoc.documentElement;
|
||||||
body = eventDoc.body;
|
body = eventDoc.body;
|
||||||
|
|
||||||
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
event.pageX = original.clientX +
|
||||||
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
|
||||||
|
( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
||||||
|
event.pageY = original.clientY +
|
||||||
|
( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
|
||||||
|
( doc && doc.clientTop || body && body.clientTop || 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add which for click: 1 === left; 2 === middle; 3 === right
|
// Add which for click: 1 === left; 2 === middle; 3 === right
|
||||||
@ -738,23 +751,23 @@ if ( !support.focusinBubbles ) {
|
|||||||
jQuery.event.special[ fix ] = {
|
jQuery.event.special[ fix ] = {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
var doc = this.ownerDocument || this,
|
var doc = this.ownerDocument || this,
|
||||||
attaches = data_priv.access( doc, fix );
|
attaches = dataPriv.access( doc, fix );
|
||||||
|
|
||||||
if ( !attaches ) {
|
if ( !attaches ) {
|
||||||
doc.addEventListener( orig, handler, true );
|
doc.addEventListener( orig, handler, true );
|
||||||
}
|
}
|
||||||
data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
|
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
|
||||||
},
|
},
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
var doc = this.ownerDocument || this,
|
var doc = this.ownerDocument || this,
|
||||||
attaches = data_priv.access( doc, fix ) - 1;
|
attaches = dataPriv.access( doc, fix ) - 1;
|
||||||
|
|
||||||
if ( !attaches ) {
|
if ( !attaches ) {
|
||||||
doc.removeEventListener( orig, handler, true );
|
doc.removeEventListener( orig, handler, true );
|
||||||
data_priv.remove( doc, fix );
|
dataPriv.remove( doc, fix );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
data_priv.access( doc, fix, attaches );
|
dataPriv.access( doc, fix, attaches );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -825,7 +838,9 @@ jQuery.fn.extend({
|
|||||||
// ( event ) dispatched jQuery.Event
|
// ( event ) dispatched jQuery.Event
|
||||||
handleObj = types.handleObj;
|
handleObj = types.handleObj;
|
||||||
jQuery( types.delegateTarget ).off(
|
jQuery( types.delegateTarget ).off(
|
||||||
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
handleObj.namespace ?
|
||||||
|
handleObj.origType + "." + handleObj.namespace :
|
||||||
|
handleObj.origType,
|
||||||
handleObj.selector,
|
handleObj.selector,
|
||||||
handleObj.handler
|
handleObj.handler
|
||||||
);
|
);
|
||||||
|
@ -4,7 +4,14 @@ define([
|
|||||||
], function( jQuery ) {
|
], function( jQuery ) {
|
||||||
|
|
||||||
// Attach a bunch of functions for handling common AJAX events
|
// Attach a bunch of functions for handling common AJAX events
|
||||||
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
|
jQuery.each([
|
||||||
|
"ajaxStart",
|
||||||
|
"ajaxStop",
|
||||||
|
"ajaxComplete",
|
||||||
|
"ajaxError",
|
||||||
|
"ajaxSuccess",
|
||||||
|
"ajaxSend"
|
||||||
|
], function( i, type ) {
|
||||||
jQuery.fn[ type ] = function( fn ) {
|
jQuery.fn[ type ] = function( fn ) {
|
||||||
return this.on( type, fn );
|
return this.on( type, fn );
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,8 @@ define([
|
|||||||
|
|
||||||
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
||||||
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
||||||
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
"change select submit keydown keypress keyup error contextmenu").split(" "),
|
||||||
|
function( i, name ) {
|
||||||
|
|
||||||
// Handle event binding
|
// Handle event binding
|
||||||
jQuery.fn[ name ] = function( data, fn ) {
|
jQuery.fn[ name ] = function( data, fn ) {
|
||||||
@ -32,7 +33,9 @@ jQuery.fn.extend({
|
|||||||
},
|
},
|
||||||
undelegate: function( selector, types, fn ) {
|
undelegate: function( selector, types, fn ) {
|
||||||
// ( namespace ) or ( selector, types [, fn] )
|
// ( namespace ) or ( selector, types [, fn] )
|
||||||
return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
|
return arguments.length === 1 ?
|
||||||
|
this.off( selector, "**" ) :
|
||||||
|
this.off( types, selector || "**", fn );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ define([
|
|||||||
"./core/access",
|
"./core/access",
|
||||||
"./manipulation/var/rcheckableType",
|
"./manipulation/var/rcheckableType",
|
||||||
"./manipulation/support",
|
"./manipulation/support",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
"./data/var/data_user",
|
"./data/var/dataUser",
|
||||||
|
|
||||||
"./core/init",
|
"./core/init",
|
||||||
"./data/accepts",
|
"./data/accepts",
|
||||||
"./traversing",
|
"./traversing",
|
||||||
"./selector",
|
"./selector",
|
||||||
"./event"
|
"./event"
|
||||||
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) {
|
], function( jQuery, concat, push, access, rcheckableType, support, dataPriv, dataUser ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
||||||
@ -80,8 +80,8 @@ function setGlobalEval( elems, refElements ) {
|
|||||||
l = elems.length;
|
l = elems.length;
|
||||||
|
|
||||||
for ( ; i < l; i++ ) {
|
for ( ; i < l; i++ ) {
|
||||||
data_priv.set(
|
dataPriv.set(
|
||||||
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
|
elems[ i ], "globalEval", !refElements || dataPriv.get( refElements[ i ], "globalEval" )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,9 +94,9 @@ function cloneCopyEvent( src, dest ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. Copy private data: events, handlers, etc.
|
// 1. Copy private data: events, handlers, etc.
|
||||||
if ( data_priv.hasData( src ) ) {
|
if ( dataPriv.hasData( src ) ) {
|
||||||
pdataOld = data_priv.access( src );
|
pdataOld = dataPriv.access( src );
|
||||||
pdataCur = data_priv.set( dest, pdataOld );
|
pdataCur = dataPriv.set( dest, pdataOld );
|
||||||
events = pdataOld.events;
|
events = pdataOld.events;
|
||||||
|
|
||||||
if ( events ) {
|
if ( events ) {
|
||||||
@ -112,11 +112,11 @@ function cloneCopyEvent( src, dest ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Copy user data
|
// 2. Copy user data
|
||||||
if ( data_user.hasData( src ) ) {
|
if ( dataUser.hasData( src ) ) {
|
||||||
udataOld = data_user.access( src );
|
udataOld = dataUser.access( src );
|
||||||
udataCur = jQuery.extend( {}, udataOld );
|
udataCur = jQuery.extend( {}, udataOld );
|
||||||
|
|
||||||
data_user.set( dest, udataCur );
|
dataUser.set( dest, udataCur );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,9 +280,9 @@ jQuery.extend({
|
|||||||
|
|
||||||
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
|
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
|
||||||
if ( jQuery.acceptData( elem ) ) {
|
if ( jQuery.acceptData( elem ) ) {
|
||||||
key = elem[ data_priv.expando ];
|
key = elem[ dataPriv.expando ];
|
||||||
|
|
||||||
if ( key && (data = data_priv.cache[ key ]) ) {
|
if ( key && (data = dataPriv.cache[ key ]) ) {
|
||||||
if ( data.events ) {
|
if ( data.events ) {
|
||||||
for ( type in data.events ) {
|
for ( type in data.events ) {
|
||||||
if ( special[ type ] ) {
|
if ( special[ type ] ) {
|
||||||
@ -294,14 +294,14 @@ jQuery.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( data_priv.cache[ key ] ) {
|
if ( dataPriv.cache[ key ] ) {
|
||||||
// Discard any remaining `private` data
|
// Discard any remaining `private` data
|
||||||
delete data_priv.cache[ key ];
|
delete dataPriv.cache[ key ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Discard any remaining `user` data
|
// Discard any remaining `user` data
|
||||||
delete data_user.cache[ elem[ data_user.expando ] ];
|
delete dataUser.cache[ elem[ dataUser.expando ] ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -431,7 +431,7 @@ jQuery.fn.extend({
|
|||||||
elem = 0;
|
elem = 0;
|
||||||
|
|
||||||
// If using innerHTML throws an exception, use the fallback method
|
// If using innerHTML throws an exception, use the fallback method
|
||||||
} catch( e ) {}
|
} catch ( e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( elem ) {
|
if ( elem ) {
|
||||||
@ -500,7 +500,8 @@ jQuery.fn.extend({
|
|||||||
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
||||||
hasScripts = scripts.length;
|
hasScripts = scripts.length;
|
||||||
|
|
||||||
// Use the original fragment for the last item instead of the first because it can end up
|
// Use the original fragment for the last item
|
||||||
|
// instead of the first because it can end up
|
||||||
// being emptied incorrectly in certain situations (#8070).
|
// being emptied incorrectly in certain situations (#8070).
|
||||||
for ( ; i < l; i++ ) {
|
for ( ; i < l; i++ ) {
|
||||||
node = fragment;
|
node = fragment;
|
||||||
@ -529,7 +530,8 @@ jQuery.fn.extend({
|
|||||||
for ( i = 0; i < hasScripts; i++ ) {
|
for ( i = 0; i < hasScripts; i++ ) {
|
||||||
node = scripts[ i ];
|
node = scripts[ i ];
|
||||||
if ( rscriptType.test( node.type || "" ) &&
|
if ( rscriptType.test( node.type || "" ) &&
|
||||||
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
!dataPriv.access( node, "globalEval" ) &&
|
||||||
|
jQuery.contains( doc, node ) ) {
|
||||||
|
|
||||||
if ( node.src ) {
|
if ( node.src ) {
|
||||||
// Optional AJAX dependency, but won't run scripts if not present
|
// Optional AJAX dependency, but won't run scripts if not present
|
||||||
|
@ -118,7 +118,8 @@ jQuery.fn.extend({
|
|||||||
elem = this[ 0 ],
|
elem = this[ 0 ],
|
||||||
parentOffset = { top: 0, left: 0 };
|
parentOffset = { top: 0, left: 0 };
|
||||||
|
|
||||||
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
|
// Fixed elements are offset from window (parentOffset = {top:0, left: 0},
|
||||||
|
// because it is its only offset parent
|
||||||
if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
if ( jQuery.css( elem, "position" ) === "fixed" ) {
|
||||||
// Assume getBoundingClientRect is there when computed position is fixed
|
// Assume getBoundingClientRect is there when computed position is fixed
|
||||||
offset = elem.getBoundingClientRect();
|
offset = elem.getBoundingClientRect();
|
||||||
@ -149,7 +150,8 @@ jQuery.fn.extend({
|
|||||||
return this.map(function() {
|
return this.map(function() {
|
||||||
var offsetParent = this.offsetParent || docElem;
|
var offsetParent = this.offsetParent || docElem;
|
||||||
|
|
||||||
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
|
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
|
||||||
|
jQuery.css( offsetParent, "position" ) === "static" ) ) {
|
||||||
offsetParent = offsetParent.offsetParent;
|
offsetParent = offsetParent.offsetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
src/queue.js
14
src/queue.js
@ -1,9 +1,9 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
"./data/var/data_priv",
|
"./data/var/dataPriv",
|
||||||
"./deferred",
|
"./deferred",
|
||||||
"./callbacks"
|
"./callbacks"
|
||||||
], function( jQuery, data_priv ) {
|
], function( jQuery, dataPriv ) {
|
||||||
|
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
queue: function( elem, type, data ) {
|
queue: function( elem, type, data ) {
|
||||||
@ -11,12 +11,12 @@ jQuery.extend({
|
|||||||
|
|
||||||
if ( elem ) {
|
if ( elem ) {
|
||||||
type = ( type || "fx" ) + "queue";
|
type = ( type || "fx" ) + "queue";
|
||||||
queue = data_priv.get( elem, type );
|
queue = dataPriv.get( elem, type );
|
||||||
|
|
||||||
// Speed up dequeue by getting out quickly if this is just a lookup
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
||||||
if ( data ) {
|
if ( data ) {
|
||||||
if ( !queue || jQuery.isArray( data ) ) {
|
if ( !queue || jQuery.isArray( data ) ) {
|
||||||
queue = data_priv.access( elem, type, jQuery.makeArray(data) );
|
queue = dataPriv.access( elem, type, jQuery.makeArray(data) );
|
||||||
} else {
|
} else {
|
||||||
queue.push( data );
|
queue.push( data );
|
||||||
}
|
}
|
||||||
@ -63,9 +63,9 @@ jQuery.extend({
|
|||||||
// Not public - generate a queueHooks object, or return the current one
|
// Not public - generate a queueHooks object, or return the current one
|
||||||
_queueHooks: function( elem, type ) {
|
_queueHooks: function( elem, type ) {
|
||||||
var key = type + "queueHooks";
|
var key = type + "queueHooks";
|
||||||
return data_priv.get( elem, key ) || data_priv.access( elem, key, {
|
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
|
||||||
empty: jQuery.Callbacks("once memory").add(function() {
|
empty: jQuery.Callbacks("once memory").add(function() {
|
||||||
data_priv.remove( elem, [ type + "queue", key ] );
|
dataPriv.remove( elem, [ type + "queue", key ] );
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ jQuery.fn.extend({
|
|||||||
type = type || "fx";
|
type = type || "fx";
|
||||||
|
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
tmp = data_priv.get( elements[ i ], type + "queueHooks" );
|
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
|
||||||
if ( tmp && tmp.empty ) {
|
if ( tmp && tmp.empty ) {
|
||||||
count++;
|
count++;
|
||||||
tmp.empty.add( resolve );
|
tmp.empty.add( resolve );
|
||||||
|
@ -27,21 +27,23 @@ define([
|
|||||||
* customize this stub for the project's specific needs.
|
* customize this stub for the project's specific needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var docElem = window.document.documentElement,
|
var hasDuplicate,
|
||||||
selector_hasDuplicate,
|
docElem = window.document.documentElement,
|
||||||
matches = docElem.matches ||
|
matches = docElem.matches ||
|
||||||
docElem.webkitMatchesSelector ||
|
docElem.webkitMatchesSelector ||
|
||||||
docElem.mozMatchesSelector ||
|
docElem.mozMatchesSelector ||
|
||||||
docElem.oMatchesSelector ||
|
docElem.oMatchesSelector ||
|
||||||
docElem.msMatchesSelector,
|
docElem.msMatchesSelector,
|
||||||
selector_sortOrder = function( a, b ) {
|
sortOrder = function( a, b ) {
|
||||||
// Flag for duplicate removal
|
// Flag for duplicate removal
|
||||||
if ( a === b ) {
|
if ( a === b ) {
|
||||||
selector_hasDuplicate = true;
|
hasDuplicate = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
|
var compare = b.compareDocumentPosition &&
|
||||||
|
a.compareDocumentPosition &&
|
||||||
|
a.compareDocumentPosition( b );
|
||||||
|
|
||||||
if ( compare ) {
|
if ( compare ) {
|
||||||
// Disconnected nodes
|
// Disconnected nodes
|
||||||
@ -102,10 +104,10 @@ jQuery.extend({
|
|||||||
i = 0,
|
i = 0,
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
selector_hasDuplicate = false;
|
hasDuplicate = false;
|
||||||
results.sort( selector_sortOrder );
|
results.sort( sortOrder );
|
||||||
|
|
||||||
if ( selector_hasDuplicate ) {
|
if ( hasDuplicate ) {
|
||||||
while ( (elem = results[i++]) ) {
|
while ( (elem = results[i++]) ) {
|
||||||
if ( elem === results[ i ] ) {
|
if ( elem === results[ i ] ) {
|
||||||
j = duplicates.push( i );
|
j = duplicates.push( i );
|
||||||
|
@ -24,7 +24,12 @@ function buildParams( prefix, obj, traditional, add ) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Item is non-scalar (array or object), encode its numeric index.
|
// Item is non-scalar (array or object), encode its numeric index.
|
||||||
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
|
buildParams(
|
||||||
|
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]",
|
||||||
|
v,
|
||||||
|
traditional,
|
||||||
|
add
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -224,7 +224,8 @@ this.testIframe = function( fileName, name, fn ) {
|
|||||||
function loadFixture() {
|
function loadFixture() {
|
||||||
var src = url( "./data/" + fileName + ".html" ),
|
var src = url( "./data/" + fileName + ".html" ),
|
||||||
iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ];
|
iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ];
|
||||||
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
|
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; " +
|
||||||
|
"top: -600px; left: -600px; visibility: hidden;";
|
||||||
|
|
||||||
iframe.contentWindow.location = src;
|
iframe.contentWindow.location = src;
|
||||||
return iframe;
|
return iframe;
|
||||||
@ -304,7 +305,8 @@ this.loadTests = function() {
|
|||||||
|
|
||||||
// Load the TestSwarm listener if swarmURL is in the address.
|
// Load the TestSwarm listener if swarmURL is in the address.
|
||||||
if ( loadSwarm ) {
|
if ( loadSwarm ) {
|
||||||
require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
|
require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ],
|
||||||
|
function() {
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,12 +25,13 @@ QUnit.config.requireExpects = true;
|
|||||||
* @param {string} key
|
* @param {string} key
|
||||||
*/
|
*/
|
||||||
QUnit.expectJqData = function( elems, key ) {
|
QUnit.expectJqData = function( elems, key ) {
|
||||||
var i, elem, expando;
|
var i, elem, expando,
|
||||||
|
currentEnv = "current_testEnvironment";
|
||||||
|
|
||||||
// As of jQuery 2.0, there will be no "cache"-data is
|
// As of jQuery 2.0, there will be no "cache"-data is
|
||||||
// stored and managed completely below the API surface
|
// stored and managed completely below the API surface
|
||||||
if ( jQuery.cache ) {
|
if ( jQuery.cache ) {
|
||||||
QUnit.current_testEnvironment.checkJqData = true;
|
QUnit[ currentEnv ].checkJqData = true;
|
||||||
|
|
||||||
if ( elems.jquery && elems.toArray ) {
|
if ( elems.jquery && elems.toArray ) {
|
||||||
elems = elems.toArray();
|
elems = elems.toArray();
|
||||||
@ -62,7 +63,12 @@ QUnit.expectJqData = function( elems, key ) {
|
|||||||
// Since this method was called it means some data was
|
// Since this method was called it means some data was
|
||||||
// expected to be found, but since there is nothing, fail early
|
// expected to be found, but since there is nothing, fail early
|
||||||
// (instead of in teardown).
|
// (instead of in teardown).
|
||||||
notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
|
notStrictEqual(
|
||||||
|
expando,
|
||||||
|
undefined,
|
||||||
|
"Target for expectJqData must have an expando, " +
|
||||||
|
"for else there can be no data to expect."
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if ( expectedDataKeys[ expando ] ) {
|
if ( expectedDataKeys[ expando ] ) {
|
||||||
expectedDataKeys[ expando ].push( key );
|
expectedDataKeys[ expando ].push( key );
|
||||||
@ -77,7 +83,8 @@ QUnit.expectJqData = function( elems, key ) {
|
|||||||
QUnit.config.urlConfig.push({
|
QUnit.config.urlConfig.push({
|
||||||
id: "jqdata",
|
id: "jqdata",
|
||||||
label: "Always check jQuery.data",
|
label: "Always check jQuery.data",
|
||||||
tooltip: "Trigger QUnit.expectJqData detection for all tests instead of just the ones that call it"
|
tooltip: "Trigger QUnit.expectJqData detection for all tests " +
|
||||||
|
"instead of just the ones that call it"
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +109,11 @@ window.moduleTeardown = function() {
|
|||||||
}
|
}
|
||||||
// In case it was removed from cache before (or never there in the first place)
|
// In case it was removed from cache before (or never there in the first place)
|
||||||
for ( i in expectedDataKeys ) {
|
for ( i in expectedDataKeys ) {
|
||||||
deepEqual( expectedDataKeys[ i ], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
|
deepEqual(
|
||||||
|
expectedDataKeys[ i ],
|
||||||
|
undefined,
|
||||||
|
"No unexpected keys were left in jQuery.cache (#" + i + ")"
|
||||||
|
);
|
||||||
delete expectedDataKeys[ i ];
|
delete expectedDataKeys[ i ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,8 +141,10 @@ window.moduleTeardown = function() {
|
|||||||
++cacheLength;
|
++cacheLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test,
|
// Because QUnit doesn't have a mechanism for retrieving
|
||||||
// if we unconditionally assert any of these, the test will fail with too many assertions :|
|
// the number of expected assertions for a test,
|
||||||
|
// if we unconditionally assert any of these,
|
||||||
|
// the test will fail with too many assertions :|
|
||||||
if ( cacheLength !== oldCacheLength ) {
|
if ( cacheLength !== oldCacheLength ) {
|
||||||
equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
|
equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
|
||||||
oldCacheLength = cacheLength;
|
oldCacheLength = cacheLength;
|
||||||
|
Loading…
Reference in New Issue
Block a user