From 91e06e9aebecf67a5c4997408bf0a28fffd03f9d Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Thu, 17 Jul 2014 10:25:59 -0700 Subject: [PATCH] Build: update grunt-jscs-checker and pass with the new rules Conflicts: build/tasks/build.js src/ajax/xhr.js src/attributes/classes.js src/attributes/prop.js src/attributes/val.js src/core/init.js src/core/ready.js src/css.js src/css/curCSS.js src/css/defaultDisplay.js src/data.js src/data/var/dataPriv.js src/data/var/dataUser.js src/dimensions.js src/effects.js src/event.js src/manipulation.js src/offset.js src/queue.js src/selector-native.js test/data/testrunner.js --- Gruntfile.js | 32 +++++++++++---- build/release-notes.js | 3 +- build/release.js | 4 +- build/tasks/build.js | 32 ++++++++++----- package.json | 2 +- src/ajax.js | 29 +++++++++----- src/ajax/jsonp.js | 4 +- src/ajax/parseXML.js | 2 +- src/ajax/script.js | 3 +- src/ajax/xhr.js | 14 +++++-- src/attributes/attr.js | 4 +- src/attributes/classes.js | 12 ++++-- src/attributes/prop.js | 19 +++++---- src/attributes/support.js | 3 +- src/attributes/val.js | 10 +++-- src/callbacks.js | 4 +- src/core.js | 7 +++- src/core/init.js | 5 ++- src/core/parseHTML.js | 3 +- src/core/ready.js | 18 ++++++--- src/css.js | 64 +++++++++++++++++++----------- src/css/curCSS.js | 15 ++++--- src/css/defaultDisplay.js | 9 +++-- src/css/var/isHidden.js | 3 +- src/data.js | 6 +-- src/data/support.js | 2 +- src/deferred.js | 11 ++++-- src/dimensions.js | 9 +++-- src/effects.js | 17 +++++--- src/effects/Tween.js | 4 +- src/event.js | 78 ++++++++++++++++++++++++------------- src/event/ajax.js | 9 ++++- src/event/alias.js | 7 +++- src/manipulation.js | 42 ++++++++++++++------ src/manipulation/support.js | 2 +- src/offset.js | 9 +++-- src/queue.js | 3 +- src/serialize.js | 7 +++- src/traversing.js | 4 +- test/data/testinit.js | 6 ++- test/data/testrunner.js | 30 ++++++++++---- 41 files changed, 379 insertions(+), 168 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 2461ba44f..7da352e40 100644 --- a/Gruntfile.js +++ b/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: { @@ -92,13 +92,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 %>" ], @@ -115,13 +133,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 } diff --git a/build/release-notes.js b/build/release-notes.js index c9676f28f..00cdc8659 100644 --- a/build/release-notes.js +++ b/build/release-notes.js @@ -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 = []; diff --git a/build/release.js b/build/release.js index 8a2b98e58..2aa785eca 100644 --- a/build/release.js +++ b/build/release.js @@ -88,7 +88,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; diff --git a/build/tasks/build.js b/build/tasks/build.js index 02c6597e3..738f934b4 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -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 ), @@ -162,7 +170,7 @@ module.exports = function( grunt ) { // It's fine if the directory is not there try { excludeList( fs.readdirSync( srcFolder + module ), module ); - } catch( e ) { + } catch ( e ) { grunt.verbose.writeln( e ); } } @@ -192,8 +200,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 ); @@ -239,7 +249,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 diff --git a/package.json b/package.json index b26751fbd..b35e91ad7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/ajax.js b/src/ajax.js index caffe883d..7a0ac1f07 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -49,7 +49,7 @@ var // a field from window.location if document.domain has been set try { ajaxLocation = location.href; -} catch( e ) { +} catch ( e ) { // Use the href attribute of an A element // since IE will modify it given document.location ajaxLocation = document.createElement( "a" ); @@ -103,7 +103,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; @@ -275,7 +277,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 + }; } } } @@ -412,9 +417,10 @@ 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 ) ? - jQuery( callbackContext ) : - jQuery.event, + globalEventContext = s.context && + ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, // Deferreds deferred = jQuery.Deferred(), completeDeferred = jQuery.Callbacks("once memory"), @@ -506,7 +512,9 @@ jQuery.extend({ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) // Handle falsy url in the settings object (#10093: consistency with old signature) // We also use the url parameter if available - s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); + s.url = ( ( url || s.url || ajaxLocation ) + "" ) + .replace( rhash, "" ) + .replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); // Alias method option to type as per ticket #12004 s.type = options.method || options.type || s.method || s.type; @@ -597,7 +605,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[ "*" ] ); @@ -607,7 +616,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(); } diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js index ff0d53899..d7ca7e1a7 100644 --- a/src/ajax/jsonp.js +++ b/src/ajax/jsonp.js @@ -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 diff --git a/src/ajax/parseXML.js b/src/ajax/parseXML.js index 0b92c7a42..9fbd9da9a 100644 --- a/src/ajax/parseXML.js +++ b/src/ajax/parseXML.js @@ -17,7 +17,7 @@ jQuery.parseXML = function( data ) { xml.async = "false"; xml.loadXML( data ); } - } catch( e ) { + } catch ( e ) { xml = undefined; } if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { diff --git a/src/ajax/script.js b/src/ajax/script.js index f6598aaf3..416a45ddb 100644 --- a/src/ajax/script.js +++ b/src/ajax/script.js @@ -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/ diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index 0f560f45a..31999d44e 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -60,7 +60,13 @@ if ( xhrSupported ) { id = ++xhrId; // Open the socket - 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 ) { @@ -132,7 +138,7 @@ if ( xhrSupported ) { // statusText for faulty cross-domain requests try { statusText = xhr.statusText; - } catch( e ) { + } catch ( e ) { // We normalize with Webkit giving an empty statusText statusText = ""; } @@ -184,13 +190,13 @@ if ( xhrSupported ) { function createStandardXHR() { try { return new window.XMLHttpRequest(); - } catch( e ) {} + } catch ( e ) {} } function createActiveXHR() { try { return new window.ActiveXObject( "Microsoft.XMLHTTP" ); - } catch( e ) {} + } catch ( e ) {} } }); diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 47639c97e..6152680c0 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -54,7 +54,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 { diff --git a/src/attributes/classes.js b/src/attributes/classes.js index 64bc747c5..a7b423035 100644 --- a/src/attributes/classes.js +++ b/src/attributes/classes.js @@ -103,7 +103,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 + ); }); } @@ -135,7 +137,9 @@ jQuery.fn.extend({ // 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 ? "" : jQuery._data( this, "__className__" ) || ""; + this.className = this.className || value === false ? + "" : + jQuery._data( this, "__className__" ) || ""; } }); }, @@ -145,7 +149,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; } } diff --git a/src/attributes/prop.js b/src/attributes/prop.js index 817a1b621..92fa8c3b3 100644 --- a/src/attributes/prop.js +++ b/src/attributes/prop.js @@ -19,7 +19,7 @@ jQuery.fn.extend({ try { this[ name ] = undefined; delete this[ name ]; - } catch( e ) {} + } catch ( e ) {} }); } }); @@ -48,9 +48,10 @@ jQuery.extend({ } if ( value !== undefined ) { - return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? - ret : - ( elem[ name ] = value ); + return hooks && "set" in hooks && + (ret = hooks.set( elem, value, name )) !== undefined ? + ret : + ( elem[ name ] = value ); } else { return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? @@ -62,16 +63,18 @@ jQuery.extend({ propHooks: { tabIndex: { get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // elem.tabIndex doesn't always return the + // correct value when it hasn't been explicitly set // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ // Use proper attribute retrieval(#12072) var tabindex = jQuery.find.attr( elem, "tabindex" ); return tabindex ? parseInt( tabindex, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - -1; + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && elem.href ? + 0 : + -1; } } } diff --git a/src/attributes/support.js b/src/attributes/support.js index 3f85d8aaa..665e836f6 100644 --- a/src/attributes/support.js +++ b/src/attributes/support.js @@ -19,7 +19,8 @@ define([ a.style.cssText = "top:1px"; - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + // Test setAttribute on camelCase class. + // If it works, we need attrFixes when doing get/setAttribute (ie6/7) support.getSetAttribute = div.className !== "t"; // Get the style information from getAttribute diff --git a/src/attributes/val.js b/src/attributes/val.js index 4a3b0e5c1..c51a1a3b8 100644 --- a/src/attributes/val.js +++ b/src/attributes/val.js @@ -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; @@ -98,8 +99,11 @@ jQuery.extend({ // oldIE 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(); diff --git a/src/callbacks.js b/src/callbacks.js index 9d12823d9..51e3a3ab9 100644 --- a/src/callbacks.js +++ b/src/callbacks.js @@ -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; } diff --git a/src/core.js b/src/core.js index 9dacc48a8..27162f84a 100644 --- a/src/core.js +++ b/src/core.js @@ -159,7 +159,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 : []; @@ -512,7 +514,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(); }); diff --git a/src/core/init.js b/src/core/init.js index f2db547a9..340e378b8 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -26,7 +26,10 @@ var rootjQuery, // Handle HTML strings if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + if ( selector.charAt(0) === "<" && + selector.charAt( 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 ]; diff --git a/src/core/parseHTML.js b/src/core/parseHTML.js index 64cf2a18a..808d60e3d 100644 --- a/src/core/parseHTML.js +++ b/src/core/parseHTML.js @@ -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" ) { diff --git a/src/core/ready.js b/src/core/ready.js index 392c4849f..095e6daeb 100644 --- a/src/core/ready.js +++ b/src/core/ready.js @@ -82,7 +82,10 @@ function detach() { */ function completed() { // readyState === "complete" is good enough for us to call the dom ready in oldIE - if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { + if ( document.addEventListener || + event.type === "load" || + document.readyState === "complete" ) { + detach(); jQuery.ready(); } @@ -93,9 +96,12 @@ 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 - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + // 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 setTimeout( jQuery.ready ); @@ -122,7 +128,7 @@ jQuery.ready.promise = function( obj ) { try { top = window.frameElement == null && document.documentElement; - } catch(e) {} + } catch ( e ) {} if ( top && top.doScroll ) { (function doScrollCheck() { @@ -132,7 +138,7 @@ jQuery.ready.promise = function( obj ) { // Use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ top.doScroll("left"); - } catch(e) { + } catch ( e ) { return setTimeout( doScrollCheck, 50 ); } diff --git a/src/css.js b/src/css.js index 2c88f2bc3..bd858a203 100644 --- a/src/css.js +++ b/src/css.js @@ -24,8 +24,10 @@ var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity\s*=\s*([^)]*)/, - // 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 + // 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" ), rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), @@ -95,7 +97,11 @@ function showHide( elements, show ) { hidden = isHidden( elem ); if ( display && display !== "none" || !hidden ) { - jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); + jQuery._data( + elem, + "olddisplay", + hidden ? display : jQuery.css( elem, "display" ) + ); } } } @@ -168,7 +174,8 @@ function getWidthOrHeight( elem, name, extra ) { var valueIsBorderBox = true, val = name === "width" ? elem.offsetWidth : elem.offsetHeight, styles = getStyles( elem ), - isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + isBorderBox = support.boxSizing && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; // some non-html elements return undefined for offsetWidth, so check for null/undefined // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 @@ -187,7 +194,8 @@ function getWidthOrHeight( elem, name, extra ) { // we need the check for style in case a browser which returns unreliable values // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] ); + valueIsBorderBox = isBorderBox && + ( support.boxSizingReliable() || val === elem.style[ name ] ); // Normalize "", auto, and prepare for extra val = parseFloat( val ) || 0; @@ -255,7 +263,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 // followed by the unprefixed version @@ -283,24 +292,28 @@ jQuery.extend({ } // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, - // but it would mean to define eight (for every problematic property) identical functions + // but it would mean to define eight + // (for every problematic property) identical functions if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { style[ name ] = "inherit"; } // 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 ) { // Support: IE // Swallow errors from 'invalid' CSS values (#5509) try { style[ name ] = value; - } catch(e) {} + } catch (e) {} } } 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; } @@ -314,7 +327,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 ) ); // gets hook for the prefixed version // followed by the unprefixed version @@ -350,11 +364,12 @@ jQuery.each([ "height", "width" ], function( i, name ) { if ( computed ) { // certain elements can have dimension info if we invisibly show them // however, it must have a current display style that would benefit from this - return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ? - jQuery.swap( elem, cssShow, function() { - return getWidthOrHeight( elem, name, extra ); - }) : - getWidthOrHeight( elem, name, extra ); + return rdisplayswap.test( jQuery.css( elem, "display" ) ) && + elem.offsetWidth === 0 ? + jQuery.swap( elem, cssShow, function() { + return getWidthOrHeight( elem, name, extra ); + }) : + getWidthOrHeight( elem, name, extra ); } }, @@ -365,7 +380,8 @@ jQuery.each([ "height", "width" ], function( i, name ) { elem, name, extra, - support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + support.boxSizing && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", styles ) : 0 ); @@ -377,9 +393,11 @@ if ( !support.opacity ) { jQuery.cssHooks.opacity = { get: function( elem, computed ) { // IE uses filters for opacity - return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? - ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : - computed ? "1" : ""; + return ropacity.test( (computed && elem.currentStyle ? + elem.currentStyle.filter : + elem.style.filter) || "" ) ? + ( 0.01 * parseFloat( RegExp.$1 ) ) + "" : + computed ? "1" : ""; }, set: function( elem, value ) { @@ -392,7 +410,8 @@ if ( !support.opacity ) { // Force it by setting the zoom level style.zoom = 1; - // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 + // if setting opacity to 1, and no other filters exist - + // attempt to remove filter attribute #6652 // if value === "", then remove inline opacity #12685 if ( ( value >= 1 || value === "" ) && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && @@ -403,7 +422,8 @@ if ( !support.opacity ) { // style.removeAttribute is IE Only, but so apparently is this code path... style.removeAttribute( "filter" ); - // if there is no filter style applied in a css rule or unset inline opacity, we are done + // if there is no filter style applied in a css rule + // or unset inline opacity, we are done if ( value === "" || currentStyle && !currentStyle.filter ) { return; } diff --git a/src/css/curCSS.js b/src/css/curCSS.js index 9ab4f1126..66602cc80 100644 --- a/src/css/curCSS.js +++ b/src/css/curCSS.js @@ -37,9 +37,12 @@ if ( window.getComputedStyle ) { } // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right - // Safari 5.1.7 (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 + // Chrome < 17 and Safari 5.0 uses "computed value" + // instead of "used value" for margin-right + // Safari 5.1.7 (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 @@ -87,8 +90,10 @@ if ( window.getComputedStyle ) { // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels - // but not position css attributes, as those are proportional to the parent element instead - // and we can't measure the parent instead because it might trigger a "stacking dolls" problem + // but not position css attributes, as those are + // proportional to the parent element instead + // and we can't measure the parent instead because it + // might trigger a "stacking dolls" problem if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { // Remember the original values diff --git a/src/css/defaultDisplay.js b/src/css/defaultDisplay.js index 210ad4a80..adf3f3748 100644 --- a/src/css/defaultDisplay.js +++ b/src/css/defaultDisplay.js @@ -17,9 +17,11 @@ 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 optmization) until something better comes along, + // Use of this method is a temporary fix (more like optmization) + // until something better comes along, // since it was removed from specification and supported only in FF style.display : jQuery.css( elem[ 0 ], "display" ); @@ -45,7 +47,8 @@ function defaultDisplay( nodeName ) { if ( display === "none" || !display ) { // Use the already-created iframe if possible - iframe = (iframe || jQuery( "