From: Oleg Gaidarenko Date: Fri, 13 Nov 2015 13:02:32 +0000 (+0300) Subject: Release: remove revert artefacts X-Git-Tag: 2.2.0~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c69673fe41ee17f46545e87a31ff96cea6c68a17;p=jquery.git Release: remove revert artefacts --- diff --git a/src/data.js b/src/data.js index 17e9c64f1..f7734e7f3 100644 --- a/src/data.js +++ b/src/data.js @@ -120,6 +120,7 @@ jQuery.fn.extend( { // will result in `undefined` for elem = this[ 0 ] which will // throw an exception if an attempt to read a data cache is made. if ( elem && value === undefined ) { + // Attempt to get data from the cache // with the key as-is data = dataUser.get( elem, key ); @@ -128,6 +129,7 @@ jQuery.fn.extend( { } camelKey = jQuery.camelCase( key ); + // Attempt to get data from the cache // with the key camelized data = dataUser.get( elem, camelKey ); @@ -148,7 +150,8 @@ jQuery.fn.extend( { // Set the data... camelKey = jQuery.camelCase( key ); - this.each(function() { + 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 = dataUser.get( this, camelKey ); @@ -161,10 +164,10 @@ jQuery.fn.extend( { // *... 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 ) { + if ( key.indexOf( "-" ) > -1 && data !== undefined ) { dataUser.set( this, key, value ); } - }); + } ); }, null, value, arguments.length > 1, null, true ); }, diff --git a/src/data/Data.js b/src/data/Data.js index b33f13497..0e29c1fc6 100644 --- a/src/data/Data.js +++ b/src/data/Data.js @@ -28,11 +28,12 @@ Data.prototype = { value: value, writable: true, configurable: true - }); + } ); } return owner[ this.expando ]; }, - cache: function( owner, initial ) { + cache: function( owner ) { + // We can accept data for non-element nodes in modern browsers, // but we should not, see #8335. // Always return an empty object. @@ -81,6 +82,7 @@ Data.prototype = { // Handle: [ owner, { properties } ] args } else { + // Copy the properties one-by-one to the cache object for ( prop in data ) { cache[ prop ] = data[ prop ]; @@ -91,10 +93,11 @@ Data.prototype = { get: function( owner, key ) { return key === undefined ? this.cache( owner ) : - owner[ this.expando ] && owner[ this.expando ][ key ] + owner[ this.expando ] && owner[ this.expando ][ key ]; }, access: function( owner, key, value ) { var stored; + // In cases where either: // // 1. No key was specified @@ -107,12 +110,12 @@ Data.prototype = { // 2. The data stored at the key // if ( key === undefined || - ((key && typeof key === "string") && value === undefined) ) { + ( ( key && typeof key === "string" ) && value === undefined ) ) { stored = this.get( owner, key ); return stored !== undefined ? - stored : this.get( owner, jQuery.camelCase(key) ); + stored : this.get( owner, jQuery.camelCase( key ) ); } // When the key is not a string, or both a key and value @@ -139,8 +142,10 @@ Data.prototype = { this.register( owner ); } else { + // Support array or space separated string of keys if ( jQuery.isArray( key ) ) { + // If "name" is an array of keys... // When data is initially created, via ("key", "val") signature, // keys will be converted to camelCase. @@ -150,10 +155,12 @@ Data.prototype = { name = key.concat( key.map( jQuery.camelCase ) ); } else { camel = jQuery.camelCase( key ); + // Try the string as a key before any manipulation if ( key in cache ) { name = [ key, camel ]; } else { + // If a key with the spaces exists, use it. // Otherwise, create an array by matching non-whitespace name = camel; diff --git a/src/deferred.js b/src/deferred.js index b56a40104..d2cd6080f 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -4,14 +4,15 @@ define( [ "./callbacks" ], function( jQuery, slice ) { -jQuery.extend({ +jQuery.extend( { Deferred: function( func ) { var tuples = [ + // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] + [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], + [ "notify", "progress", jQuery.Callbacks( "memory" ) ] ], state = "pending", promise = { @@ -24,11 +25,12 @@ jQuery.extend({ }, then: function( /* fnDone, fnFail, fnProgress */ ) { var fns = arguments; - return jQuery.Deferred(function( newDefer ) { + return jQuery.Deferred( function( newDefer ) { jQuery.each( tuples, function( i, tuple ) { var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; + // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ](function() { + deferred[ tuple[ 1 ] ]( function() { var returned = fn && fn.apply( this, arguments ); if ( returned && jQuery.isFunction( returned.promise ) ) { returned.promise() @@ -46,6 +48,7 @@ jQuery.extend({ fns = null; } ).promise(); }, + // Get a promise for this deferred // If obj is provided, the promise aspect is added to the object promise: function( obj ) { @@ -63,11 +66,12 @@ jQuery.extend({ stateString = tuple[ 3 ]; // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; + promise[ tuple[ 1 ] ] = list.add; // Handle state if ( stateString ) { - list.add(function() { + list.add( function() { + // state = [ resolved | rejected ] state = stateString; @@ -76,12 +80,13 @@ jQuery.extend({ } // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); return this; }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); + // Make the deferred a promise promise.promise( deferred ); diff --git a/src/offset.js b/src/offset.js index acc41997a..4352a9995 100644 --- a/src/offset.js +++ b/src/offset.js @@ -77,9 +77,9 @@ jQuery.fn.extend( { if ( arguments.length ) { return options === undefined ? this : - this.each(function( i ) { + this.each( function( i ) { jQuery.offset.setOffset( this, options, i ); - }); + } ); } var docElem, win, diff --git a/src/wrap.js b/src/wrap.js index c85cd304e..32d1d331f 100644 --- a/src/wrap.js +++ b/src/wrap.js @@ -64,11 +64,11 @@ jQuery.fn.extend( { }, unwrap: function() { - return this.parent().each(function() { + return this.parent().each( function() { if ( !jQuery.nodeName( this, "body" ) ) { jQuery( this ).replaceWith( this.childNodes ); } - }).end(); + } ).end(); } } ); diff --git a/test/data/badjson.js b/test/data/badjson.js index ad2de7a39..d359e824f 100644 --- a/test/data/badjson.js +++ b/test/data/badjson.js @@ -1 +1 @@ -{bad: toTheBone} +{bad: toTheBone;} diff --git a/test/data/testinit.js b/test/data/testinit.js index ca8f433d7..4c8d7d972 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -269,6 +269,7 @@ this.iframeCallback = undefined; // Tests are always loaded async QUnit.config.autostart = false; this.loadTests = function() { + // Leverage QUnit URL parsing to detect testSwarm environment and "basic" testing mode var loadSwarm = ( QUnit.urlParams[ "swarmURL" ] + "" ).indexOf( "http" ) === 0, basicTests = ( QUnit.urlParams[ "module" ] + "" ) === "basic"; @@ -277,6 +278,7 @@ this.loadTests = function() { require( [ "data/testrunner.js" ], function() { var i = 0, tests = [ + // A special module with basic tests, meant for // not fully supported environments like Android 2.3, // jsdom or PhantomJS. We run it everywhere, though, diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 8e7cc06f4..5110a9795 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1586,11 +1586,11 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re } else { // No built-in support for binary data, but it's easy to add via a prefilter - jQuery.ajaxPrefilter( "arraybuffer", function ( s ) { + jQuery.ajaxPrefilter( "arraybuffer", function( s ) { s.xhrFields = { responseType: "arraybuffer" }; s.responseFields.arraybuffer = "response"; s.converters[ "binary arraybuffer" ] = true; - }); + } ); ajaxTest( "gh-2498 - jQuery.ajax() - binary data shouldn't throw an exception", 2, function( assert ) { return { @@ -1828,7 +1828,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re url: url( "data/ajax/content-type.php" ), data: { "content-type": "test/jsontest", - "response": JSON.stringify({test: "test"}) + "response": JSON.stringify( { test: "test" } ) }, success: function( result ) { assert.strictEqual( diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 517c907db..f2bcefcad 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -737,9 +737,9 @@ QUnit.test( "prop('tabindex')", function( assert ) { QUnit.test( "image.prop( 'tabIndex' )", function( assert ) { assert.expect( 1 ); - var image = jQuery("") - .appendTo("#qunit-fixture"); - assert.equal( image.prop("tabIndex" ), -1, "tabIndex on image" ); + var image = jQuery( "" ) + .appendTo( "#qunit-fixture" ); + assert.equal( image.prop( "tabIndex" ), -1, "tabIndex on image" ); } ); QUnit.test( "prop('tabindex', value)", function( assert ) { diff --git a/test/unit/core.js b/test/unit/core.js index 1faf293b0..e2b4d1b55 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -38,7 +38,7 @@ QUnit.test( "jQuery()", function( assert ) { } if ( jQuery.fn.offset ) { expected++; - attrObj["offset"] = { "top": 1, "left": 1 }; + attrObj[ "offset" ] = { "top": 1, "left": 1 }; } if ( jQuery.fn.css ) { expected += 2; @@ -95,7 +95,7 @@ QUnit.test( "jQuery()", function( assert ) { assert.equal( div.length, 4, "Correct number of elements generated for div hr code b" ); assert.equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); - assert.equal( jQuery( [ 1,2,3 ] ).get( 1 ), 2, "Test passing an array to the factory" ); + assert.equal( jQuery( [ 1, 2, 3 ] ).get( 1 ), 2, "Test passing an array to the factory" ); assert.equal( jQuery( document.body ).get( 0 ), jQuery( "body" ).get( 0 ), "Test passing an html node to the factory" ); @@ -105,14 +105,14 @@ QUnit.test( "jQuery()", function( assert ) { elem = jQuery( "\n\nworld" )[ 0 ]; assert.equal( elem.nodeName.toLowerCase(), "em", "leading newlines" ); - elem = jQuery("
", attrObj ); + elem = jQuery( "
", attrObj ); if ( jQuery.fn.width ) { assert.equal( elem[ 0 ].style.width, "10px", "jQuery() quick setter width" ); } if ( jQuery.fn.offset ) { - equal( elem[0].style.top, "1px", "jQuery() quick setter offset"); + assert.equal( elem[ 0 ].style.top, "1px", "jQuery() quick setter offset" ); } if ( jQuery.fn.css ) { @@ -273,8 +273,9 @@ QUnit.test( "type", function( assert ) { } ); QUnit.test( "type for `Symbol`", function( assert ) { + // Prevent reference errors - if( typeof Symbol !== "function" ) { + if ( typeof Symbol !== "function" ) { assert.expect( 0 ); return; } @@ -283,7 +284,7 @@ QUnit.test( "type for `Symbol`", function( assert ) { assert.equal( jQuery.type( Symbol() ), "symbol", "Symbol" ); assert.equal( jQuery.type( Object( Symbol() ) ), "symbol", "Symbol" ); -}); +} ); QUnit.asyncTest( "isPlainObject", function( assert ) { assert.expect( 15 ); @@ -361,7 +362,6 @@ QUnit[ typeof Symbol === "function" ? "test" : "skip" ]( "isPlainObject(Symbol)" assert.equal( jQuery.isPlainObject( Object( Symbol() ) ), false, "Symbol inside an object" ); } ); - QUnit.test( "isFunction", function( assert ) { assert.expect( 19 ); @@ -913,7 +913,7 @@ QUnit.test( "jQuery.map", function( assert ) { assert.ok( !result, "empty NodeList treated like array" ); result = jQuery.map( Array( 4 ), function( v, k ) { - return k % 2 ? k : [ k,k,k ]; + return k % 2 ? k : [ k, k, k ]; } ); assert.equal( result.join( "" ), "00012223", "Array results flattened (#2616)" ); } ); @@ -1065,7 +1065,7 @@ QUnit.test( "jQuery.grep(Array-like)", function( assert ) { [], "Satisfying elements absent, Array-like object used, and grep explicitly uninverted" ); -}); +} ); QUnit.test( "jQuery.extend(Object, Object)", function( assert ) { assert.expect( 28 ); @@ -1183,19 +1183,19 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) { QUnit.test( "jQuery.extend(Object, Object {created with \"defineProperties\"})", function( assert ) { assert.expect( 2 ); - var definedObj = Object.defineProperties({}, { + var definedObj = Object.defineProperties( {}, { "enumerableProp": { - get: function () { + get: function() { return true; }, enumerable: true }, "nonenumerableProp": { - get: function () { + get: function() { return true; } } - }), + } ), accessorObj = {}; jQuery.extend( accessorObj, definedObj ); @@ -1253,7 +1253,7 @@ QUnit.test( "jQuery.each(Object,Function)", function( assert ) { assert.deepEqual( seen, [ 1, 2 ], "Broken array iteration" ); seen = []; - jQuery.each( { "a": 1, "b": 2,"c": 3 }, function( k, v ) { + jQuery.each( { "a": 1, "b": 2, "c": 3 }, function( k, v ) { seen.push( v ); return false; } ); @@ -1373,7 +1373,7 @@ QUnit.test( "jQuery.makeArray", function( assert ) { assert.equal( ( function() { return jQuery.makeArray( arguments ); } )( 1, 2 ).join( "" ), "12", "Pass makeArray an arguments array" ); - assert.equal( jQuery.makeArray( [ 1,2,3 ] ).join( "" ), "123", "Pass makeArray a real array" ); + assert.equal( jQuery.makeArray( [ 1, 2, 3 ] ).join( "" ), "123", "Pass makeArray a real array" ); assert.equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); diff --git a/test/unit/data.js b/test/unit/data.js index a33322365..077362eda 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -278,9 +278,9 @@ QUnit.test( "data-* attributes", function( assert ) { var prop, i, l, metadata, elem, obj, obj2, check, num, num2, parseJSON = jQuery.parseJSON, - div = jQuery("
"), - child = jQuery("
"), - dummy = jQuery("
"); + div = jQuery( "
" ), + child = jQuery( "
" ), + dummy = jQuery( "
" ); assert.equal( div.data( "attr" ), undefined, "Check for non-existing data-attr attribute" ); @@ -295,8 +295,8 @@ QUnit.test( "data-* attributes", function( assert ) { div.remove(); - child.appendTo("#qunit-fixture"); - assert.equal( child.data("myobj"), "old data", "Value accessed from data-* attribute"); + child.appendTo( "#qunit-fixture" ); + assert.equal( child.data( "myobj" ), "old data", "Value accessed from data-* attribute" ); child.data( "myobj", "replaced" ); assert.equal( child.data( "myobj" ), "replaced", "Original data overwritten" ); @@ -408,7 +408,7 @@ QUnit.test( "data-* attributes", function( assert ) { break; case 3: assert.equal( jQuery( elem ).data( "number" ), true, "Check number property" ); - assert.deepEqual( jQuery( elem ).data( "stuff" ), [ 2,8 ], "Check stuff property" ); + assert.deepEqual( jQuery( elem ).data( "stuff" ), [ 2, 8 ], "Check stuff property" ); break; default: assert.ok( false, [ "Assertion failed on index ", index, ", with data" ].join( "" ) ); @@ -600,7 +600,7 @@ QUnit.test( ".data should not miss attr() set data-* with hyphenated property na assert.deepEqual( b.data( "long-param" ), { a: 2 }, "data with property long-param was found, 2" ); } ); -QUnit.test(".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function( assert ) { +QUnit.test( ".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function( assert ) { var div = jQuery( "
", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), datas = { "non-empty": "a string", @@ -695,7 +695,7 @@ QUnit.test( ".data supports interoperable removal of properties SET TWICE #13850 } ); QUnit.test( ".removeData supports removal of hyphenated properties via array (#12786)", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var div, plain, compare; @@ -708,6 +708,7 @@ QUnit.test( ".removeData supports removal of hyphenated properties via array (#1 // From batch assignment .data({ "a-a": 1 }) "a-a": 1, + // From property, value assignment .data( "b-b", 1 ) "bB": 1 }; @@ -842,13 +843,13 @@ QUnit.test( "Check that the expando is removed when there's no more data", funct assert.strictEqual( div[ 0 ][ key ], undefined, "Expando was not removed when there was no more data" ); } } -}); +} ); QUnit.test( "Check that the expando is removed when there's no more data on non-nodes", function( assert ) { assert.expect( 1 ); var key, - obj = jQuery( {key: 42} ); + obj = jQuery( { key: 42 } ); obj.data( "some", "data" ); assert.equal( obj.data( "some" ), "data", "Data is added" ); obj.removeData( "some" ); diff --git a/test/unit/deferred.js b/test/unit/deferred.js index e050f0454..0f55b0843 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -16,32 +16,32 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { assert.strictEqual( defer.pipe, defer.then, "pipe is an alias of then" ); - createDeferred().resolve().done(function() { + createDeferred().resolve().done( function() { assert.ok( true, "Success on resolve" ); assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" ); - }).fail(function() { + } ).fail( function() { assert.ok( false, "Error on resolve" ); - }).always(function() { + } ).always( function() { assert.ok( true, "Always callback on resolve" ); - }); + } ); - createDeferred().reject().done(function() { + createDeferred().reject().done( function() { assert.ok( false, "Success on reject" ); - }).fail(function() { + } ).fail( function() { assert.ok( true, "Error on reject" ); assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" ); - }).always(function() { + } ).always( function() { assert.ok( true, "Always callback on reject" ); - }); + } ); - createDeferred(function( defer ) { + createDeferred( function( defer ) { assert.ok( this === defer, "Defer passed as this & first argument" ); - this.resolve("done"); - }).done(function( value ) { + this.resolve( "done" ); + } ).done( function( value ) { assert.strictEqual( value, "done", "Passed function executed" ); - }); + } ); - createDeferred(function( defer ) { + createDeferred( function( defer ) { var promise = defer.promise(), func = function() {}, funcPromise = defer.promise( func ); @@ -97,18 +97,18 @@ QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) { var value1, value2, value3, defer = jQuery.Deferred(), - piped = defer.then(function( a, b ) { + piped = defer.then( function( a, b ) { return a * b; - }); + } ); - piped.done(function( result ) { + piped.done( function( result ) { value3 = result; - }); + } ); - defer.done(function( a, b ) { + defer.done( function( a, b ) { value1 = a; value2 = b; - }); + } ); defer.resolve( 2, 3 ); @@ -116,13 +116,13 @@ QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) { assert.strictEqual( value2, 3, "second resolve value ok" ); assert.strictEqual( value3, 6, "result of filter ok" ); - jQuery.Deferred().reject().then(function() { + jQuery.Deferred().reject().then( function() { assert.ok( false, "then should not be called on reject" ); - }); + } ); - jQuery.Deferred().resolve().then( jQuery.noop ).done(function( value ) { + jQuery.Deferred().resolve().then( jQuery.noop ).done( function( value ) { assert.strictEqual( value, undefined, "then done callback can return undefined/null" ); - }); + } ); } ); QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { @@ -132,31 +132,31 @@ QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { defer = jQuery.Deferred(), piped = defer.then( null, function( a, b ) { return a * b; - }); + } ); - piped.fail(function( result ) { + piped.fail( function( result ) { value3 = result; - }); + } ); - defer.fail(function( a, b ) { + defer.fail( function( a, b ) { value1 = a; value2 = b; - }); + } ); defer.reject( 2, 3 ); - strictEqual( value1, 2, "first reject value ok" ); - strictEqual( value2, 3, "second reject value ok" ); - strictEqual( value3, 6, "result of filter ok" ); + assert.strictEqual( value1, 2, "first reject value ok" ); + assert.strictEqual( value2, 3, "second reject value ok" ); + assert.strictEqual( value3, 6, "result of filter ok" ); jQuery.Deferred().resolve().then( null, function() { - ok( false, "then should not be called on resolve" ); - }); + assert.ok( false, "then should not be called on resolve" ); + } ); - jQuery.Deferred().reject().then( null, jQuery.noop ).fail(function( value ) { - strictEqual( value, undefined, "then fail callback can return undefined/null" ); - }); -}); + jQuery.Deferred().reject().then( null, jQuery.noop ).fail( function( value ) { + assert.strictEqual( value, undefined, "then fail callback can return undefined/null" ); + } ); +} ); QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) { assert.expect( 3 ); @@ -181,7 +181,7 @@ QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) { assert.strictEqual( value1, 2, "first progress value ok" ); assert.strictEqual( value2, 3, "second progress value ok" ); assert.strictEqual( value3, 6, "result of filter ok" ); -}); +} ); QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) { assert.expect( 3 ); @@ -208,7 +208,7 @@ QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) { assert.strictEqual( value1, 2, "first resolve value ok" ); assert.strictEqual( value2, 3, "second resolve value ok" ); assert.strictEqual( value3, 6, "result of filter ok" ); -}); +} ); QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) { assert.expect( 3 ); @@ -235,7 +235,7 @@ QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) { assert.strictEqual( value1, 2, "first reject value ok" ); assert.strictEqual( value2, 3, "second reject value ok" ); assert.strictEqual( value3, 6, "result of filter ok" ); -}); +} ); QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) { assert.expect( 3 ); @@ -261,7 +261,7 @@ QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) { assert.strictEqual( value1, 2, "first progress value ok" ); assert.strictEqual( value2, 3, "second progress value ok" ); assert.strictEqual( value3, 6, "result of filter ok" ); -}); +} ); QUnit.test( "jQuery.Deferred.then - context", function( assert ) { assert.expect( 7 ); @@ -271,16 +271,16 @@ QUnit.test( "jQuery.Deferred.then - context", function( assert ) { jQuery.Deferred().resolveWith( context, [ 2 ] ).then( function( value ) { return value * 3; - } ).done(function( value ) { + } ).done( function( value ) { assert.strictEqual( this, context, "custom context correctly propagated" ); assert.strictEqual( value, 6, "proper value received" ); - }); + } ); - jQuery.Deferred().resolve().then(function() { - return jQuery.Deferred().resolveWith(context); - }).done(function() { + jQuery.Deferred().resolve().then( function() { + return jQuery.Deferred().resolveWith( context ); + } ).done( function() { assert.strictEqual( this, context, "custom context of returned deferred correctly propagated" ); - }); + } ); defer = jQuery.Deferred(); piped = defer.then( function( value ) { @@ -289,25 +289,25 @@ QUnit.test( "jQuery.Deferred.then - context", function( assert ) { defer.resolve( 2 ); - piped.done(function( value ) { + piped.done( function( value ) { assert.strictEqual( this, piped, "default context gets updated to latest promise in the chain" ); assert.strictEqual( value, 6, "proper value received" ); - }); + } ); defer2 = jQuery.Deferred(); piped2 = defer2.then(); defer2.resolve( 2 ); - piped2.done(function( value ) { + piped2.done( function( value ) { assert.strictEqual( this, piped2, "default context gets updated to latest promise in the chain (without passing function)" ); assert.strictEqual( value, 2, "proper value received (without passing function)" ); - }); -}); + } ); +} ); QUnit.test( "jQuery.when", function( assert ) { assert.expect( 37 ); - jQuery.each({ + jQuery.each( { "an empty string": "", "a non-empty string": "some string", "zero": 0, @@ -322,21 +322,21 @@ QUnit.test( "jQuery.when", function( assert ) { }, function( message, value ) { assert.ok( jQuery.isFunction( - jQuery.when( value ).done(function( resolveValue ) { + jQuery.when( value ).done( function( resolveValue ) { assert.strictEqual( this, window, "Context is the global object with " + message ); assert.strictEqual( resolveValue, value, "Test the promise was resolved with " + message ); - }).promise + } ).promise ), "Test " + message + " triggers the creation of a new Promise" ); - }); + } ); assert.ok( jQuery.isFunction( - jQuery.when().done(function( resolveValue ) { + jQuery.when().done( function( resolveValue ) { assert.strictEqual( this, window, "Test the promise was resolved with window as its context" ); assert.strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" ); - }).promise + } ).promise ), "Test calling when with no parameter triggers the creation of a new Promise" ); @@ -344,22 +344,22 @@ QUnit.test( "jQuery.when", function( assert ) { var cache, context = {}; - jQuery.when( jQuery.Deferred().resolveWith( context ) ).done(function() { + jQuery.when( jQuery.Deferred().resolveWith( context ) ).done( function() { assert.strictEqual( this, context, "when( promise ) propagates context" ); - }); + } ); - jQuery.each([ 1, 2, 3 ], function( k, i ) { + jQuery.each( [ 1, 2, 3 ], function( k, i ) { - jQuery.when( cache || jQuery.Deferred(function() { + jQuery.when( cache || jQuery.Deferred( function() { this.resolve( i ); - }) - ).done(function( value ) { + } ) + ).done( function( value ) { assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) ); cache = value; - }); + } ); - }); + } ); } ); QUnit.test( "jQuery.when - joined", function( assert ) { @@ -399,31 +399,31 @@ QUnit.test( "jQuery.when - joined", function( assert ) { context1 = defer1 && jQuery.isFunction( defer1.promise ) ? defer1.promise() : undefined, context2 = defer2 && jQuery.isFunction( defer2.promise ) ? defer2.promise() : undefined; - jQuery.when( defer1, defer2 ).done(function( a, b ) { + jQuery.when( defer1, defer2 ).done( function( a, b ) { if ( shouldResolve ) { assert.deepEqual( [ a, b ], expected, code + " => resolve" ); assert.strictEqual( this[ 0 ], context1, code + " => first context OK" ); assert.strictEqual( this[ 1 ], context2, code + " => second context OK" ); } else { - ok( false, code + " => resolve" ); + assert.ok( false, code + " => resolve" ); } - }).fail(function( a, b ) { + } ).fail( function( a, b ) { if ( shouldError ) { assert.deepEqual( [ a, b ], expected, code + " => reject" ); } else { - ok( false, code + " => reject" ); + assert.ok( false, code + " => reject" ); } - }).progress(function( a, b ) { + } ).progress( function( a, b ) { assert.deepEqual( [ a, b ], expectedNotify, code + " => progress" ); assert.strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" ); assert.strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" ); - }); - }); - }); + } ); + } ); + } ); deferreds.futureSuccess.resolve( 1 ); deferreds.futureError.reject( 0 ); -}); +} ); QUnit.test( "jQuery.when - resolved", function( assert ) { assert.expect( 6 ); @@ -432,16 +432,16 @@ QUnit.test( "jQuery.when - resolved", function( assert ) { b = jQuery.Deferred().notify( 2 ).resolve( 5 ), c = jQuery.Deferred().notify( 3 ).resolve( 6 ); - jQuery.when( a, b, c ).progress(function( a, b, c ) { + jQuery.when( a, b, c ).progress( function( a, b, c ) { assert.strictEqual( a, 1, "first notify value ok" ); assert.strictEqual( b, 2, "second notify value ok" ); assert.strictEqual( c, 3, "third notify value ok" ); - }).done(function( a, b, c ) { + } ).done( function( a, b, c ) { assert.strictEqual( a, 4, "first resolve value ok" ); assert.strictEqual( b, 5, "second resolve value ok" ); assert.strictEqual( c, 6, "third resolve value ok" ); - }).fail(function() { + } ).fail( function() { assert.ok( false, "Error on resolve" ); - }); + } ); -}); +} ); diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js index 797290f3b..f474dc6c3 100644 --- a/test/unit/deprecated.js +++ b/test/unit/deprecated.js @@ -1,6 +1,5 @@ QUnit.module( "deprecated", { teardown: moduleTeardown } ); - QUnit.test( "bind/unbind", function( assert ) { assert.expect( 4 ); @@ -14,7 +13,7 @@ QUnit.test( "bind/unbind", function( assert ) { assert.equal( e.type, "click", "correct event type" ); assert.equal( e.data.bindData, 19, "correct trigger data" ); assert.equal( trig, 42, "correct bind data" ); - assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" ); + assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" ); } ) .trigger( "click", [ 42 ] ) .unbind( "click" ) @@ -32,11 +31,11 @@ QUnit.test( "delegate/undelegate", function( assert ) { markup .delegate( "b", "click", function( e ) { assert.equal( e.type, "click", "correct event type" ); - assert.equal( e.target.nodeName.toLowerCase(), "b" , "correct element" ); + assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" ); } ) .find( "b" ) .trigger( "click" ) .end() .undelegate( "b", "click" ) .remove(); -} ); \ No newline at end of file +} ); diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 20c93f680..5bd4f3384 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -254,7 +254,7 @@ QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/out assert.equal( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #9441" ); assert.equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #9441" ); assert.equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" ); - assert.equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" ); + assert.equal( $divChild.outerHeight( true ), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" ); // tests that child div of an unconnected div works the same as a normal div assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" ); @@ -265,7 +265,7 @@ QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/out assert.equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #9441" ); assert.equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #9441" ); assert.equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #9441" ); - assert.equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #9300" ); + assert.equal( $divUnconnected.outerHeight( true ), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #9300" ); // teardown html $divHiddenParent.remove(); @@ -327,7 +327,7 @@ QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) assert.equal( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #10413" ); assert.equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #10413" ); assert.equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #10413" ); - assert.equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #10413" ); + assert.equal( $divChild.outerHeight( true ), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #10413" ); // tests that child div of an unconnected div works the same as a normal div assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" ); @@ -338,7 +338,7 @@ QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) assert.equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #10413" ); assert.equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #10413" ); assert.equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #10413" ); - assert.equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #10413" ); + assert.equal( $divUnconnected.outerHeight( true ), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #10413" ); // teardown html $divHiddenParent.remove(); @@ -409,7 +409,7 @@ QUnit.test( "getters on non elements should return null", function( assert ) { QUnit.test( "setters with and without box-sizing:border-box", function( assert ) { assert.expect( 60 ); - var parent = jQuery( "#foo" ).css({ width: "200px", height: "200px", "font-size": "16px" }), + var parent = jQuery( "#foo" ).css( { width: "200px", height: "200px", "font-size": "16px" } ), el_bb = jQuery( "
" ).appendTo( parent ), el = jQuery( "
" ).appendTo( parent ); diff --git a/test/unit/effects.js b/test/unit/effects.js index 23dbc1ecf..20b15a1ca 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -36,13 +36,13 @@ QUnit.test( "show() basic", function( assert ) { assert.expect( 2 ); var div, - hiddendiv = jQuery("div.hidden"); + hiddendiv = jQuery( "div.hidden" ); hiddendiv.hide().show(); - assert.equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." ); + assert.equal( hiddendiv.css( "display" ), "block", "Make sure a pre-hidden div is visible." ); - div = jQuery("
").hide().appendTo("#qunit-fixture").show(); + div = jQuery( "
" ).hide().appendTo( "#qunit-fixture" ).show(); assert.equal( div.css( "display" ), "block", "Make sure pre-hidden divs show" ); @@ -99,7 +99,7 @@ QUnit.test( "show()", function( assert ) { assert.expectJqData( this, div, "olddisplay" ); // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("

"); + jQuery( "#qunit-fixture" ).append( "

" ); old = jQuery( "#test-table" ).show().css( "display" ) !== "table"; jQuery( "#test-table" ).remove(); @@ -137,39 +137,39 @@ QUnit.test( "show(Number) - other displays", function( assert ) { assert.expect( 15 ); // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("

"); + jQuery( "#qunit-fixture" ).append( "

" ); var test, old = jQuery( "#test-table" ).show().css( "display" ) !== "table"; - jQuery("#test-table").remove(); + jQuery( "#test-table" ).remove(); // Note: inline elements are expected to be inline-block // because we're showing width/height // Can't animate width/height inline // See #14344 test = { - "div" : "block", - "p" : "block", - "a" : "inline-block", - "code" : "inline-block", - "pre" : "block", - "span" : "inline-block", - "table" : old ? "block" : "table", - "thead" : old ? "block" : "table-header-group", - "tbody" : old ? "block" : "table-row-group", - "tr" : old ? "block" : "table-row", - "th" : old ? "block" : "table-cell", - "td" : old ? "block" : "table-cell", - "ul" : "block", - "li" : old ? "block" : "list-item" + "div": "block", + "p": "block", + "a": "inline-block", + "code": "inline-block", + "pre": "block", + "span": "inline-block", + "table": old ? "block" : "table", + "thead": old ? "block" : "table-header-group", + "tbody": old ? "block" : "table-row-group", + "tr": old ? "block" : "table-row", + "th": old ? "block" : "table-cell", + "td": old ? "block" : "table-cell", + "ul": "block", + "li": old ? "block" : "list-item" }; - jQuery.each(test, function(selector, expected) { - var elem = jQuery(selector, "#show-tests").show(1, function() { - assert.equal( elem.css("display"), expected, "Show using correct display type for " + selector ); - }); - }); + jQuery.each( test, function( selector, expected ) { + var elem = jQuery( selector, "#show-tests" ).show( 1, function() { + assert.equal( elem.css( "display" ), expected, "Show using correct display type for " + selector ); + } ); + } ); this.clock.tick( 10 ); jQuery( "#show-tests" ).remove(); @@ -180,7 +180,7 @@ QUnit.test( "Persist correct display value", function( assert ) { assert.expect( 3 ); // #show-tests * is set display: none in CSS - jQuery("#qunit-fixture").append("
foo
"); + jQuery( "#qunit-fixture" ).append( "
foo
" ); var $span = jQuery( "#show-tests span" ), displayNone = $span.css( "display" ), @@ -524,7 +524,7 @@ QUnit.test( "animate duration 0", function( assert ) { assert.expect( 11 ); var $elem, - $elems = jQuery( [ { a:0 },{ a:0 } ] ), + $elems = jQuery( [ { a:0 }, { a:0 } ] ), counter = 0; assert.equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" ); @@ -929,7 +929,7 @@ jQuery.each( { if ( t_w === "hide" ) {num++;} if ( t_o.constructor === Number ) {num += 2;} if ( t_w.constructor === Number ) {num += 2;} - if ( t_h.constructor === Number ) {num +=2;} + if ( t_h.constructor === Number ) {num += 2;} assert.expect( num ); @@ -937,7 +937,7 @@ jQuery.each( { elem.animate( anim, 50 ); - jQuery.when( elem ).done(function( elem ) { + jQuery.when( elem ).done( function( elem ) { var cur_o, cur_w, cur_h, old_h; elem = elem[ 0 ]; @@ -1539,11 +1539,12 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser show: [ 1 ], animate: [ { width: "show" } ] }, - $divTest = jQuery("
test
"), + $divTest = jQuery( "
test
" ), + // parentNode = null - $divEmpty = jQuery("
"), - $divNone = jQuery("
"), - $divInline = jQuery("
"), + $divEmpty = jQuery( "
" ), + $divNone = jQuery( "
" ), + $divInline = jQuery( "
" ), clock = this.clock; assert.strictEqual( $divTest.show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = document fragment" ); @@ -1556,24 +1557,24 @@ QUnit.test( "animate should set display for disconnected nodes", function( asser assert.expectJqData( env, $divNone[ 0 ], "olddisplay" ); jQuery.each( methods, function( name, opt ) { - jQuery.each([ + jQuery.each( [ // parentNode = document fragment - jQuery("
test
"), + jQuery( "
test
" ), // parentNode = null - jQuery("
") + jQuery( "
" ) ], function() { - var callback = [function () { + var callback = [ function() { assert.strictEqual( this.style.display, "block", "set display to block with " + name ); assert.expectJqData( env, this, "olddisplay" ); - }]; + } ]; jQuery.fn[ name ].apply( this, opt.concat( callback ) ); - }); - }); + } ); + } ); clock.tick( 400 ); } ); @@ -1817,7 +1818,7 @@ QUnit.test( "non-px animation handles non-numeric start (#11971)", function( ass this.clock.tick( 10 ); } ); -QUnit.test("Animation callbacks (#11797)", function( assert ) { +QUnit.test( "Animation callbacks (#11797)", function( assert ) { assert.expect( 16 ); var prog = 0, @@ -1938,7 +1939,7 @@ QUnit.test( "Animation callbacks in order (#2292)", function( assert ) { always: function() { assert.step( 5 ); } - }).finish(); + } ).finish(); this.clock.tick( dur + 10 ); } ); @@ -2316,8 +2317,8 @@ QUnit.test( "Respect display value on inline elements (#14824)", function( asser clock.tick( 800 ); } ); -QUnit.test( "Animation should go to its end state if document.hidden = true", function(assert) { - assert.expect(1); +QUnit.test( "Animation should go to its end state if document.hidden = true", function( assert ) { + assert.expect( 1 ); var height; if ( Object.defineProperty ) { @@ -2328,14 +2329,14 @@ QUnit.test( "Animation should go to its end state if document.hidden = true", fu get: function() { return true; } - }); + } ); } catch ( e ) {} } else { document.hidden = true; } if ( document.hidden ) { - height = jQuery( "#qunit-fixture" ).animate({ height: 500 } ).height(); + height = jQuery( "#qunit-fixture" ).animate( { height: 500 } ).height(); assert.equal( height, 500, "Animation should happen immediately if document.hidden = true" ); jQuery( document ).removeProp( "hidden" ); @@ -2343,7 +2344,7 @@ QUnit.test( "Animation should go to its end state if document.hidden = true", fu } else { assert.ok( true, "Can't run the test since we can't reproduce correct environment for it" ); } -}); +} ); QUnit.test( "jQuery.easing._default (gh-2218)", function( assert ) { assert.expect( 2 ); diff --git a/test/unit/event.js b/test/unit/event.js index b207441c9..12f132e0d 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -901,55 +901,55 @@ QUnit.test( "mouseenter, mouseleave don't catch exceptions", function( assert ) if ( jQuery.fn.click ) { - QUnit.test("trigger() shortcuts", function( assert ) { + QUnit.test( "trigger() shortcuts", function( assert ) { assert.expect( 6 ); var counter, clickCounter, - elem = jQuery("
  • Change location
  • ").prependTo("#firstUL"); - elem.find("a").on("click", function() { - var close = jQuery("spanx", this); // same with jQuery(this).find("span"); + elem = jQuery( "
  • Change location
  • " ).prependTo( "#firstUL" ); + elem.find( "a" ).on( "click", function() { + var close = jQuery( "spanx", this ); // same with jQuery(this).find("span"); assert.equal( close.length, 0, "Context element does not exist, length must be zero" ); - assert.ok( !close[0], "Context element does not exist, direct access to element must return undefined" ); + assert.ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" ); return false; - }).click(); + } ).click(); // manually clean up detached elements elem.remove(); - jQuery("#check1").click(function() { + jQuery( "#check1" ).click( function() { assert.ok( true, "click event handler for checkbox gets fired twice, see #815" ); - }).click(); + } ).click(); counter = 0; - jQuery("#firstp")[0].onclick = function() { + jQuery( "#firstp" )[ 0 ].onclick = function() { counter++; }; - jQuery("#firstp").click(); + jQuery( "#firstp" ).click(); assert.equal( counter, 1, "Check that click, triggers onclick event handler also" ); clickCounter = 0; - jQuery("#simon1")[0].onclick = function() { + jQuery( "#simon1" )[ 0 ].onclick = function() { clickCounter++; }; - jQuery("#simon1").click(); + jQuery( "#simon1" ).click(); assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" ); - elem = jQuery("").load(function(){ - assert.ok( true, "Trigger the load event, using the shortcut .load() (#2819)"); - }).load(); + elem = jQuery( "" ).load( function() { + assert.ok( true, "Trigger the load event, using the shortcut .load() (#2819)" ); + } ).load(); // manually clean up detached elements elem.remove(); // test that special handlers do not blow up with VML elements (#7071) - jQuery("").appendTo("head"); - jQuery(" ").appendTo("#form"); - jQuery("#oval").click().keydown(); - }); + jQuery( "" ).appendTo( "head" ); + jQuery( " " ).appendTo( "#form" ); + jQuery( "#oval" ).click().keydown(); + } ); } -QUnit.test("trigger() bubbling", function( assert ) { +QUnit.test( "trigger() bubbling", function( assert ) { assert.expect( 18 ); var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0; @@ -1226,7 +1226,7 @@ QUnit.test( "trigger(eventObject, [data], [fn])", function( assert ) { //$child.on("foo", error ); event = new jQuery.Event( "foo" ); - $child.trigger( event, [ 1,2,3 ] ).off(); + $child.trigger( event, [ 1, 2, 3 ] ).off(); assert.equal( event.result, "result", "Check event.result attribute" ); // Will error if it bubbles @@ -1882,7 +1882,7 @@ QUnit.test( "ignore comment nodes in event delegation (gh-2055)", function( asse .appendTo( $foo.find( "#sap" ) ); if ( !test() ) { - fireNative( $comment[0], "DOMNodeInserted" ); + fireNative( $comment[ 0 ], "DOMNodeInserted" ); } } ); @@ -2850,7 +2850,6 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e jQuery( "#donor-input" ).trigger( "focus" ); } ); - QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) { assert.expect( 5 ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 4d8eed7d9..2125067b8 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1560,7 +1560,7 @@ QUnit.test( "clone(multiple selected options) (Bug #8129)", function( assert ) { var element = jQuery( "" ); function getSelectedOptions( collection ) { - return collection.find( "option" ).filter(function( option ) { + return collection.find( "option" ).filter( function( option ) { return option.selected; } ); } diff --git a/test/unit/offset.js b/test/unit/offset.js index ea2c26606..88e75950b 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -52,10 +52,10 @@ QUnit.test( "object without getBoundingClientRect", function( assert ) { assert.expect( 2 ); // Simulates a browser without gBCR on elements, we just want to return 0,0 - var result = jQuery({ ownerDocument: document }).offset(); + var result = jQuery( { ownerDocument: document } ).offset(); assert.equal( result.top, 0, "Check top" ); assert.equal( result.left, 0, "Check left" ); -}); +} ); QUnit.test( "disconnected node", function( assert ) { assert.expect( 2 ); @@ -65,8 +65,8 @@ QUnit.test( "disconnected node", function( assert ) { // These tests are solely for master/compat consistency // Retrieving offset on disconnected/hidden elements is not officially // valid input, but will return zeros for back-compat - equal( result.top, 0, "Check top" ); - equal( result.left, 0, "Check left" ); + assert.equal( result.top, 0, "Check top" ); + assert.equal( result.left, 0, "Check left" ); } ); QUnit.test( "hidden (display: none) element", function( assert ) { diff --git a/test/unit/selector.js b/test/unit/selector.js index 2f6e9affd..a3c7aba90 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -32,7 +32,7 @@ QUnit.test( "id", function( assert ) { assert.t( "ID selector with existing ID descendant", "#firstp #simon1", [ "simon1" ] ); assert.t( "ID selector with non-existent descendant", "#firstp #foobar", [] ); assert.t( "ID selector using UTF8", "#台北Táiběi", [ "台北Táiběi" ] ); - assert.t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", [ "台北Táiběi","台北" ] ); + assert.t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", [ "台北Táiběi", "台北" ] ); assert.t( "Descendant ID selector using UTF8", "div #台北", [ "台北" ] ); assert.t( "Child ID selector using UTF8", "form > #台北", [ "台北" ] ); @@ -103,14 +103,14 @@ QUnit.test( "selectors with comma", function( assert ) { QUnit.test( "child and adjacent", function( assert ) { assert.expect( 27 ); - assert.t( "Child", "p > a", [ "simon1","google","groups","mark","yahoo","simon" ] ); - assert.t( "Child", "p> a", [ "simon1","google","groups","mark","yahoo","simon" ] ); - assert.t( "Child", "p >a", [ "simon1","google","groups","mark","yahoo","simon" ] ); - assert.t( "Child", "p>a", [ "simon1","google","groups","mark","yahoo","simon" ] ); - assert.t( "Child w/ Class", "p > a.blog", [ "mark","simon" ] ); - assert.t( "All Children", "code > *", [ "anchor1","anchor2" ] ); - assert.t( "All Grandchildren", "p > * > *", [ "anchor1","anchor2" ] ); - assert.t( "Adjacent", "p + p", [ "ap","en","sap" ] ); + assert.t( "Child", "p > a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] ); + assert.t( "Child", "p> a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] ); + assert.t( "Child", "p >a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] ); + assert.t( "Child", "p>a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] ); + assert.t( "Child w/ Class", "p > a.blog", [ "mark", "simon" ] ); + assert.t( "All Children", "code > *", [ "anchor1", "anchor2" ] ); + assert.t( "All Grandchildren", "p > * > *", [ "anchor1", "anchor2" ] ); + assert.t( "Adjacent", "p + p", [ "ap", "en", "sap" ] ); assert.t( "Adjacent", "p#firstp + p", [ "ap" ] ); assert.t( "Adjacent", "p[lang=en] + p", [ "sap" ] ); assert.t( "Adjacent", "a.GROUPS + code + a", [ "mark" ] ); @@ -163,7 +163,7 @@ QUnit.test( "attributes", function( assert ) { assert.t( "Attribute Equals", "#qunit-fixture a[rel=bookmark]", [ "simon1" ] ); assert.t( "Attribute Equals", "#qunit-fixture a[href='http://www.google.com/']", [ "google" ] ); assert.t( "Attribute Equals", "#qunit-fixture a[ rel = 'bookmark' ]", [ "simon1" ] ); - assert.t( "Attribute Equals Number", "#qunit-fixture option[value='1']", [ "option1b","option2b","option3b","option4b","option5c" ] ); + assert.t( "Attribute Equals Number", "#qunit-fixture option[value='1']", [ "option1b", "option2b", "option3b", "option4b", "option5c" ] ); assert.t( "Attribute Equals Number", "#qunit-fixture li[tabIndex='-1']", [ "foodWithNegativeTabIndex" ] ); document.getElementById( "anchor2" ).href = "#2"; @@ -187,13 +187,13 @@ QUnit.test( "attributes", function( assert ) { assert.t( "Attribute selector using UTF8", "span[lang=中文]", [ "台北" ] ); - assert.t( "Attribute Begins With", "a[href ^= 'http://www']", [ "google","yahoo" ] ); + assert.t( "Attribute Begins With", "a[href ^= 'http://www']", [ "google", "yahoo" ] ); assert.t( "Attribute Ends With", "a[href $= 'org/']", [ "mark" ] ); - assert.t( "Attribute Contains", "a[href *= 'google']", [ "google","groups" ] ); + assert.t( "Attribute Contains", "a[href *= 'google']", [ "google", "groups" ] ); if ( jQuery.find.compile ) { - assert.t( "Empty values", "#select1 option[value!='']", [ "option1b","option1c","option1d" ] ); - assert.t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", [ "google","groups","anchor1" ] ); + assert.t( "Empty values", "#select1 option[value!='']", [ "option1b", "option1c", "option1d" ] ); + assert.t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", [ "google", "groups", "anchor1" ] ); assert.t( "Select options via :selected", "#select1 option:selected", [ "option1a" ] ); assert.t( "Select options via :selected", "#select2 option:selected", [ "option2d" ] ); assert.t( "Select options via :selected", "#select3 option:selected", [ "option3b", "option3c" ] ); @@ -209,7 +209,6 @@ QUnit.test( "attributes", function( assert ) { assert.t( "Empty values", "#select1 option[value='']", [ "option1a" ] ); - assert.t( "Grouped Form Elements", "input[name='foo[bar]']", [ "hidden2" ] ); // Make sure attribute value quoting works correctly. See jQuery #6093; #6428; #13894 @@ -262,7 +261,6 @@ QUnit.test( "attributes", function( assert ) { assert.ok( "skip", ":input not supported in selector-native" ); } - // #11115 assert.ok( jQuery( "" ).prop( "checked", false ).is( "[checked]" ), "[checked] selects by attribute (positive)" diff --git a/test/unit/serialize.js b/test/unit/serialize.js index b48760200..6e250244d 100644 --- a/test/unit/serialize.js +++ b/test/unit/serialize.js @@ -10,7 +10,7 @@ QUnit.test( "jQuery.param()", function( assert ) { params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" }; assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); - params = { "string":"foo","null":null,"undefined":undefined }; + params = { "string":"foo", "null":null, "undefined":undefined }; assert.equal( jQuery.param( params ), "string=foo&null=&undefined=", "handle nulls and undefineds properly" ); params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" }; @@ -25,16 +25,16 @@ QUnit.test( "jQuery.param()", function( assert ) { params = { "foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } }; assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); - params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; + params = { a:[ 1, 2 ], b:{ c:3, d:[ 4, 5 ], e:{ x:[ 6 ], y:7, z:[ 8, 9 ] }, f:true, g:false, h:undefined }, i:[ 10, 11 ], j:true, k:false, l:[ undefined, 0 ], m:"cowboy hat?" }; assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" ); params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, "d": 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); - params = { "a":[ 1,2 ], "b":{ "c":3, "d":[ 4,5 ], "e":{ "x":[ 6 ], "y":7, "z":[ 8,9 ] }, "f":true, "g":false, "h":undefined }, "i":[ 10,11 ], "j":true, "k":false, "l":[ undefined,0 ], "m":"cowboy hat?" }; + params = { "a":[ 1, 2 ], "b":{ "c":3, "d":[ 4, 5 ], "e":{ "x":[ 6 ], "y":7, "z":[ 8, 9 ] }, "f":true, "g":false, "h":undefined }, "i":[ 10, 11 ], "j":true, "k":false, "l":[ undefined, 0 ], "m":"cowboy hat?" }; assert.equal( jQuery.param( params, true ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); - assert.equal( decodeURIComponent( jQuery.param( { "a": [ 1,2,3 ], "b[]": [ 4,5,6 ], "c[d]": [ 7,8,9 ], "e": { "f": [ 10 ], "g": [ 11,12 ], "h": 13 } } ) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); + assert.equal( decodeURIComponent( jQuery.param( { "a": [ 1, 2, 3 ], "b[]": [ 4, 5, 6 ], "c[d]": [ 7, 8, 9 ], "e": { "f": [ 10 ], "g": [ 11, 12 ], "h": 13 } } ) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); // #7945 assert.equal( jQuery.param( { "jquery": "1.4.2" } ), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" ); @@ -62,13 +62,13 @@ QUnit.test( "jQuery.param()", function( assert ) { params = { "foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us" }; assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); - params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; + params = { a:[ 1, 2 ], b:{ c:3, d:[ 4, 5 ], e:{ x:[ 6 ], y:7, z:[ 8, 9 ] }, f:true, g:false, h:undefined }, i:[ 10, 11 ], j:true, k:false, l:[ undefined, 0 ], m:"cowboy hat?" }; assert.equal( jQuery.param( params ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" ); params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; assert.equal( jQuery.param( params ), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); - params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; + params = { a:[ 1, 2 ], b:{ c:3, d:[ 4, 5 ], e:{ x:[ 6 ], y:7, z:[ 8, 9 ] }, f:true, g:false, h:undefined }, i:[ 10, 11 ], j:true, k:false, l:[ undefined, 0 ], m:"cowboy hat?" }; assert.equal( decodeURIComponent( jQuery.param( params, false ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); params = { "param1": null }; diff --git a/test/unit/support.js b/test/unit/support.js index 6a51ccb8a..80ea58ef0 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -272,6 +272,6 @@ testIframeWithCallback( assert.ok( true, "no ajax; skipping jQuery.support['" + i + "']" ); } } - }); + } ); } )();