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({
|
||||
pkg: grunt.file.readJSON( "package.json" ),
|
||||
dst: readOptionalJSON( "dist/.destination.json" ),
|
||||
compare_size: {
|
||||
"compare_size": {
|
||||
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
||||
options: {
|
||||
compress: {
|
||||
@ -93,13 +93,31 @@ module.exports = function( grunt ) {
|
||||
src: "src/**/*.js",
|
||||
gruntfile: "Gruntfile.js",
|
||||
|
||||
// Right know, check only test helpers
|
||||
test: [ "test/data/testrunner.js", "test/data/testinit.js" ],
|
||||
release: "build/*.js",
|
||||
// Right now, check only test helpers
|
||||
test: [ "test/data/testrunner.js" ],
|
||||
release: [ "build/*.js", "!build/release-notes.js" ],
|
||||
tasks: "build/tasks/*.js"
|
||||
},
|
||||
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: {
|
||||
files: [ "<%= jshint.all.src %>" ],
|
||||
@ -116,13 +134,13 @@ module.exports = function( grunt ) {
|
||||
sourceMappingURL: "jquery.min.map",
|
||||
report: "min",
|
||||
beautify: {
|
||||
ascii_only: true
|
||||
"ascii_only": true
|
||||
},
|
||||
banner: "/*! jQuery v<%= pkg.version %> | " +
|
||||
"(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
|
||||
"jquery.org/license */",
|
||||
compress: {
|
||||
hoist_funs: false,
|
||||
"hoist_funs": false,
|
||||
loops: false,
|
||||
unused: false
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ http.request({
|
||||
host: "bugs.jquery.com",
|
||||
port: 80,
|
||||
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 ) {
|
||||
var data = [];
|
||||
|
||||
|
@ -89,7 +89,9 @@ module.exports = function( Release ) {
|
||||
|
||||
var archiver = require( "archiver" )( "zip" ),
|
||||
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 ) {
|
||||
throw err;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* 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 ) {
|
||||
@ -35,7 +36,8 @@ module.exports = function( grunt ) {
|
||||
/**
|
||||
* Strip all definitions generated by requirejs
|
||||
* 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
|
||||
* @param {String} name
|
||||
* @param {String} path
|
||||
@ -98,7 +100,8 @@ module.exports = function( grunt ) {
|
||||
|
||||
grunt.registerMultiTask(
|
||||
"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() {
|
||||
var flag, index,
|
||||
done = this.async(),
|
||||
@ -113,7 +116,8 @@ module.exports = function( grunt ) {
|
||||
/**
|
||||
* Recursively calls the excluder to remove on all modules in the 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 ) {
|
||||
if ( list ) {
|
||||
@ -121,7 +125,9 @@ module.exports = function( grunt ) {
|
||||
list.forEach(function( module ) {
|
||||
// Exclude var modules as well
|
||||
if ( module === "var" ) {
|
||||
excludeList( fs.readdirSync( srcFolder + prepend + module ), prepend + module );
|
||||
excludeList(
|
||||
fs.readdirSync( srcFolder + prepend + module ), prepend + module
|
||||
);
|
||||
return;
|
||||
}
|
||||
if ( prepend ) {
|
||||
@ -143,7 +149,9 @@ module.exports = function( grunt ) {
|
||||
},
|
||||
/**
|
||||
* 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 ) {
|
||||
var m = /^(\+|\-|)([\w\/-]+)$/.exec( flag ),
|
||||
@ -171,7 +179,9 @@ module.exports = function( grunt ) {
|
||||
} else {
|
||||
grunt.log.error( "Module \"" + module + "\" is a mimimum requirement.");
|
||||
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 {
|
||||
@ -195,8 +205,10 @@ module.exports = function( grunt ) {
|
||||
// * none (implicit exclude)
|
||||
// *:* all (implicit include)
|
||||
// *:*:-css all except css and dependents (explicit > implicit)
|
||||
// *:*:-css:+effects same (excludes effects because explicit include is trumped by explicit exclude of dependency)
|
||||
// *:+effects none except effects and its dependencies (explicit include trumps implicit exclude of dependency)
|
||||
// *:*:-css:+effects same (excludes effects because explicit include is
|
||||
// trumped by explicit exclude of dependency)
|
||||
// *:+effects none except effects and its dependencies
|
||||
// (explicit include trumps implicit exclude of dependency)
|
||||
delete flags[ "*" ];
|
||||
for ( flag in flags ) {
|
||||
excluder( flag );
|
||||
@ -249,7 +261,9 @@ 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(",") : "") + "]);";
|
||||
config.rawText.jquery = "define([" +
|
||||
(included.length ? included.join(",") : "") +
|
||||
"]);";
|
||||
}
|
||||
|
||||
// Trace dependencies and concatenate files
|
||||
|
@ -39,7 +39,7 @@
|
||||
"grunt-contrib-uglify": "0.5.0",
|
||||
"grunt-contrib-watch": "0.6.1",
|
||||
"grunt-git-authors": "1.2.0",
|
||||
"grunt-jscs-checker": "0.4.1",
|
||||
"grunt-jscs-checker": "0.6.1",
|
||||
"grunt-jsonlint": "1.0.4",
|
||||
"grunt-npmcopy": "0.1.0",
|
||||
"gzip-js": "0.3.2",
|
||||
|
19
src/ajax.js
19
src/ajax.js
@ -89,7 +89,9 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
|
||||
inspected[ dataType ] = true;
|
||||
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
|
||||
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
|
||||
if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
||||
if ( typeof dataTypeOrTransport === "string" &&
|
||||
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
|
||||
|
||||
options.dataTypes.unshift( dataTypeOrTransport );
|
||||
inspect( dataTypeOrTransport );
|
||||
return false;
|
||||
@ -262,7 +264,10 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
|
||||
try {
|
||||
response = conv( response );
|
||||
} 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,7 +401,8 @@ jQuery.extend({
|
||||
// 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 ) ?
|
||||
globalEventContext = s.context &&
|
||||
( callbackContext.nodeType || callbackContext.jquery ) ?
|
||||
jQuery( callbackContext ) :
|
||||
jQuery.event,
|
||||
// Deferreds
|
||||
@ -582,7 +588,8 @@ jQuery.extend({
|
||||
jqXHR.setRequestHeader(
|
||||
"Accept",
|
||||
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[ "*" ]
|
||||
);
|
||||
|
||||
@ -592,7 +599,9 @@ jQuery.extend({
|
||||
}
|
||||
|
||||
// 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
|
||||
return jqXHR.abort();
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||
var callbackName, overwritten, responseContainer,
|
||||
jsonProp = s.jsonp !== false && ( rjsonp.test( s.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
|
||||
|
@ -6,7 +6,8 @@ define([
|
||||
// Install script dataType
|
||||
jQuery.ajaxSetup({
|
||||
accepts: {
|
||||
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
||||
script: "text/javascript, application/javascript, " +
|
||||
"application/ecmascript, application/x-ecmascript"
|
||||
},
|
||||
contents: {
|
||||
script: /(?:java|ecma)script/
|
||||
|
@ -45,7 +45,13 @@ jQuery.ajaxTransport(function( options ) {
|
||||
xhr = options.xhr(),
|
||||
id = ++xhrId;
|
||||
|
||||
xhr.open( options.type, options.url, options.async, options.username, options.password );
|
||||
xhr.open(
|
||||
options.type,
|
||||
options.url,
|
||||
options.async,
|
||||
options.username,
|
||||
options.password
|
||||
);
|
||||
|
||||
// Apply custom fields if provided
|
||||
if ( options.xhrFields ) {
|
||||
|
@ -50,7 +50,9 @@ jQuery.extend({
|
||||
if ( value === null ) {
|
||||
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;
|
||||
|
||||
} else {
|
||||
|
@ -2,9 +2,9 @@ define([
|
||||
"../core",
|
||||
"../var/rnotwhite",
|
||||
"../var/strundefined",
|
||||
"../data/var/data_priv",
|
||||
"../data/var/dataPriv",
|
||||
"../core/init"
|
||||
], function( jQuery, rnotwhite, strundefined, data_priv ) {
|
||||
], function( jQuery, rnotwhite, strundefined, dataPriv ) {
|
||||
|
||||
var rclass = /[\t\r\n\f]/g;
|
||||
|
||||
@ -104,7 +104,9 @@ jQuery.fn.extend({
|
||||
|
||||
if ( jQuery.isFunction( value ) ) {
|
||||
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" ) {
|
||||
if ( this.className ) {
|
||||
// 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`,
|
||||
// then remove the whole classname (if there was one, the above saved it).
|
||||
// Otherwise bring back whatever was previously saved (if anything),
|
||||
// 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,
|
||||
l = this.length;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ jQuery.extend({
|
||||
propHooks: {
|
||||
tabIndex: {
|
||||
get: function( elem ) {
|
||||
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
|
||||
return elem.hasAttribute( "tabindex" ) ||
|
||||
rfocusable.test( elem.nodeName ) || elem.href ?
|
||||
elem.tabIndex :
|
||||
-1;
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ jQuery.fn.extend({
|
||||
|
||||
if ( !arguments.length ) {
|
||||
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 ) {
|
||||
return ret;
|
||||
@ -100,8 +101,10 @@ jQuery.extend({
|
||||
// IE6-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 : option.getAttribute( "disabled" ) === null ) &&
|
||||
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
||||
( support.optDisabled ?
|
||||
!option.disabled : option.getAttribute( "disabled" ) === null ) &&
|
||||
( !option.parentNode.disabled ||
|
||||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
|
||||
|
||||
// Get the specific value for the option
|
||||
value = jQuery( option ).val();
|
||||
|
@ -70,7 +70,9 @@ jQuery.Callbacks = function( options ) {
|
||||
firingLength = list.length;
|
||||
firing = true;
|
||||
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
|
||||
break;
|
||||
}
|
||||
|
@ -162,7 +162,9 @@ jQuery.extend = jQuery.fn.extend = function() {
|
||||
}
|
||||
|
||||
// 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 ) {
|
||||
copyIsArray = false;
|
||||
clone = src && jQuery.isArray(src) ? src : [];
|
||||
@ -458,7 +460,8 @@ jQuery.extend({
|
||||
});
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,10 @@ var rootjQuery,
|
||||
|
||||
// Handle HTML strings
|
||||
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
|
||||
match = [ null, selector, null ];
|
||||
|
||||
|
@ -5,7 +5,8 @@ define([
|
||||
], function( jQuery, rsingleTag ) {
|
||||
|
||||
// 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
|
||||
jQuery.parseHTML = function( data, context, keepScripts ) {
|
||||
if ( !data || typeof data !== "string" ) {
|
||||
|
@ -72,8 +72,10 @@ jQuery.ready.promise = function( obj ) {
|
||||
|
||||
readyList = jQuery.Deferred();
|
||||
|
||||
// Catch cases where $(document).ready() is called after the browser event has already occurred.
|
||||
// We once tried to use readyState "interactive" here, but it caused issues like the one
|
||||
// Catch cases where $(document).ready() is called
|
||||
// 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
|
||||
if ( document.readyState === "complete" ) {
|
||||
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
||||
|
38
src/css.js
38
src/css.js
@ -11,17 +11,18 @@ define([
|
||||
"./css/defaultDisplay",
|
||||
"./css/addGetHookIf",
|
||||
"./css/support",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/dataPriv",
|
||||
|
||||
"./core/init",
|
||||
"./css/swap",
|
||||
"./core/ready",
|
||||
"./selector" // contains
|
||||
], function( jQuery, pnum, access, rmargin, rnumnonpx, cssExpand, isHidden,
|
||||
getStyles, curCSS, defaultDisplay, addGetHookIf, support, data_priv ) {
|
||||
getStyles, curCSS, defaultDisplay, addGetHookIf, support, dataPriv ) {
|
||||
|
||||
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
|
||||
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
||||
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
|
||||
@ -161,7 +162,7 @@ function showHide( elements, show ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
values[ index ] = data_priv.get( elem, "olddisplay" );
|
||||
values[ index ] = dataPriv.get( elem, "olddisplay" );
|
||||
display = elem.style.display;
|
||||
if ( show ) {
|
||||
// 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
|
||||
// for such an element
|
||||
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 {
|
||||
hidden = isHidden( elem );
|
||||
|
||||
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 ),
|
||||
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
|
||||
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 ( !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;
|
||||
}
|
||||
|
||||
} 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 ) {
|
||||
if ( hooks && "get" in hooks &&
|
||||
(ret = hooks.get( elem, false, extra )) !== undefined ) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -305,7 +319,8 @@ jQuery.extend({
|
||||
origName = jQuery.camelCase( 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
|
||||
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
|
||||
@ -341,7 +356,8 @@ jQuery.each([ "height", "width" ], function( i, name ) {
|
||||
|
||||
// Certain elements can have dimension info if we invisibly show them
|
||||
// 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" ) ) &&
|
||||
elem.offsetWidth === 0 ?
|
||||
jQuery.swap( elem, cssShow, function() {
|
||||
return getWidthOrHeight( elem, name, extra );
|
||||
}) :
|
||||
|
@ -26,8 +26,10 @@ function curCSS( elem, name, computed ) {
|
||||
|
||||
// Support: iOS < 6
|
||||
// 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
|
||||
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
|
||||
// iOS < 6 (at least) returns percentage for a larger set of 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 ) ) {
|
||||
|
||||
// Remember the original values
|
||||
|
@ -17,11 +17,15 @@ function actualDisplay( name, doc ) {
|
||||
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
|
||||
|
||||
// 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)
|
||||
// until something better comes along,
|
||||
// since it was removed from specification and supported only in FF
|
||||
style.display : jQuery.css( elem[ 0 ], "display" );
|
||||
style.display :
|
||||
|
||||
jQuery.css( elem[ 0 ], "display" );
|
||||
|
||||
// We don't have any data stored on 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 ) {
|
||||
|
||||
// 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
|
||||
doc = iframe[ 0 ].contentDocument;
|
||||
|
@ -8,6 +8,7 @@ define([
|
||||
// isHidden might be called from jQuery#filter function;
|
||||
// in that case, element will be second argument
|
||||
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 );
|
||||
};
|
||||
});
|
||||
|
40
src/data.js
40
src/data.js
@ -2,9 +2,9 @@ define([
|
||||
"./core",
|
||||
"./var/rnotwhite",
|
||||
"./core/access",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/data_user"
|
||||
], function( jQuery, rnotwhite, access, data_priv, data_user ) {
|
||||
"./data/var/dataPriv",
|
||||
"./data/var/dataUser"
|
||||
], function( jQuery, rnotwhite, access, dataPriv, dataUser ) {
|
||||
|
||||
// Implementation Summary
|
||||
//
|
||||
@ -40,7 +40,7 @@ function dataAttr( elem, key, data ) {
|
||||
} catch ( e ) {}
|
||||
|
||||
// Make sure we set the data so it isn't changed later
|
||||
data_user.set( elem, key, data );
|
||||
dataUser.set( elem, key, data );
|
||||
} else {
|
||||
data = undefined;
|
||||
}
|
||||
@ -50,25 +50,25 @@ function dataAttr( elem, key, data ) {
|
||||
|
||||
jQuery.extend({
|
||||
hasData: function( elem ) {
|
||||
return data_user.hasData( elem ) || data_priv.hasData( elem );
|
||||
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
|
||||
},
|
||||
|
||||
data: function( elem, name, data ) {
|
||||
return data_user.access( elem, name, data );
|
||||
return dataUser.access( elem, name, data );
|
||||
},
|
||||
|
||||
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
|
||||
// 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 ) {
|
||||
return data_priv.access( elem, name, data );
|
||||
return dataPriv.access( elem, name, data );
|
||||
},
|
||||
|
||||
_removeData: function( elem, name ) {
|
||||
data_priv.remove( elem, name );
|
||||
dataPriv.remove( elem, name );
|
||||
}
|
||||
});
|
||||
|
||||
@ -81,9 +81,9 @@ jQuery.fn.extend({
|
||||
// Gets all values
|
||||
if ( key === undefined ) {
|
||||
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;
|
||||
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
|
||||
if ( typeof key === "object" ) {
|
||||
return this.each(function() {
|
||||
data_user.set( this, key );
|
||||
dataUser.set( this, key );
|
||||
});
|
||||
}
|
||||
|
||||
@ -123,14 +123,14 @@ jQuery.fn.extend({
|
||||
if ( elem && value === undefined ) {
|
||||
// Attempt to get data from the cache
|
||||
// with the key as-is
|
||||
data = data_user.get( elem, key );
|
||||
data = dataUser.get( elem, key );
|
||||
if ( data !== undefined ) {
|
||||
return data;
|
||||
}
|
||||
|
||||
// Attempt to get data from the cache
|
||||
// with the key camelized
|
||||
data = data_user.get( elem, camelKey );
|
||||
data = dataUser.get( elem, camelKey );
|
||||
if ( data !== undefined ) {
|
||||
return data;
|
||||
}
|
||||
@ -150,18 +150,18 @@ jQuery.fn.extend({
|
||||
this.each(function() {
|
||||
// First, attempt to store a copy or reference of any
|
||||
// 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
|
||||
// store property names with dashes in a camelCase form.
|
||||
// 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_
|
||||
// have dashes, we need to also store a copy of that
|
||||
// unchanged property.
|
||||
if ( key.indexOf("-") !== -1 && data !== undefined ) {
|
||||
data_user.set( this, key, value );
|
||||
dataUser.set( this, key, value );
|
||||
}
|
||||
});
|
||||
}, null, value, arguments.length > 1, null, true );
|
||||
@ -169,7 +169,7 @@ jQuery.fn.extend({
|
||||
|
||||
removeData: function( key ) {
|
||||
return this.each(function() {
|
||||
data_user.remove( this, key );
|
||||
dataUser.remove( this, key );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -36,7 +36,10 @@ jQuery.extend({
|
||||
.fail( newDefer.reject )
|
||||
.progress( newDefer.notify );
|
||||
} 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,
|
||||
|
||||
// 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(),
|
||||
|
||||
// Update function for both resolve and progress values
|
||||
|
@ -6,7 +6,9 @@ define([
|
||||
|
||||
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
|
||||
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
|
||||
jQuery.fn[ funcName ] = function( margin, value ) {
|
||||
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/isHidden",
|
||||
"./css/defaultDisplay",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/dataPriv",
|
||||
|
||||
"./core/init",
|
||||
"./effects/Tween",
|
||||
@ -12,7 +12,7 @@ define([
|
||||
"./css",
|
||||
"./deferred",
|
||||
"./traversing"
|
||||
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) {
|
||||
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, dataPriv ) {
|
||||
|
||||
var
|
||||
fxNow, timerId,
|
||||
@ -54,7 +54,9 @@ var
|
||||
|
||||
// Update scale, tolerating zero or NaN from tween.cur(),
|
||||
// break the loop if scale is unchanged or perfect, or if we've just had enough
|
||||
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
|
||||
} while (
|
||||
scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations
|
||||
);
|
||||
}
|
||||
|
||||
// Update tween properties
|
||||
@ -128,7 +130,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
orig = {},
|
||||
style = elem.style,
|
||||
hidden = elem.nodeType && isHidden( elem ),
|
||||
dataShow = data_priv.get( elem, "fxshow" );
|
||||
dataShow = dataPriv.get( elem, "fxshow" );
|
||||
|
||||
// Handle queue: false promises
|
||||
if ( !opts.queue ) {
|
||||
@ -169,7 +171,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
|
||||
// Test default display if display is currently "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" ) {
|
||||
style.display = "inline-block";
|
||||
@ -193,7 +195,8 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
toggle = toggle || value === "toggle";
|
||||
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 ) {
|
||||
hidden = true;
|
||||
} else {
|
||||
@ -214,7 +217,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
hidden = dataShow.hidden;
|
||||
}
|
||||
} else {
|
||||
dataShow = data_priv.access( elem, "fxshow", {} );
|
||||
dataShow = dataPriv.access( elem, "fxshow", {} );
|
||||
}
|
||||
|
||||
// Store state if its toggle - enables .stop().toggle() to "reverse"
|
||||
@ -231,7 +234,7 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
anim.done(function() {
|
||||
var prop;
|
||||
|
||||
data_priv.remove( elem, "fxshow" );
|
||||
dataPriv.remove( elem, "fxshow" );
|
||||
for ( prop in orig ) {
|
||||
jQuery.style( elem, prop, orig[ prop ] );
|
||||
}
|
||||
@ -481,7 +484,7 @@ jQuery.fn.extend({
|
||||
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
|
||||
|
||||
// Empty animations, or finishing resolves immediately
|
||||
if ( empty || data_priv.get( this, "finish" ) ) {
|
||||
if ( empty || dataPriv.get( this, "finish" ) ) {
|
||||
anim.stop( true );
|
||||
}
|
||||
};
|
||||
@ -511,7 +514,7 @@ jQuery.fn.extend({
|
||||
var dequeue = true,
|
||||
index = type != null && type + "queueHooks",
|
||||
timers = jQuery.timers,
|
||||
data = data_priv.get( this );
|
||||
data = dataPriv.get( this );
|
||||
|
||||
if ( index ) {
|
||||
if ( data[ index ] && data[ index ].stop ) {
|
||||
@ -526,7 +529,9 @@ jQuery.fn.extend({
|
||||
}
|
||||
|
||||
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 );
|
||||
dequeue = false;
|
||||
timers.splice( index, 1 );
|
||||
@ -547,7 +552,7 @@ jQuery.fn.extend({
|
||||
}
|
||||
return this.each(function() {
|
||||
var index,
|
||||
data = data_priv.get( this ),
|
||||
data = dataPriv.get( this ),
|
||||
queue = data[ type + "queue" ],
|
||||
hooks = data[ type + "queueHooks" ],
|
||||
timers = jQuery.timers,
|
||||
|
@ -78,7 +78,9 @@ Tween.propHooks = {
|
||||
// Use .style if available and use plain properties where available.
|
||||
if ( jQuery.fx.step[ tween.prop ] ) {
|
||||
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 );
|
||||
} else {
|
||||
tween.elem[ tween.prop ] = tween.now;
|
||||
|
65
src/event.js
65
src/event.js
@ -5,12 +5,12 @@ define([
|
||||
"./var/hasOwn",
|
||||
"./var/slice",
|
||||
"./event/support",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/dataPriv",
|
||||
|
||||
"./core/init",
|
||||
"./data/accepts",
|
||||
"./selector"
|
||||
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) {
|
||||
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, dataPriv ) {
|
||||
|
||||
var
|
||||
rkeyEvent = /^key/,
|
||||
@ -45,7 +45,7 @@ jQuery.event = {
|
||||
var handleObjIn, eventHandle, tmp,
|
||||
events, t, handleObj,
|
||||
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)
|
||||
if ( !elemData ) {
|
||||
@ -117,7 +117,9 @@ jQuery.event = {
|
||||
handlers.delegateCount = 0;
|
||||
|
||||
// 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 ) {
|
||||
elem.addEventListener( type, eventHandle, false );
|
||||
}
|
||||
@ -151,7 +153,7 @@ jQuery.event = {
|
||||
var j, origCount, tmp,
|
||||
events, t, handleObj,
|
||||
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) ) {
|
||||
return;
|
||||
@ -186,7 +188,8 @@ jQuery.event = {
|
||||
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
||||
( !handler || handler.guid === handleObj.guid ) &&
|
||||
( !tmp || tmp.test( handleObj.namespace ) ) &&
|
||||
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
||||
( !selector || selector === handleObj.selector ||
|
||||
selector === "**" && handleObj.selector ) ) {
|
||||
handlers.splice( j, 1 );
|
||||
|
||||
if ( handleObj.selector ) {
|
||||
@ -201,7 +204,9 @@ jQuery.event = {
|
||||
// Remove generic event handler if we removed something and no more handlers exist
|
||||
// (avoids potential for endless recursion during removal of special event handlers)
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -212,7 +217,7 @@ jQuery.event = {
|
||||
// Remove the expando if it's no longer used
|
||||
if ( jQuery.isEmptyObject( events ) ) {
|
||||
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)
|
||||
event.isTrigger = onlyHandlers ? 2 : 3;
|
||||
event.namespace = namespaces.join(".");
|
||||
event.namespace_re = event.namespace ?
|
||||
event.rnamespace = event.namespace ?
|
||||
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
|
||||
null;
|
||||
|
||||
@ -300,7 +305,8 @@ jQuery.event = {
|
||||
special.bindType || type;
|
||||
|
||||
// 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 ) {
|
||||
handle.apply( cur, data );
|
||||
}
|
||||
@ -356,7 +362,7 @@ jQuery.event = {
|
||||
var i, j, ret, matched, handleObj,
|
||||
handlerQueue = [],
|
||||
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 ] || {};
|
||||
|
||||
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
||||
@ -377,17 +383,18 @@ jQuery.event = {
|
||||
event.currentTarget = matched.elem;
|
||||
|
||||
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)
|
||||
// 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.data = handleObj.data;
|
||||
|
||||
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
||||
.apply( matched.elem, args );
|
||||
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle ||
|
||||
handleObj.handler ).apply( matched.elem, args );
|
||||
|
||||
if ( ret !== undefined ) {
|
||||
if ( (event.result = ret) === false ) {
|
||||
@ -454,7 +461,8 @@ jQuery.event = {
|
||||
},
|
||||
|
||||
// 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: {},
|
||||
|
||||
@ -472,7 +480,8 @@ jQuery.event = {
|
||||
},
|
||||
|
||||
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 ) {
|
||||
var eventDoc, doc, body,
|
||||
button = original.button;
|
||||
@ -483,8 +492,12 @@ jQuery.event = {
|
||||
doc = eventDoc.documentElement;
|
||||
body = eventDoc.body;
|
||||
|
||||
event.pageX = original.clientX + ( 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 );
|
||||
event.pageX = original.clientX +
|
||||
( 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
|
||||
@ -738,23 +751,23 @@ if ( !support.focusinBubbles ) {
|
||||
jQuery.event.special[ fix ] = {
|
||||
setup: function() {
|
||||
var doc = this.ownerDocument || this,
|
||||
attaches = data_priv.access( doc, fix );
|
||||
attaches = dataPriv.access( doc, fix );
|
||||
|
||||
if ( !attaches ) {
|
||||
doc.addEventListener( orig, handler, true );
|
||||
}
|
||||
data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
|
||||
dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
|
||||
},
|
||||
teardown: function() {
|
||||
var doc = this.ownerDocument || this,
|
||||
attaches = data_priv.access( doc, fix ) - 1;
|
||||
attaches = dataPriv.access( doc, fix ) - 1;
|
||||
|
||||
if ( !attaches ) {
|
||||
doc.removeEventListener( orig, handler, true );
|
||||
data_priv.remove( doc, fix );
|
||||
dataPriv.remove( doc, fix );
|
||||
|
||||
} else {
|
||||
data_priv.access( doc, fix, attaches );
|
||||
dataPriv.access( doc, fix, attaches );
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -825,7 +838,9 @@ jQuery.fn.extend({
|
||||
// ( event ) dispatched jQuery.Event
|
||||
handleObj = types.handleObj;
|
||||
jQuery( types.delegateTarget ).off(
|
||||
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
|
||||
handleObj.namespace ?
|
||||
handleObj.origType + "." + handleObj.namespace :
|
||||
handleObj.origType,
|
||||
handleObj.selector,
|
||||
handleObj.handler
|
||||
);
|
||||
|
@ -4,7 +4,14 @@ define([
|
||||
], function( jQuery ) {
|
||||
|
||||
// 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 ) {
|
||||
return this.on( type, fn );
|
||||
};
|
||||
|
@ -5,7 +5,8 @@ define([
|
||||
|
||||
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
||||
"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
|
||||
jQuery.fn[ name ] = function( data, fn ) {
|
||||
@ -32,7 +33,9 @@ jQuery.fn.extend({
|
||||
},
|
||||
undelegate: function( 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",
|
||||
"./manipulation/var/rcheckableType",
|
||||
"./manipulation/support",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/data_user",
|
||||
"./data/var/dataPriv",
|
||||
"./data/var/dataUser",
|
||||
|
||||
"./core/init",
|
||||
"./data/accepts",
|
||||
"./traversing",
|
||||
"./selector",
|
||||
"./event"
|
||||
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) {
|
||||
], function( jQuery, concat, push, access, rcheckableType, support, dataPriv, dataUser ) {
|
||||
|
||||
var
|
||||
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
||||
@ -80,8 +80,8 @@ function setGlobalEval( elems, refElements ) {
|
||||
l = elems.length;
|
||||
|
||||
for ( ; i < l; i++ ) {
|
||||
data_priv.set(
|
||||
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
|
||||
dataPriv.set(
|
||||
elems[ i ], "globalEval", !refElements || dataPriv.get( refElements[ i ], "globalEval" )
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -94,9 +94,9 @@ function cloneCopyEvent( src, dest ) {
|
||||
}
|
||||
|
||||
// 1. Copy private data: events, handlers, etc.
|
||||
if ( data_priv.hasData( src ) ) {
|
||||
pdataOld = data_priv.access( src );
|
||||
pdataCur = data_priv.set( dest, pdataOld );
|
||||
if ( dataPriv.hasData( src ) ) {
|
||||
pdataOld = dataPriv.access( src );
|
||||
pdataCur = dataPriv.set( dest, pdataOld );
|
||||
events = pdataOld.events;
|
||||
|
||||
if ( events ) {
|
||||
@ -112,11 +112,11 @@ function cloneCopyEvent( src, dest ) {
|
||||
}
|
||||
|
||||
// 2. Copy user data
|
||||
if ( data_user.hasData( src ) ) {
|
||||
udataOld = data_user.access( src );
|
||||
if ( dataUser.hasData( src ) ) {
|
||||
udataOld = dataUser.access( src );
|
||||
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++ ) {
|
||||
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 ) {
|
||||
for ( type in data.events ) {
|
||||
if ( special[ type ] ) {
|
||||
@ -294,14 +294,14 @@ jQuery.extend({
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( data_priv.cache[ key ] ) {
|
||||
if ( dataPriv.cache[ key ] ) {
|
||||
// Discard any remaining `private` data
|
||||
delete data_priv.cache[ key ];
|
||||
delete dataPriv.cache[ key ];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Discard any remaining `user` data
|
||||
delete data_user.cache[ elem[ data_user.expando ] ];
|
||||
delete dataUser.cache[ elem[ dataUser.expando ] ];
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -500,7 +500,8 @@ jQuery.fn.extend({
|
||||
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
||||
hasScripts = scripts.length;
|
||||
|
||||
// Use the original fragment for the last item instead of the first because it can end up
|
||||
// Use the original fragment for the last item
|
||||
// instead of the first because it can end up
|
||||
// being emptied incorrectly in certain situations (#8070).
|
||||
for ( ; i < l; i++ ) {
|
||||
node = fragment;
|
||||
@ -529,7 +530,8 @@ jQuery.fn.extend({
|
||||
for ( i = 0; i < hasScripts; i++ ) {
|
||||
node = scripts[ i ];
|
||||
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 ) {
|
||||
// Optional AJAX dependency, but won't run scripts if not present
|
||||
|
@ -118,7 +118,8 @@ jQuery.fn.extend({
|
||||
elem = this[ 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" ) {
|
||||
// Assume getBoundingClientRect is there when computed position is fixed
|
||||
offset = elem.getBoundingClientRect();
|
||||
@ -149,7 +150,8 @@ jQuery.fn.extend({
|
||||
return this.map(function() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
14
src/queue.js
14
src/queue.js
@ -1,9 +1,9 @@
|
||||
define([
|
||||
"./core",
|
||||
"./data/var/data_priv",
|
||||
"./data/var/dataPriv",
|
||||
"./deferred",
|
||||
"./callbacks"
|
||||
], function( jQuery, data_priv ) {
|
||||
], function( jQuery, dataPriv ) {
|
||||
|
||||
jQuery.extend({
|
||||
queue: function( elem, type, data ) {
|
||||
@ -11,12 +11,12 @@ jQuery.extend({
|
||||
|
||||
if ( elem ) {
|
||||
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
|
||||
if ( data ) {
|
||||
if ( !queue || jQuery.isArray( data ) ) {
|
||||
queue = data_priv.access( elem, type, jQuery.makeArray(data) );
|
||||
queue = dataPriv.access( elem, type, jQuery.makeArray(data) );
|
||||
} else {
|
||||
queue.push( data );
|
||||
}
|
||||
@ -63,9 +63,9 @@ jQuery.extend({
|
||||
// Not public - generate a queueHooks object, or return the current one
|
||||
_queueHooks: function( elem, type ) {
|
||||
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() {
|
||||
data_priv.remove( elem, [ type + "queue", key ] );
|
||||
dataPriv.remove( elem, [ type + "queue", key ] );
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -127,7 +127,7 @@ jQuery.fn.extend({
|
||||
type = type || "fx";
|
||||
|
||||
while ( i-- ) {
|
||||
tmp = data_priv.get( elements[ i ], type + "queueHooks" );
|
||||
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
|
||||
if ( tmp && tmp.empty ) {
|
||||
count++;
|
||||
tmp.empty.add( resolve );
|
||||
|
@ -27,21 +27,23 @@ define([
|
||||
* customize this stub for the project's specific needs.
|
||||
*/
|
||||
|
||||
var docElem = window.document.documentElement,
|
||||
selector_hasDuplicate,
|
||||
var hasDuplicate,
|
||||
docElem = window.document.documentElement,
|
||||
matches = docElem.matches ||
|
||||
docElem.webkitMatchesSelector ||
|
||||
docElem.mozMatchesSelector ||
|
||||
docElem.oMatchesSelector ||
|
||||
docElem.msMatchesSelector,
|
||||
selector_sortOrder = function( a, b ) {
|
||||
sortOrder = function( a, b ) {
|
||||
// Flag for duplicate removal
|
||||
if ( a === b ) {
|
||||
selector_hasDuplicate = true;
|
||||
hasDuplicate = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
|
||||
var compare = b.compareDocumentPosition &&
|
||||
a.compareDocumentPosition &&
|
||||
a.compareDocumentPosition( b );
|
||||
|
||||
if ( compare ) {
|
||||
// Disconnected nodes
|
||||
@ -102,10 +104,10 @@ jQuery.extend({
|
||||
i = 0,
|
||||
j = 0;
|
||||
|
||||
selector_hasDuplicate = false;
|
||||
results.sort( selector_sortOrder );
|
||||
hasDuplicate = false;
|
||||
results.sort( sortOrder );
|
||||
|
||||
if ( selector_hasDuplicate ) {
|
||||
if ( hasDuplicate ) {
|
||||
while ( (elem = results[i++]) ) {
|
||||
if ( elem === results[ i ] ) {
|
||||
j = duplicates.push( i );
|
||||
|
@ -24,7 +24,12 @@ function buildParams( prefix, obj, traditional, add ) {
|
||||
|
||||
} else {
|
||||
// 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() {
|
||||
var src = url( "./data/" + fileName + ".html" ),
|
||||
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;
|
||||
return iframe;
|
||||
@ -304,7 +305,8 @@ this.loadTests = function() {
|
||||
|
||||
// Load the TestSwarm listener if swarmURL is in the address.
|
||||
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();
|
||||
});
|
||||
} else {
|
||||
|
@ -25,12 +25,13 @@ QUnit.config.requireExpects = true;
|
||||
* @param {string} 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
|
||||
// stored and managed completely below the API surface
|
||||
if ( jQuery.cache ) {
|
||||
QUnit.current_testEnvironment.checkJqData = true;
|
||||
QUnit[ currentEnv ].checkJqData = true;
|
||||
|
||||
if ( elems.jquery && elems.toArray ) {
|
||||
elems = elems.toArray();
|
||||
@ -62,7 +63,12 @@ QUnit.expectJqData = function( elems, key ) {
|
||||
// Since this method was called it means some data was
|
||||
// expected to be found, but since there is nothing, fail early
|
||||
// (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 {
|
||||
if ( expectedDataKeys[ expando ] ) {
|
||||
expectedDataKeys[ expando ].push( key );
|
||||
@ -77,7 +83,8 @@ QUnit.expectJqData = function( elems, key ) {
|
||||
QUnit.config.urlConfig.push({
|
||||
id: "jqdata",
|
||||
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)
|
||||
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 ];
|
||||
}
|
||||
}
|
||||
@ -130,8 +141,10 @@ window.moduleTeardown = function() {
|
||||
++cacheLength;
|
||||
}
|
||||
|
||||
// Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test,
|
||||
// if we unconditionally assert any of these, the test will fail with too many assertions :|
|
||||
// Because QUnit doesn't have a mechanism for retrieving
|
||||
// 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 ) {
|
||||
equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
|
||||
oldCacheLength = cacheLength;
|
||||
|
Loading…
Reference in New Issue
Block a user