aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <timmywil@users.noreply.github.com>2023-09-18 12:39:00 -0400
committerGitHub <noreply@github.com>2023-09-18 12:39:00 -0400
commit2bdecf8b7bd10864e5337a4e24e39476c78cf23a (patch)
tree4685fc5ca912e368c294a3949c7ef5b663fec980 /test
parentf75daab09102a4dd5107deadb55d4a169f86254a (diff)
downloadjquery-2bdecf8b7bd10864e5337a4e24e39476c78cf23a.tar.gz
jquery-2bdecf8b7bd10864e5337a4e24e39476c78cf23a.zip
Build: migrate most grunt tasks off of grunt
Updated tasks include: - lint - npmcopy - build, minify, and process for distribution. - new custom build command using yargs - compare size of minified/gzip built files - pretest scripts, including qunit-fixture, babel transpilation, and npmcopy - node smoke tests - promises aplus tests - new watch task using `rollup.watch` directly Also: - upgraded husky and added the new lint command - updated lint config to use new "flat" config format. See https://eslint.org/docs/latest/use/configure/configuration-files-new - Temporarily disabled one lint rule until flat config is supported by eslint-plugin-import. See https://github.com/import-js/eslint-plugin-import/issues/2556 - committed package-lock.json - updated all test scripts to use the new build - added an express test server that uses middleware-mockserver (this can be used to run tests without karma) - build-all-variants is now build:all Close gh-5318
Diffstat (limited to 'test')
-rw-r--r--test/.eslintrc.json89
-rw-r--r--test/data/core/.babelrc.json5
-rw-r--r--test/data/support/bootstrap.html22
-rw-r--r--test/data/testinit-jsdom.js4
-rw-r--r--test/data/testinit.js31
-rw-r--r--test/data/testrunner.js1
-rw-r--r--test/middleware-mockserver.cjs35
-rw-r--r--test/node_smoke_tests/commonjs/.eslintrc.json13
-rw-r--r--test/node_smoke_tests/module/.eslintrc.json13
-rw-r--r--test/node_smoke_tests/module/lib/jquery-module-specifier.js7
-rw-r--r--test/promises_aplus_adapters/.eslintrc.json5
-rw-r--r--test/server.js21
-rw-r--r--test/unit/ajax.js97
-rw-r--r--test/unit/attributes.js21
-rw-r--r--test/unit/callbacks.js19
-rw-r--r--test/unit/core.js118
-rw-r--r--test/unit/css.js9
-rw-r--r--test/unit/data.js22
-rw-r--r--test/unit/deferred.js48
-rw-r--r--test/unit/deprecated.js8
-rw-r--r--test/unit/effects.js62
-rw-r--r--test/unit/event.js165
-rw-r--r--test/unit/manipulation.js15
-rw-r--r--test/unit/offset.js129
-rw-r--r--test/unit/queue.js8
-rw-r--r--test/unit/selector.js30
-rw-r--r--test/unit/serialize.js22
-rw-r--r--test/unit/traversing.js8
28 files changed, 571 insertions, 456 deletions
diff --git a/test/.eslintrc.json b/test/.eslintrc.json
deleted file mode 100644
index b95c113d6..000000000
--- a/test/.eslintrc.json
+++ /dev/null
@@ -1,89 +0,0 @@
-{
- "root": true,
-
- "extends": "../.eslintrc-browser.json",
-
- "env": {
-
- // In source the browser env is not enabled but unit tests rely on them
- // too much and we don't run them in non-browser environments anyway.
- "browser": true
- },
-
- "globals": {
- "require": false,
- "Promise": false,
- "Symbol": false,
- "trustedTypes": false,
- "QUnit": false,
- "ajaxTest": false,
- "testIframe": false,
- "createDashboardXML": false,
- "createWithFriesXML": false,
- "createXMLFragment": false,
- "includesModule": false,
- "moduleTeardown": false,
- "url": false,
- "q": false,
- "jQuery": true,
- "sinon": true,
- "amdDefined": true,
- "fireNative": true,
- "Globals": true,
- "hasPHP": true,
- "isLocal": true,
- "supportjQuery": true,
- "originaljQuery": true,
- "$": true,
- "original$": true,
- "baseURL": true,
- "externalHost": true
- },
-
- "rules": {
- // See https://github.com/eslint/eslint/issues/2342
- "no-unused-vars": "off",
-
- // Too many errors
- "max-len": "off",
- "brace-style": "off",
- "key-spacing": "off",
- "camelcase": "off",
- "one-var": "off",
- "strict": "off",
-
- // Not really too many - waiting for autofix features for these rules
- "lines-around-comment": "off",
- "dot-notation": "off"
- },
-
- "overrides": [
- {
- "files": [
- "middleware-mockserver.js"
- ],
-
- "extends": "../.eslintrc-node.json"
- },
-
- {
- "files": [
- "data/core/jquery-iterability-transpiled-es6.js",
- "data/testinit-jsdom.js"
- ],
- "parserOptions": {
- "ecmaVersion": 2015
- }
- },
-
- {
- "files": [
- "jquery.js",
- "data/testinit.js"
- ],
- "parserOptions": {
- "ecmaVersion": 2020
- }
- }
- ]
-}
diff --git a/test/data/core/.babelrc.json b/test/data/core/.babelrc.json
new file mode 100644
index 000000000..4328ab218
--- /dev/null
+++ b/test/data/core/.babelrc.json
@@ -0,0 +1,5 @@
+{
+ "plugins": ["@babel/transform-for-of"],
+ "retainLines": true,
+ "sourceMaps": "inline"
+}
diff --git a/test/data/support/bootstrap.html b/test/data/support/bootstrap.html
index d8e643ac2..731a47431 100644
--- a/test/data/support/bootstrap.html
+++ b/test/data/support/bootstrap.html
@@ -5,16 +5,16 @@
<link rel="stylesheet" href="../../../external/bootstrap/bootstrap.min.css" class="stylesheet">
</head>
<body>
-<div>
- <script src="../../jquery.js"></script>
- <script src="../iframeTest.js"></script>
- <script src="getComputedSupport.js"></script>
-</div>
-<script>
- startIframeTest(
- getComputedStyle( document.body ),
- getComputedSupport( jQuery.support )
- );
-</script>
+ <div>
+ <script src="../../jquery.js"></script>
+ <script src="../iframeTest.js"></script>
+ <script src="getComputedSupport.js"></script>
+ </div>
+ <script>
+ startIframeTest(
+ getComputedStyle( document.body ),
+ getComputedSupport( jQuery.support )
+ );
+ </script>
</body>
</html>
diff --git a/test/data/testinit-jsdom.js b/test/data/testinit-jsdom.js
index 0a784df03..95012a392 100644
--- a/test/data/testinit-jsdom.js
+++ b/test/data/testinit-jsdom.js
@@ -37,10 +37,10 @@ window.original$ = this.$ = "replaced";
* @example url("mock.php?foo=bar")
* @result "data/mock.php?foo=bar&10538358345554"
*/
-function url( value ) {
+this.url = function( value ) {
return baseURL + value + ( /\?/.test( value ) ? "&" : "?" ) +
new Date().getTime() + "" + parseInt( Math.random() * 100000, 10 );
-}
+};
// We only run basic tests in jsdom so we don't need to repeat the logic
// from the regular testinit.js
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 8d85a0edc..baf758205 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -1,5 +1,4 @@
/* eslint no-multi-str: "off" */
-
"use strict";
var FILEPATH = "/test/data/testinit.js",
@@ -16,18 +15,17 @@ var FILEPATH = "/test/data/testinit.js",
baseURL = parentUrl + "test/data/",
supportjQuery = this.jQuery,
- // see RFC 2606
- externalHost = "example.com",
-
// NOTE: keep it in sync with build/tasks/lib/slim-build-flags.js
- slimBuildFlags = [
- "-ajax",
- "-callbacks",
- "-deferred",
- "-effects",
- "-queue"
+ excludedFromSlim = [
+ "ajax",
+ "callbacks",
+ "deferred",
+ "effects",
+ "queue"
];
+// see RFC 2606
+this.externalHost = "example.com";
this.hasPHP = true;
this.isLocal = window.location.protocol === "file:";
@@ -241,7 +239,7 @@ this.ajaxTest = function( title, expect, options, wrapper ) {
completed = true;
delete ajaxTest.abort;
assert.ok( false, "aborted " + reason );
- jQuery.each( requests, function( i, request ) {
+ jQuery.each( requests, function( _i, request ) {
request.abort();
} );
}
@@ -319,16 +317,16 @@ this.includesModule = function( moduleName ) {
var excludedModulesPart, excludedModules;
- // A short-cut for the slim build, e.g. "4.0.0-pre slim"
- if ( jQuery.fn.jquery.indexOf( " slim" ) > -1 ) {
+ // A short-cut for the slim build, e.g. "4.0.0-pre+slim"
+ if ( jQuery.fn.jquery.indexOf( "+slim" ) > -1 ) {
// The module is included if it does NOT exist on the list
// of modules excluded in the slim build
- return slimBuildFlags.indexOf( "-" + moduleName ) === -1;
+ return excludedFromSlim.indexOf( moduleName ) === -1;
}
- // example version for `grunt custom:-deprecated`:
- // "4.0.0-pre -deprecated,-deprecated/ajax-event-alias,-deprecated/event"
+ // example version for `npm run build -- -e deprecated`:
+ // "v4.0.0-pre+14dc9347 -deprecated,-deprecated/ajax-event-alias,-deprecated/event"
excludedModulesPart = jQuery.fn.jquery
// Take the flags out of the version string.
@@ -393,6 +391,7 @@ this.loadTests = function() {
var i = 0,
tests = [
+
// A special module with basic tests, meant for not fully
// supported environments like jsdom. We run it everywhere,
// though, to make sure tests are not broken.
diff --git a/test/data/testrunner.js b/test/data/testrunner.js
index 283c37d8c..8da5cc3b3 100644
--- a/test/data/testrunner.js
+++ b/test/data/testrunner.js
@@ -1,5 +1,4 @@
( function() {
-
"use strict";
// Store the old count so that we only assert on tests that have actually leaked,
diff --git a/test/middleware-mockserver.cjs b/test/middleware-mockserver.cjs
index 35e4c1778..a7a7a47b9 100644
--- a/test/middleware-mockserver.cjs
+++ b/test/middleware-mockserver.cjs
@@ -67,16 +67,25 @@ const mocks = {
resp.end( "<root><element /></root>" );
},
script: function( req, resp ) {
+ const headers = {};
if ( req.query.header === "ecma" ) {
- resp.writeHead( 200, { "content-type": "application/ecmascript" } );
+ headers[ "content-type" ] = "application/ecmascript";
} else if ( "header" in req.query ) {
- resp.writeHead( 200, { "content-type": "text/javascript" } );
+ headers[ "content-type" ] = "text/javascript";
} else {
- resp.writeHead( 200, { "content-type": "text/html" } );
+ headers[ "content-type" ] = "text/html";
}
if ( req.query.cors ) {
- resp.writeHead( 200, { "access-control-allow-origin": "*" } );
+ headers[ "access-control-allow-origin" ] = "*";
+ }
+
+ if ( resp.set ) {
+ resp.set( headers );
+ } else {
+ for ( const key in headers ) {
+ resp.writeHead( 200, { [ key ]: headers[ key ] } );
+ }
}
if ( req.query.callback ) {
@@ -165,14 +174,25 @@ const mocks = {
}
},
headers: function( req, resp ) {
- resp.writeHead( 200, {
+ const headers = {
"Sample-Header": "Hello World",
"Empty-Header": "",
"Sample-Header2": "Hello World 2",
"List-Header": "Item 1",
"list-header": "Item 2",
"constructor": "prototype collision (constructor)"
- } );
+ };
+
+ // Use resp.append in express to
+ // avoid overwriting List-Header
+ if ( resp.append ) {
+
+ for ( const key in headers ) {
+ resp.append( key, headers[ key ] );
+ }
+ } else {
+ resp.writeHead( 200, headers );
+ }
req.query.keys.split( "|" ).forEach( function( key ) {
if ( key.toLowerCase() in req.headers ) {
resp.write( `${ key }: ${ req.headers[ key.toLowerCase() ] }\n` );
@@ -354,7 +374,7 @@ function MockserverMiddlewareFactory() {
parsed: parsed
} );
- if ( /^test\/data\/mock.php\//.test( path ) ) {
+ if ( /^\/?test\/data\/mock.php\/?/.test( path ) ) {
// Support REST-like Apache PathInfo
path = "test\/data\/mock.php";
@@ -365,6 +385,7 @@ function MockserverMiddlewareFactory() {
return;
}
+ // console.log( "Mock handling", req.method, parsed.href );
handlers[ path ]( subReq, resp, next );
};
}
diff --git a/test/node_smoke_tests/commonjs/.eslintrc.json b/test/node_smoke_tests/commonjs/.eslintrc.json
deleted file mode 100644
index 26409bd89..000000000
--- a/test/node_smoke_tests/commonjs/.eslintrc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "root": true,
-
- "extends": "../../../.eslintrc-node.json",
-
- "parserOptions": {
- "ecmaVersion": 2015,
- "sourceType": "script"
- },
- "env": {
- "es2022": true
- }
-}
diff --git a/test/node_smoke_tests/module/.eslintrc.json b/test/node_smoke_tests/module/.eslintrc.json
deleted file mode 100644
index 3a13e1732..000000000
--- a/test/node_smoke_tests/module/.eslintrc.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "root": true,
-
- "extends": "../../../.eslintrc-node.json",
-
- "parserOptions": {
- "ecmaVersion": 2022,
- "sourceType": "module"
- },
- "env": {
- "es2022": true
- }
-}
diff --git a/test/node_smoke_tests/module/lib/jquery-module-specifier.js b/test/node_smoke_tests/module/lib/jquery-module-specifier.js
index 39aff9fd4..e65432f47 100644
--- a/test/node_smoke_tests/module/lib/jquery-module-specifier.js
+++ b/test/node_smoke_tests/module/lib/jquery-module-specifier.js
@@ -5,6 +5,11 @@ const dirname = path.dirname( fileURLToPath( import.meta.url ) );
const ROOT_DIR = path.resolve( dirname, "..", "..", "..", ".." );
+// import does not work with Windows-style paths
+function ensureUnixPath( path ) {
+ return path.replace( /^[a-z]:/i, "" ).replace( /\\+/g, "/" );
+}
+
// If `jQueryModuleSpecifier` is a real relative path, make it absolute
// to make sure it resolves to the same file inside utils from
// a subdirectory. Otherwise, leave it as-is as we may be testing `exports`
@@ -16,6 +21,6 @@ export const getJQueryModuleSpecifier = () => {
}
return jQueryModuleInputSpecifier.startsWith( "." ) ?
- path.resolve( ROOT_DIR, jQueryModuleInputSpecifier ) :
+ ensureUnixPath( path.resolve( ROOT_DIR, jQueryModuleInputSpecifier ) ) :
jQueryModuleInputSpecifier;
};
diff --git a/test/promises_aplus_adapters/.eslintrc.json b/test/promises_aplus_adapters/.eslintrc.json
deleted file mode 100644
index f961645e5..000000000
--- a/test/promises_aplus_adapters/.eslintrc.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "root": true,
-
- "extends": "../../.eslintrc-node.json"
-}
diff --git a/test/server.js b/test/server.js
new file mode 100644
index 000000000..268018cc1
--- /dev/null
+++ b/test/server.js
@@ -0,0 +1,21 @@
+import express from "express";
+import mockServer from "./middleware-mockserver.cjs";
+import fs from "fs";
+
+const nameHTML = fs.readFileSync( "./test/data/name.html", "utf8" );
+const app = express();
+
+app.use( mockServer() );
+
+app.post( "/test/data/name.html", function( _req, res ) {
+ res.send( nameHTML );
+} );
+
+app.use( "/dist", express.static( "dist" ) );
+app.use( "/src", express.static( "src" ) );
+app.use( "/test", express.static( "test" ) );
+app.use( "/external", express.static( "external" ) );
+
+app.listen( 3000, function() {
+ console.log( "Server is running on port 3000" );
+} );
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 99622c6ce..d20327b90 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -455,6 +455,7 @@ QUnit.module( "ajax", {
},
cache: false,
beforeSend: function( xhr, settings ) {
+
// Clear the cache-buster param value
var url = settings.url.replace( /_=[^&#]+/, "_=" );
assert.equal( url, baseURL + "name.html?abc&devo=hat&_=#brownies",
@@ -684,7 +685,7 @@ QUnit.module( "ajax", {
url: url( "404.txt" ),
beforeSend: nocallback( "beforeSend" ),
error: nocallback( "error" ),
- complete: nocallback( "complete" )
+ complete: nocallback( "complete" )
};
} );
@@ -873,8 +874,8 @@ QUnit.module( "ajax", {
success: function( data ) {
assert.ok( data.match( /^html text/ ), "Check content for datatype html" );
jQuery( "#ap" ).html( data );
- assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated for datatype html" );
- assert.strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated for datatype html" );
+ assert.strictEqual( window.testFoo, "foo", "Check if script was evaluated for datatype html" );
+ assert.strictEqual( window.testBar, "bar", "Check if script src was evaluated for datatype html" );
}
};
} );
@@ -884,6 +885,7 @@ QUnit.module( "ajax", {
return {
dataType: "jsonp",
url: url( "mock.php?action=errorWithScript" ),
+
// error is the significant assertion
error: function( xhr ) {
var expected = { "status": 404, "msg": "Not Found" };
@@ -912,6 +914,7 @@ QUnit.module( "ajax", {
complete: function() {
jQuery.globalEval = globalEval;
},
+
// error is the significant assertion
error: function( xhr ) {
assert.strictEqual( xhr.status, 404, testMsg );
@@ -1171,8 +1174,8 @@ QUnit.module( "ajax", {
Globals.register( "functionToCleanUp" );
Globals.register( "XXX" );
Globals.register( "jsonpResults" );
- window[ "jsonpResults" ] = function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (GET, custom callback function)" );
+ window.jsonpResults = function( data ) {
+ assert.ok( data.data, "JSON results returned (GET, custom callback function)" );
};
},
requests: [ {
@@ -1181,7 +1184,7 @@ QUnit.module( "ajax", {
crossDomain: crossDomain,
jsonp: "callback",
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (GET, data obj callback)" );
+ assert.ok( data.data, "JSON results returned (GET, data obj callback)" );
}
}, {
url: baseURL + "mock.php?action=jsonp",
@@ -1190,7 +1193,7 @@ QUnit.module( "ajax", {
jsonpCallback: "jsonpResults",
success: function( data ) {
assert.strictEqual(
- typeof window[ "jsonpResults" ],
+ typeof window.jsonpResults,
"function",
"should not rewrite original function"
);
@@ -1202,8 +1205,8 @@ QUnit.module( "ajax", {
crossDomain: crossDomain,
jsonpCallback: "functionToCleanUp",
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (GET, custom callback name to be cleaned up)" );
- assert.strictEqual( window[ "functionToCleanUp" ], true, "Callback was removed (GET, custom callback name to be cleaned up)" );
+ assert.ok( data.data, "JSON results returned (GET, custom callback name to be cleaned up)" );
+ assert.strictEqual( window.functionToCleanUp, true, "Callback was removed (GET, custom callback name to be cleaned up)" );
var xhr;
jQuery.ajax( {
url: baseURL + "mock.php?action=jsonp",
@@ -1217,7 +1220,7 @@ QUnit.module( "ajax", {
} );
xhr.fail( function() {
assert.ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" );
- assert.strictEqual( window[ "functionToCleanUp" ], true, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" );
+ assert.strictEqual( window.functionToCleanUp, true, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" );
} );
}
}, {
@@ -1230,7 +1233,7 @@ QUnit.module( "ajax", {
assert.ok( /action=jsonp&callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" );
},
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (GET, custom callback name with no url manipulation)" );
+ assert.ok( data.data, "JSON results returned (GET, custom callback name with no url manipulation)" );
}
} ]
};
@@ -1267,7 +1270,7 @@ QUnit.module( "ajax", {
dataType: "jsonp",
crossDomain: crossDomain,
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (POST, no callback)" );
+ assert.ok( data.data, "JSON results returned (POST, no callback)" );
}
},
{
@@ -1277,7 +1280,7 @@ QUnit.module( "ajax", {
dataType: "jsonp",
crossDomain: crossDomain,
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (POST, data callback)" );
+ assert.ok( data.data, "JSON results returned (POST, data callback)" );
}
},
{
@@ -1287,7 +1290,7 @@ QUnit.module( "ajax", {
dataType: "jsonp",
crossDomain: crossDomain,
success: function( data ) {
- assert.ok( data[ "data" ], "JSON results returned (POST, data obj callback)" );
+ assert.ok( data.data, "JSON results returned (POST, data obj callback)" );
}
}
];
@@ -1461,7 +1464,7 @@ QUnit.module( "ajax", {
url: url( "mock.php?action=testbar" ),
dataType: "script",
success: function() {
- assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" );
+ assert.strictEqual( window.testBar, "bar", "Script results returned (GET, no callback)" );
}
};
} );
@@ -1478,7 +1481,7 @@ QUnit.module( "ajax", {
type: "POST",
dataType: "script",
success: function( data, status ) {
- assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (POST, no callback)" );
+ assert.strictEqual( window.testBar, "bar", "Script results returned (POST, no callback)" );
assert.strictEqual( status, "success", "Script results returned (POST, no callback)" );
}
};
@@ -1492,7 +1495,7 @@ QUnit.module( "ajax", {
url: url( "mock.php?action=testbar" ),
dataType: "script",
success: function() {
- assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" );
+ assert.strictEqual( window.testBar, "bar", "Script results returned (GET, no callback)" );
}
};
} );
@@ -1518,10 +1521,10 @@ QUnit.module( "ajax", {
},
success: function( json ) {
assert.ok( json.length >= 2, "Check length" );
- assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" );
- assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" );
- assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" );
- assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" );
+ assert.strictEqual( json[ 0 ].name, "John", "Check JSON: first, name" );
+ assert.strictEqual( json[ 0 ].age, 21, "Check JSON: first, age" );
+ assert.strictEqual( json[ 1 ].name, "Peter", "Check JSON: second, name" );
+ assert.strictEqual( json[ 1 ].age, 25, "Check JSON: second, age" );
}
},
{
@@ -1538,10 +1541,10 @@ QUnit.module( "ajax", {
],
success: function( json ) {
assert.ok( json.length >= 2, "Check length" );
- assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" );
- assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" );
- assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" );
- assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" );
+ assert.strictEqual( json[ 0 ].name, "John", "Check JSON: first, name" );
+ assert.strictEqual( json[ 0 ].age, 21, "Check JSON: first, age" );
+ assert.strictEqual( json[ 1 ].name, "Peter", "Check JSON: second, name" );
+ assert.strictEqual( json[ 1 ].age, 25, "Check JSON: second, age" );
}
}
];
@@ -1562,10 +1565,10 @@ QUnit.module( "ajax", {
assert.strictEqual( typeof text, "string", "json wasn't auto-determined" );
var json = JSON.parse( text );
assert.ok( json.length >= 2, "Check length" );
- assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" );
- assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" );
- assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" );
- assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" );
+ assert.strictEqual( json[ 0 ].name, "John", "Check JSON: first, name" );
+ assert.strictEqual( json[ 0 ].age, 21, "Check JSON: first, age" );
+ assert.strictEqual( json[ 1 ].name, "Peter", "Check JSON: second, name" );
+ assert.strictEqual( json[ 1 ].age, 25, "Check JSON: second, age" );
}
},
{
@@ -1587,10 +1590,10 @@ QUnit.module( "ajax", {
assert.strictEqual( typeof text, "string", "json wasn't auto-determined" );
var json = JSON.parse( text );
assert.ok( json.length >= 2, "Check length" );
- assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" );
- assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" );
- assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" );
- assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" );
+ assert.strictEqual( json[ 0 ].name, "John", "Check JSON: first, name" );
+ assert.strictEqual( json[ 0 ].age, 21, "Check JSON: first, age" );
+ assert.strictEqual( json[ 1 ].name, "Peter", "Check JSON: second, name" );
+ assert.strictEqual( json[ 1 ].age, 25, "Check JSON: second, age" );
}
}
];
@@ -1816,6 +1819,7 @@ QUnit.module( "ajax", {
var ifModifiedNow = new Date();
jQuery.each(
+
/* jQuery.each arguments start */
{
" (cache)": true,
@@ -1870,6 +1874,7 @@ QUnit.module( "ajax", {
}
);
}
+
/* jQuery.each arguments end */
);
@@ -1940,6 +1945,7 @@ QUnit.module( "ajax", {
}
jQuery.each(
+
/* jQuery.each arguments start */
{
"name.html": true,
@@ -2014,6 +2020,7 @@ QUnit.module( "ajax", {
} );
}
+
/* jQuery.each arguments end*/
);
} );
@@ -2815,10 +2822,10 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
},
function( json ) {
assert.ok( json.length >= 2, "Check length" );
- assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" );
- assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" );
- assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" );
- assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" );
+ assert.strictEqual( json[ 0 ].name, "John", "Check JSON: first, name" );
+ assert.strictEqual( json[ 0 ].age, 21, "Check JSON: first, age" );
+ assert.strictEqual( json[ 1 ].name, "Peter", "Check JSON: second, name" );
+ assert.strictEqual( json[ 1 ].age, 25, "Check JSON: second, age" );
done();
}
);
@@ -2828,9 +2835,9 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
assert.expect( 2 );
var done = assert.async();
jQuery.getJSON( url( "mock.php?action=json" ), function( json ) {
- if ( json && json[ "data" ] ) {
- assert.strictEqual( json[ "data" ][ "lang" ], "en", "Check JSON: lang" );
- assert.strictEqual( json[ "data" ].length, 25, "Check JSON: length" );
+ if ( json && json.data ) {
+ assert.strictEqual( json.data.lang, "en", "Check JSON: lang" );
+ assert.strictEqual( json.data.length, 25, "Check JSON: length" );
done();
}
} );
@@ -2870,7 +2877,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
Globals.register( "testBar" );
jQuery.getScript( url( "mock.php?action=testbar" ), function() {
- assert.strictEqual( window[ "testBar" ], "bar", "Check if script was evaluated" );
+ assert.strictEqual( window.testBar, "bar", "Check if script was evaluated" );
done();
} );
}
@@ -2901,7 +2908,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery.getScript( {
url: url( "mock.php?action=testbar" ),
success: function() {
- assert.strictEqual( window[ "testBar" ], "bar", "Check if script was evaluated" );
+ assert.strictEqual( window.testBar, "bar", "Check if script was evaluated" );
done();
}
} );
@@ -3003,7 +3010,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
assert.expect( 7 );
var done = assert.async();
var verifyEvaluation = function() {
- assert.strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated after load" );
+ assert.strictEqual( window.testBar, "bar", "Check if script src was evaluated after load" );
assert.strictEqual( jQuery( "#ap" ).html(), "bar", "Check if script evaluation has modified DOM" );
done();
};
@@ -3014,7 +3021,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery( "#first" ).load( url( "mock.php?action=testHTML&baseURL=" + baseURL ), function() {
assert.ok( jQuery( "#first" ).html().match( /^html text/ ), "Check content after loading html" );
assert.strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" );
- assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" );
+ assert.strictEqual( window.testFoo, "foo", "Check if script was evaluated after load" );
setTimeout( verifyEvaluation, 600 );
} );
} );
@@ -3026,7 +3033,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery( "#first" ).load( url( "test2.html" ), function() {
assert.strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" );
- assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" );
+ assert.strictEqual( window.testFoo, "foo", "Check if script was evaluated after load" );
done();
} );
} );
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 7a272ffbe..b9647e6a7 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -239,7 +239,7 @@ QUnit.test( "attr(Hash)", function( assert ) {
assert.equal(
jQuery( "#text1" ).attr( {
"value": function() {
- return this[ "id" ];
+ return this.id;
} } ).attr( "value" ),
"text1",
"Set attribute to computed value #1"
@@ -394,11 +394,11 @@ QUnit.test( "attr(String, Object)", function( assert ) {
table = jQuery( "#table" ).append( "<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>" );
td = table.find( "td" ).eq( 0 );
td.attr( "rowspan", "2" );
- assert.equal( td[ 0 ][ "rowSpan" ], 2, "Check rowspan is correctly set" );
+ assert.equal( td[ 0 ].rowSpan, 2, "Check rowspan is correctly set" );
td.attr( "colspan", "2" );
- assert.equal( td[ 0 ][ "colSpan" ], 2, "Check colspan is correctly set" );
+ assert.equal( td[ 0 ].colSpan, 2, "Check colspan is correctly set" );
table.attr( "cellspacing", "2" );
- assert.equal( table[ 0 ][ "cellSpacing" ], "2", "Check cellspacing is correctly set" );
+ assert.equal( table[ 0 ].cellSpacing, "2", "Check cellspacing is correctly set" );
assert.equal( jQuery( "#area1" ).attr( "value" ), undefined, "Value attribute is distinct from value property." );
@@ -456,6 +456,7 @@ QUnit.test( "attr(String, Object)", function( assert ) {
$radio = jQuery( "<input>", {
"value": "sup",
+
// Use uppercase here to ensure the type
// attrHook is still used
"TYPE": "radio"
@@ -701,9 +702,9 @@ QUnit.test( "prop(String, Object) on null/undefined", function( assert ) {
$body = jQuery( body );
assert.ok( $body.prop( "nextSibling" ) === null, "Make sure a null expando returns null" );
- body[ "foo" ] = "bar";
+ body.foo = "bar";
assert.equal( $body.prop( "foo" ), "bar", "Make sure the expando is preferred over the dom attribute" );
- body[ "foo" ] = undefined;
+ body.foo = undefined;
assert.ok( $body.prop( "foo" ) === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
select = document.createElement( "select" );
@@ -848,7 +849,7 @@ QUnit.test( "removeProp(String)", function( assert ) {
obj = {};
assert.strictEqual(
- jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ][ "nonexisting" ],
+ jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ].nonexisting,
undefined,
"removeprop works correctly on DOM element nodes"
);
@@ -856,12 +857,12 @@ QUnit.test( "removeProp(String)", function( assert ) {
jQuery.each( [ document, obj ], function( i, ele ) {
var $ele = jQuery( ele );
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
- assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug trac-7500)." );
+ assert.strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug trac-7500)." );
} );
jQuery.each( [ commentNode, textNode, attributeNode ], function( i, ele ) {
var $ele = jQuery( ele );
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
- assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug trac-7500)." );
+ assert.strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug trac-7500)." );
} );
} );
@@ -1116,7 +1117,7 @@ QUnit.test( "val(select) after form.reset() (Bug trac-2551)", function( assert )
jQuery( "#kkk" ).val( "gf" );
- document[ "kk" ].reset();
+ document.kk.reset();
assert.equal( jQuery( "#kkk" )[ 0 ].value, "cf", "Check value of select after form reset." );
assert.equal( jQuery( "#kkk" ).val(), "cf", "Check value of select after form reset." );
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js
index 3f3dc15ec..36431cd5c 100644
--- a/test/unit/callbacks.js
+++ b/test/unit/callbacks.js
@@ -19,6 +19,7 @@ var output,
outputA = addToOutput( "A" ),
outputB = addToOutput( "B" ),
outputC = addToOutput( "C" ),
+ /* eslint-disable key-spacing */
tests = {
"": "XABC X XABCABCC X XBB X XABA X XX",
"once": "XABC X X X X X XABA X XX",
@@ -227,7 +228,9 @@ jQuery.each( tests, function( strFlags, resultString ) {
// Return false
output = "X";
cblist = jQuery.Callbacks( flags );
- cblist.add( outputA, function() { return false; }, outputB );
+ cblist.add( outputA, function() {
+ return false;
+ }, outputB );
cblist.add( outputA );
cblist.fire();
assert.strictEqual( output, results.shift(), "Callback returning false" );
@@ -269,7 +272,7 @@ QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert
fn = function() {
assert.ok( !( count++ ), "called once" );
};
- options[ "unique" ] = false;
+ options.unique = false;
cb.add( fn, fn );
cb.fire();
} );
@@ -364,7 +367,9 @@ QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", fun
var cb = jQuery.Callbacks(),
fired = false,
- shot = function() { fired = true; };
+ shot = function() {
+ fired = true;
+ };
cb.disable();
cb.empty();
@@ -379,8 +384,12 @@ QUnit.test( "jQuery.Callbacks() - list with memory stays locked (gh-3469)", func
var cb = jQuery.Callbacks( "memory" ),
fired = 0,
- count1 = function() { fired += 1; },
- count2 = function() { fired += 10; };
+ count1 = function() {
+ fired += 1;
+ },
+ count2 = function() {
+ fired += 10;
+ };
cb.add( count1 );
cb.fire();
diff --git a/test/unit/core.js b/test/unit/core.js
index 0029ee717..294664d5c 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -38,19 +38,21 @@ QUnit.test( "jQuery()", function( assert ) {
// few here but beware of modular builds where these methods may be excluded.
if ( includesModule( "deprecated" ) ) {
expected++;
- attrObj[ "click" ] = function() { assert.ok( exec, "Click executed." ); };
+ attrObj.click = function() {
+ assert.ok( exec, "Click executed." );
+ };
}
if ( includesModule( "dimensions" ) ) {
expected++;
- attrObj[ "width" ] = 10;
+ attrObj.width = 10;
}
if ( includesModule( "offset" ) ) {
expected++;
- attrObj[ "offset" ] = { "top": 1, "left": 1 };
+ attrObj.offset = { "top": 1, "left": 1 };
}
if ( includesModule( "css" ) ) {
expected += 2;
- attrObj[ "css" ] = { "paddingLeft": 1, "paddingRight": 1 };
+ attrObj.css = { "paddingLeft": 1, "paddingRight": 1 };
}
if ( includesModule( "attributes" ) ) {
expected++;
@@ -216,17 +218,17 @@ QUnit.test( "noConflict", function( assert ) {
var $$ = jQuery;
assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
- assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." );
- assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
+ assert.strictEqual( window.jQuery, $$, "Make sure jQuery wasn't touched." );
+ assert.strictEqual( window.$, original$, "Make sure $ was reverted." );
jQuery = $ = $$;
assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" );
- assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." );
- assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." );
+ assert.strictEqual( window.jQuery, originaljQuery, "Make sure jQuery was reverted." );
+ assert.strictEqual( window.$, original$, "Make sure $ was reverted." );
assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." );
- window[ "jQuery" ] = jQuery = $$;
+ window.jQuery = jQuery = $$;
} );
QUnit.test( "isPlainObject", function( assert ) {
@@ -274,7 +276,7 @@ QUnit.test( "isPlainObject", function( assert ) {
// Makes the function a little more realistic
// (and harder to detect, incidentally)
- fn.prototype[ "someMethod" ] = function() {};
+ fn.prototype.someMethod = function() {};
// Again, instantiated objects shouldn't be matched
assert.ok( !jQuery.isPlainObject( new fn() ), "new fn" );
@@ -431,10 +433,10 @@ QUnit.test( "XSS via location.hash", function( assert ) {
var done = assert.async();
assert.expect( 1 );
- jQuery[ "_check9521" ] = function( x ) {
+ jQuery._check9521 = function( x ) {
assert.ok( x, "script called from #id-like selector with inline handler" );
jQuery( "#check9521" ).remove();
- delete jQuery[ "_check9521" ];
+ delete jQuery._check9521;
done();
};
try {
@@ -442,7 +444,7 @@ QUnit.test( "XSS via location.hash", function( assert ) {
// This throws an error because it's processed like an id
jQuery( "#<img id='check9521' src='no-such-.gif' onerror='jQuery._check9521(false)'>" ).appendTo( "#qunit-fixture" );
} catch ( err ) {
- jQuery[ "_check9521" ]( true );
+ jQuery._check9521( true );
}
} );
@@ -451,12 +453,12 @@ QUnit.test( "jQuery('html')", function( assert ) {
var s, div, j;
- jQuery[ "foo" ] = false;
+ jQuery.foo = false;
s = jQuery( "<script>jQuery.foo='test';</script>" )[ 0 ];
assert.ok( s, "Creating a script" );
- assert.ok( !jQuery[ "foo" ], "Make sure the script wasn't executed prematurely" );
+ assert.ok( !jQuery.foo, "Make sure the script wasn't executed prematurely" );
jQuery( "body" ).append( "<script>jQuery.foo='test';</script>" );
- assert.ok( jQuery[ "foo" ], "Executing a script's contents in the right context" );
+ assert.ok( jQuery.foo, "Executing a script's contents in the right context" );
// Test multi-line HTML
div = jQuery( "<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>" )[ 0 ];
@@ -584,20 +586,20 @@ QUnit.test( "inArray()", function( assert ) {
assert.expect( 19 );
var selections = {
- p: q( "firstp", "sap", "ap", "first" ),
- em: q( "siblingnext", "siblingfirst" ),
+ p: q( "firstp", "sap", "ap", "first" ),
+ em: q( "siblingnext", "siblingfirst" ),
div: q( "qunit-testrunner-toolbar", "nothiddendiv", "nothiddendivchild", "foo" ),
- a: q( "mark", "groups", "google", "simon1" ),
+ a: q( "mark", "groups", "google", "simon1" ),
empty: []
},
tests = {
- p: { elem: jQuery( "#ap" )[ 0 ], index: 2 },
- em: { elem: jQuery( "#siblingfirst" )[ 0 ], index: 1 },
- div: { elem: jQuery( "#nothiddendiv" )[ 0 ], index: 1 },
- a: { elem: jQuery( "#simon1" )[ 0 ], index: 3 }
+ p: { elem: jQuery( "#ap" )[ 0 ], index: 2 },
+ em: { elem: jQuery( "#siblingfirst" )[ 0 ], index: 1 },
+ div: { elem: jQuery( "#nothiddendiv" )[ 0 ], index: 1 },
+ a: { elem: jQuery( "#simon1" )[ 0 ], index: 3 }
},
falseTests = {
- p: jQuery( "#liveSpan1" )[ 0 ],
+ p: jQuery( "#liveSpan1" )[ 0 ],
em: jQuery( "#nothiddendiv" )[ 0 ],
empty: ""
};
@@ -634,7 +636,9 @@ QUnit.test( "each(Function)", function( assert ) {
var div, pass, i;
div = jQuery( "div" );
- div.each( function() {this.foo = "zoo";} );
+ div.each( function() {
+this.foo = "zoo";
+} );
pass = true;
for ( i = 0; i < div.length; i++ ) {
if ( div.get( i ).foo !== "zoo" ) {
@@ -740,8 +744,12 @@ QUnit.test( "jQuery.map", function( assert ) {
result = {
Zero: function() {},
- One: function( a ) { a = a; },
- Two: function( a, b ) { a = a; b = b; }
+ One: function( a ) {
+ a = a;
+ },
+ Two: function( a, b ) {
+ a = a; b = b;
+ }
};
callback = function( v, k ) {
assert.equal( k, "foo", label + "-argument function treated like object" );
@@ -999,25 +1007,25 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) {
assert.deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
jQuery.extend( true, deep1, deep2 );
- assert.deepEqual( deep1[ "foo" ], deepmerged[ "foo" ], "Check if foo: settings must be extended" );
- assert.deepEqual( deep2[ "foo" ], deep2copy[ "foo" ], "Check if not deep2: options must not be modified" );
- assert.equal( deep1[ "foo2" ], document, "Make sure that a deep clone was not attempted on the document" );
+ assert.deepEqual( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
+ assert.deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
+ assert.equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
- assert.ok( jQuery.extend( true, {}, nestedarray )[ "arr" ] !== arr, "Deep extend of object must clone child array" );
+ assert.ok( jQuery.extend( true, {}, nestedarray ).arr !== arr, "Deep extend of object must clone child array" );
// trac-5991
- assert.ok( Array.isArray( jQuery.extend( true, { "arr": {} }, nestedarray )[ "arr" ] ), "Cloned array have to be an Array" );
- assert.ok( jQuery.isPlainObject( jQuery.extend( true, { "arr": arr }, { "arr": {} } )[ "arr" ] ), "Cloned object have to be an plain object" );
+ assert.ok( Array.isArray( jQuery.extend( true, { "arr": {} }, nestedarray ).arr ), "Cloned array have to be an Array" );
+ assert.ok( jQuery.isPlainObject( jQuery.extend( true, { "arr": arr }, { "arr": {} } ).arr ), "Cloned object have to be an plain object" );
empty = {};
optionsWithLength = { "foo": { "length": -1 } };
jQuery.extend( true, empty, optionsWithLength );
- assert.deepEqual( empty[ "foo" ], optionsWithLength[ "foo" ], "The length property must copy correctly" );
+ assert.deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
empty = {};
optionsWithDate = { "foo": { "date": new Date() } };
jQuery.extend( true, empty, optionsWithDate );
- assert.deepEqual( empty[ "foo" ], optionsWithDate[ "foo" ], "Dates copy correctly" );
+ assert.deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
/** @constructor */
myKlass = function() {};
@@ -1025,13 +1033,13 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) {
optionsWithCustomObject = { "foo": { "date": customObject } };
empty = {};
jQuery.extend( true, empty, optionsWithCustomObject );
- assert.ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly (no methods)" );
+ assert.ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly (no methods)" );
// Makes the class a little more realistic
myKlass.prototype = { "someMethod": function() {} };
empty = {};
jQuery.extend( true, empty, optionsWithCustomObject );
- assert.ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly" );
+ assert.ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly" );
MyNumber = Number;
@@ -1039,18 +1047,18 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) {
assert.ok( parseInt( ret.foo, 10 ) === 5, "Wrapped numbers copy correctly" );
nullUndef = jQuery.extend( {}, options, { "xnumber2": null } );
- assert.ok( nullUndef[ "xnumber2" ] === null, "Check to make sure null values are copied" );
+ assert.ok( nullUndef.xnumber2 === null, "Check to make sure null values are copied" );
nullUndef = jQuery.extend( {}, options, { "xnumber2": undefined } );
- assert.ok( nullUndef[ "xnumber2" ] === options[ "xnumber2" ], "Check to make sure undefined values are not copied" );
+ assert.ok( nullUndef.xnumber2 === options.xnumber2, "Check to make sure undefined values are not copied" );
nullUndef = jQuery.extend( {}, options, { "xnumber0": null } );
- assert.ok( nullUndef[ "xnumber0" ] === null, "Check to make sure null values are inserted" );
+ assert.ok( nullUndef.xnumber0 === null, "Check to make sure null values are inserted" );
target = {};
- recursive = { foo:target, bar:5 };
+ recursive = { foo: target, bar: 5 };
jQuery.extend( true, target, recursive );
- assert.deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
+ assert.deepEqual( target, { bar: 5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
ret = jQuery.extend( true, { foo: [] }, { foo: [ 0 ] } ); // 1907
assert.equal( ret.foo.length, 1, "Check to make sure a value with coercion 'false' copies over when necessary to fix trac-1907" );
@@ -1058,11 +1066,11 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) {
ret = jQuery.extend( true, { foo: "1,2,3" }, { foo: [ 1, 2, 3 ] } );
assert.ok( typeof ret.foo !== "string", "Check to make sure values equal with coercion (but not actually equal) overwrite correctly" );
- ret = jQuery.extend( true, { foo:"bar" }, { foo:null } );
+ ret = jQuery.extend( true, { foo: "bar" }, { foo: null } );
assert.ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for trac-1908" );
- obj = { foo:null };
- jQuery.extend( true, obj, { foo:"notnull" } );
+ obj = { foo: null };
+ jQuery.extend( true, obj, { foo: "notnull" } );
assert.equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
function func() {}
@@ -1172,8 +1180,12 @@ QUnit.test( "jQuery.each(Object,Function)", function( assert ) {
seen = {
Zero: function() {},
- One: function( a ) { a = a; },
- Two: function( a, b ) { a = a; b = b; }
+ One: function( a ) {
+ a = a;
+ },
+ Two: function( a, b ) {
+ a = a; b = b;
+ }
};
callback = function( k ) {
assert.equal( k, "foo", label + "-argument function treated like object" );
@@ -1282,7 +1294,9 @@ QUnit.test( "jQuery.makeArray", function( assert ) {
assert.equal( jQuery.makeArray( document.getElementsByName( "PWD" ) ).slice( 0, 1 )[ 0 ].name, "PWD", "Pass makeArray a nodelist" );
- assert.equal( ( function() { return jQuery.makeArray( arguments ); } )( 1, 2 ).join( "" ), "12", "Pass makeArray an arguments array" );
+ 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" );
@@ -1296,12 +1310,14 @@ QUnit.test( "jQuery.makeArray", function( assert ) {
assert.equal( jQuery.makeArray( document.createElement( "div" ) )[ 0 ].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" );
- assert.equal( jQuery.makeArray( { length:2, 0:"a", 1:"b" } ).join( "" ), "ab", "Pass makeArray an array like map (with length)" );
+ assert.equal( jQuery.makeArray( { length: 2, 0: "a", 1: "b" } ).join( "" ), "ab", "Pass makeArray an array like map (with length)" );
assert.ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice( 0, 1 )[ 0 ].nodeName, "Pass makeArray a childNodes array" );
// function, is tricky as it has length
- assert.equal( jQuery.makeArray( function() { return 1;} )[ 0 ](), 1, "Pass makeArray a function" );
+ assert.equal( jQuery.makeArray( function() {
+ return 1;
+ } )[ 0 ](), 1, "Pass makeArray a function" );
//window, also has length
assert.equal( jQuery.makeArray( window )[ 0 ], window, "Pass makeArray the window" );
@@ -1327,7 +1343,7 @@ QUnit.test( "jQuery.isEmptyObject", function( assert ) {
assert.expect( 2 );
assert.equal( true, jQuery.isEmptyObject( {} ), "isEmptyObject on empty object literal" );
- assert.equal( false, jQuery.isEmptyObject( { a:1 } ), "isEmptyObject on non-empty object literal" );
+ assert.equal( false, jQuery.isEmptyObject( { a: 1 } ), "isEmptyObject on non-empty object literal" );
// What about this ?
// equal(true, jQuery.isEmptyObject(null), "isEmptyObject on null" );
diff --git a/test/unit/css.js b/test/unit/css.js
index 7ba147a5e..31d043544 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -38,7 +38,7 @@ QUnit.test( "css(String|Hash)", function( assert ) {
width = parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) );
height = parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) );
- jQuery( "#nothiddendiv" ).css( { "overflow":"hidden", "width": -1, "height": -1 } );
+ jQuery( "#nothiddendiv" ).css( { "overflow": "hidden", "width": -1, "height": -1 } );
assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ), 0, "Test negative width set to 0" );
assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ), 0, "Test negative height set to 0" );
@@ -321,8 +321,7 @@ QUnit.test( "css(String, Object)", function( assert ) {
success = true;
try {
jQuery( "#foo" ).css( "backgroundColor", "rgba(0, 0, 0, 0.1)" );
- }
- catch ( e ) {
+ } catch ( e ) {
success = false;
}
assert.ok( success, "Setting RGBA values does not throw Error (trac-5509)" );
@@ -1203,6 +1202,7 @@ QUnit.test( "Do not append px (trac-9548, trac-12990, gh-2792)", function( asser
$div.css( "animation-iteration-count", 2 );
if ( $div.css( "animation-iteration-count" ) !== undefined ) {
+
// if $div.css( "animation-iteration-count" ) return "1",
// it actually return the default value of animation-iteration-count
assert.equal( $div.css( "animation-iteration-count" ), 2, "Do not append px to 'animation-iteration-count'" );
@@ -1714,7 +1714,7 @@ QUnit.test( "Do not throw on frame elements from css method (trac-15098)", funct
if ( transformName ) {
assert.equal( elemStyle[ transformName ], transformVal, "setting properly-prefixed transform" );
}
- assert.equal( elemStyle[ "undefined" ], undefined, "Nothing writes to node.style.undefined" );
+ assert.equal( elemStyle.undefined, undefined, "Nothing writes to node.style.undefined" );
} );
QUnit.test( "Don't detect fake set properties on a node when caching the prefixed version", function( assert ) {
@@ -1829,6 +1829,7 @@ QUnit.testUnlessIE( "Don't append px to CSS vars", function( assert ) {
// Support: IE 11+
// This test requires Grid to be *not supported* to work.
if ( QUnit.isIE ) {
+
// Make sure explicitly provided IE vendor prefix (`-ms-`) is not converted
// to a non-working `Ms` prefix in JavaScript.
QUnit.test( "IE vendor prefixes are not mangled", function( assert ) {
diff --git a/test/unit/data.js b/test/unit/data.js
index 2a7db8146..98973c6ed 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -74,14 +74,14 @@ function dataTests( elem, assert ) {
assert.strictEqual( jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
- dataObj[ "foo" ] = "bar";
+ dataObj.foo = "bar";
assert.equal( jQuery.data( elem, "foo" ), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
assert.strictEqual( jQuery.hasData( elem ), true, "jQuery.hasData agrees data exists when data exists" );
jQuery.data( elem, "foo", "baz" );
assert.equal( jQuery.data( elem, "foo" ), "baz", "Data can be changed by jQuery.data" );
- assert.equal( dataObj[ "foo" ], "baz", "Changes made through jQuery.data propagate to referenced data object" );
+ assert.equal( dataObj.foo, "baz", "Changes made through jQuery.data propagate to referenced data object" );
jQuery.data( elem, "foo", undefined );
assert.equal( jQuery.data( elem, "foo" ), "baz", "Data is not unset by passing undefined to jQuery.data" );
@@ -398,7 +398,7 @@ QUnit.test( "data-* attributes", function( assert ) {
break;
case 2:
assert.equal( jQuery( elem ).data( "zoooo" ), "bar", "Check zoooo property" );
- assert.deepEqual( jQuery( elem ).data( "bar" ), { "test":"baz" }, "Check bar property" );
+ assert.deepEqual( jQuery( elem ).data( "bar" ), { "test": "baz" }, "Check bar property" );
break;
case 3:
assert.equal( jQuery( elem ).data( "number" ), true, "Check number property" );
@@ -426,13 +426,13 @@ QUnit.test( ".data(Object)", function( assert ) {
assert.equal( div.data( "test" ), "in", "Verify setting an object in data" );
assert.equal( div.data( "test2" ), "in2", "Verify setting an object in data" );
- obj = { test:"unset" };
+ obj = { test: "unset" };
jqobj = jQuery( obj );
jqobj.data( "test", "unset" );
jqobj.data( { "test": "in", "test2": "in2" } );
- assert.equal( jQuery.data( obj )[ "test" ], "in", "Verify setting an object on an object extends the data object" );
- assert.equal( obj[ "test2" ], undefined, "Verify setting an object on an object does not extend the object" );
+ assert.equal( jQuery.data( obj ).test, "in", "Verify setting an object on an object extends the data object" );
+ assert.equal( obj.test2, undefined, "Verify setting an object on an object does not extend the object" );
// manually clean up detached elements
div.remove();
@@ -521,12 +521,12 @@ QUnit.test( ".data should follow html5 specification regarding camel casing", fu
var div = jQuery( "<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>" )
.prependTo( "body" );
- assert.equal( div.data()[ "wTF" ], "ftw", "Verify single letter data-* key" );
- assert.equal( div.data()[ "bigALittleA" ], "bouncing-b", "Verify single letter mixed data-* key" );
+ assert.equal( div.data().wTF, "ftw", "Verify single letter data-* key" );
+ assert.equal( div.data().bigALittleA, "bouncing-b", "Verify single letter mixed data-* key" );
- assert.equal( div.data()[ "foo" ], "a", "Verify single word data-* key" );
- assert.equal( div.data()[ "fooBar" ], "b", "Verify multiple word data-* key" );
- assert.equal( div.data()[ "fooBarBaz" ], "c", "Verify multiple word data-* key" );
+ assert.equal( div.data().foo, "a", "Verify single word data-* key" );
+ assert.equal( div.data().fooBar, "b", "Verify multiple word data-* key" );
+ assert.equal( div.data().fooBarBaz, "c", "Verify multiple word data-* key" );
assert.equal( div.data( "foo" ), "a", "Verify single word data-* key" );
assert.equal( div.data( "fooBar" ), "b", "Verify multiple word data-* key" );
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index 2c791cd1c..45c94fd1d 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -108,7 +108,9 @@ QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
piped = defer.then( function( a, b ) {
return a * b;
} ),
- done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 3 ), function() {
+ return assert.async();
+ } );
piped.done( function( result ) {
value3 = result;
@@ -145,7 +147,9 @@ QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
piped = defer.then( null, function( a, b ) {
return a * b;
} ),
- done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 3 ), function() {
+ return assert.async();
+ } );
piped.done( function( result ) {
value3 = result;
@@ -181,7 +185,9 @@ QUnit.test( "jQuery.Deferred.catch", function( assert ) {
piped = defer.catch( function( a, b ) {
return a * b;
} ),
- done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 3 ), function() {
+ return assert.async();
+ } );
piped.done( function( result ) {
value3 = result;
@@ -218,7 +224,9 @@ QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( ass
piped = defer.pipe( null, function( a, b ) {
return a * b;
} ),
- done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 3 ), function() {
+ return assert.async();
+ } );
piped.fail( function( result ) {
value3 = result;
@@ -416,7 +424,9 @@ QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
var defer, piped, defer2, piped2,
context = { custom: true },
- done = jQuery.map( new Array( 5 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 5 ), function() {
+ return assert.async();
+ } );
jQuery.Deferred().resolveWith( context, [ 2 ] ).then( function( value ) {
assert.strictEqual( this, context, "custom context received by .then handler" );
@@ -475,7 +485,9 @@ QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
var defer, piped, defer2, piped2,
context = { custom: true },
- done = jQuery.map( new Array( 5 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 5 ), function() {
+ return assert.async();
+ } );
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe( function( value ) {
assert.strictEqual( this, context, "custom context received by .pipe handler" );
@@ -642,7 +654,9 @@ QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
var context = { id: "callback context" },
thenable = jQuery.Deferred().resolve( "thenable fulfillment" ).promise(),
- done = jQuery.map( new Array( 8 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 8 ), function() {
+ return assert.async();
+ } );
thenable.unwrapped = false;
@@ -693,7 +707,9 @@ QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert )
var trigger = jQuery.Deferred().notify(),
expectedProgress = [ "baz", "baz" ],
- done = jQuery.map( new Array( 2 ), function() { return assert.async(); } ),
+ done = jQuery.map( new Array( 2 ), function() {
+ return assert.async();
+ } ),
failer = function( evt ) {
return function() {
assert.ok( false, "no unexpected " + evt );
@@ -718,7 +734,9 @@ QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
assert.expect( 7 );
var notifiedResolved = jQuery.Deferred().notify( "foo" )/*xxx .resolve( "bar" )*/,
- done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
+ done = jQuery.map( new Array( 3 ), function() {
+ return assert.async();
+ } );
notifiedResolved.progress( function( v ) {
assert.strictEqual( v, "foo", "progress value" );
@@ -798,7 +816,9 @@ QUnit.test( "jQuery.when(nonThenable) - like Promise.resolve", function( assert
assert.expect( 44 );
- var defaultContext = ( function getDefaultContext() { return this; } )(),
+ var defaultContext = ( function getDefaultContext() {
+ return this;
+ } )(),
done = assert.async( 20 );
@@ -914,7 +934,9 @@ QUnit.test( "jQuery.when(thenable) - like Promise.resolve", function( assert ) {
},
numCases = Object.keys( willSucceed ).length + Object.keys( willError ).length,
- defaultContext = ( function getDefaultContext() { return this; } )(),
+ defaultContext = ( function getDefaultContext() {
+ return this;
+ } )(),
done = assert.async( numCases * 2 );
@@ -992,7 +1014,9 @@ QUnit.test( "jQuery.when(a, b) - like Promise.all", function( assert ) {
rejectedStandardPromise: true
},
- defaultContext = ( function getDefaultContext() { return this; } )(),
+ defaultContext = ( function getDefaultContext() {
+ return this;
+ } )(),
done = assert.async( 98 );
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index bddd40105..7958ca450 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -46,8 +46,12 @@ QUnit.test( "hover() mouseenter mouseleave", function( assert ) {
assert.expect( 1 );
var times = 0,
- handler1 = function() { ++times; },
- handler2 = function() { ++times; };
+ handler1 = function() {
+ ++times;
+},
+ handler2 = function() {
+ ++times;
+};
jQuery( "#firstp" )
.hover( handler1, handler2 )
diff --git a/test/unit/effects.js b/test/unit/effects.js
index b3c86c382..8f6492124 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -8,8 +8,12 @@ if ( !includesModule( "effects" ) ) {
var fxInterval = 13,
oldRaf = window.requestAnimationFrame,
hideOptions = {
- inline: function() { jQuery.style( this, "display", "none" ); },
- cascade: function() { this.className = "hidden"; }
+ inline: function() {
+ jQuery.style( this, "display", "none" );
+ },
+ cascade: function() {
+ this.className = "hidden";
+ }
};
QUnit.module( "effects", {
@@ -540,12 +544,12 @@ 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" );
- $elems.eq( 0 ).animate( { a:1 }, 0, function() {
+ $elems.eq( 0 ).animate( { a: 1 }, 0, function() {
assert.ok( true, "Animate a simple property." );
counter++;
} );
@@ -555,18 +559,18 @@ QUnit.test( "animate duration 0", function( assert ) {
assert.equal( counter, 1, "One synchronic animations" );
- $elems.animate( { a:2 }, 0, function() {
+ $elems.animate( { a: 2 }, 0, function() {
assert.ok( true, "Animate a second simple property." );
counter++;
} );
assert.equal( counter, 3, "Multiple synchronic animations" );
- $elems.eq( 0 ).animate( { a:3 }, 0, function() {
+ $elems.eq( 0 ).animate( { a: 3 }, 0, function() {
assert.ok( true, "Animate a third simple property." );
counter++;
} );
- $elems.eq( 1 ).animate( { a:3 }, fxInterval * 20, function() {
+ $elems.eq( 1 ).animate( { a: 3 }, fxInterval * 20, function() {
counter++;
// Failed until [6115]
@@ -948,15 +952,33 @@ jQuery.each( {
num = 0;
// TODO: uncrowd this
- if ( t_h === "show" ) { num++; }
- if ( t_w === "show" ) { num++; }
- if ( t_w === "hide" || t_w === "show" ) { num++; }
- if ( t_h === "hide" || t_h === "show" ) { num++; }
- if ( t_o === "hide" || t_o === "show" ) { num++; }
- 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 === "show" ) {
+ num++;
+ }
+ if ( t_w === "show" ) {
+ num++;
+ }
+ if ( t_w === "hide" || t_w === "show" ) {
+ num++;
+ }
+ if ( t_h === "hide" || t_h === "show" ) {
+ num++;
+ }
+ if ( t_o === "hide" || t_o === "show" ) {
+ num++;
+ }
+ 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;
+ }
assert.expect( num );
@@ -2457,7 +2479,9 @@ QUnit.test( "Show/hide/toggle and display: inline", function( assert ) {
.hide().show( N ),
$el.clone().data( { call: "hide+toggle", done: "inline" } ).appendTo( fixture )
.hide().toggle( N )
- ], function( $clone ) { return $clone[ 0 ]; } );
+ ], function( $clone ) {
+ return $clone[ 0 ];
+ } );
// Animations not allowed to complete
interrupted = jQuery.map( [
@@ -2465,7 +2489,9 @@ QUnit.test( "Show/hide/toggle and display: inline", function( assert ) {
$el.clone().data( { call: "toggle+stop" } ).appendTo( fixture ).toggle( N ),
$el.clone().data( { call: "hide+show+stop" } ).appendTo( fixture ).hide().show( N ),
$el.clone().data( { call: "hide+toggle+stop" } ).appendTo( fixture ).hide().toggle( N )
- ], function( $clone ) { return $clone[ 0 ]; } );
+ ], function( $clone ) {
+ return $clone[ 0 ];
+ } );
// All elements should be inline-block during the animation
clock.tick( N / 2 );
diff --git a/test/unit/event.js b/test/unit/event.js
index 920b2a182..2d49aa10c 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -224,12 +224,12 @@ QUnit.test( "on(), namespace with special add", function( assert ) {
div.on( "test.a", { x: 1 }, function( e ) {
assert.ok( !!e.xyz, "Make sure that the data is getting passed through." );
- assert.equal( e.data[ "x" ], 1, "Make sure data is attached properly." );
+ assert.equal( e.data.x, 1, "Make sure data is attached properly." );
} );
div.on( "test.b", { x: 2 }, function( e ) {
assert.ok( !!e.xyz, "Make sure that the data is getting passed through." );
- assert.equal( e.data[ "x" ], 2, "Make sure data is attached properly." );
+ assert.equal( e.data.x, 2, "Make sure data is attached properly." );
} );
// Should trigger 5
@@ -293,14 +293,14 @@ QUnit.test( "on/one/off(Object)", function( assert ) {
// Regular bind
.on( {
- "click":handler,
- "mouseover":handler
+ "click": handler,
+ "mouseover": handler
} )
// Bind with data
.one( {
- "click":handlerWithData,
- "mouseover":handlerWithData
+ "click": handlerWithData,
+ "mouseover": handlerWithData
}, 2 );
trigger();
@@ -313,8 +313,8 @@ QUnit.test( "on/one/off(Object)", function( assert ) {
assert.equal( mouseoverCounter, 4, "on(Object)" );
jQuery( "#firstp" ).off( {
- "click":handler,
- "mouseover":handler
+ "click": handler,
+ "mouseover": handler
} );
trigger();
@@ -553,7 +553,9 @@ QUnit.test( "on(), namespaced events, cloned events", function( assert ) {
} ).trigger( "tester" );
// Make sure events stick with appendTo'd elements (which are cloned) trac-2027
- jQuery( "<a href='#fail' class='test'>test</a>" ).on( "click", function() { return false; } ).appendTo( "#qunit-fixture" );
+ jQuery( "<a href='#fail' class='test'>test</a>" ).on( "click", function() {
+ return false;
+ } ).appendTo( "#qunit-fixture" );
assert.ok( jQuery( "a.test" ).eq( 0 ).triggerHandler( "click" ) === false, "Handler is bound to appendTo'd elements" );
} );
@@ -704,7 +706,9 @@ QUnit.test( "on(name, false), off(name, false)", function( assert ) {
assert.expect( 3 );
var main = 0;
- jQuery( "#qunit-fixture" ).on( "click", function() { main++; } );
+ jQuery( "#qunit-fixture" ).on( "click", function() {
+ main++;
+ } );
jQuery( "#ap" ).trigger( "click" );
assert.equal( main, 1, "Verify that the trigger happened correctly." );
@@ -727,7 +731,9 @@ QUnit.test( "on(name, selector, false), off(name, selector, false)", function( a
var main = 0;
- jQuery( "#qunit-fixture" ).on( "click", "#ap", function() { main++; } );
+ jQuery( "#qunit-fixture" ).on( "click", "#ap", function() {
+ main++;
+ } );
jQuery( "#ap" ).trigger( "click" );
assert.equal( main, 1, "Verify that the trigger happened correctly." );
@@ -766,7 +772,7 @@ QUnit.test( "on()/trigger()/off() on plain object", function( assert ) {
events = jQuery._data( obj, "events" );
assert.ok( events, "Object has events bound." );
- assert.equal( obj[ "events" ], undefined, "Events object on plain objects is not events" );
+ assert.equal( obj.events, undefined, "Events object on plain objects is not events" );
assert.equal( obj.test, undefined, "Make sure that test event is not on the plain object." );
assert.equal( obj.handle, undefined, "Make sure that the event handler is not on the plain object." );
@@ -785,7 +791,7 @@ QUnit.test( "on()/trigger()/off() on plain object", function( assert ) {
assert.equal( obj && obj[ jQuery.expando ] &&
obj[ jQuery.expando ][ jQuery.expando ] &&
- obj[ jQuery.expando ][ jQuery.expando ][ "events" ], undefined, "Make sure events object is removed" );
+ obj[ jQuery.expando ][ jQuery.expando ].events, undefined, "Make sure events object is removed" );
} );
QUnit.test( "off(type)", function( assert ) {
@@ -938,12 +944,26 @@ QUnit.test( "trigger() bubbling", function( assert ) {
var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0;
- jQuery( window ).on( "click", function() { win++; } );
- jQuery( document ).on( "click", function( e ) { if ( e.target !== document ) { doc++; } } );
- jQuery( "html" ).on( "click", function() { html++; } );
- jQuery( "body" ).on( "click", function() { body++; } );
- jQuery( "#qunit-fixture" ).on( "click", function() { main++; } );
- jQuery( "#ap" ).on( "click", function() { ap++; return false; } );
+ jQuery( window ).on( "click", function() {
+ win++;
+ } );
+ jQuery( document ).on( "click", function( e ) {
+ if ( e.target !== document ) {
+ doc++;
+ }
+ } );
+ jQuery( "html" ).on( "click", function() {
+ html++;
+ } );
+ jQuery( "body" ).on( "click", function() {
+ body++;
+ } );
+ jQuery( "#qunit-fixture" ).on( "click", function() {
+ main++;
+ } );
+ jQuery( "#ap" ).on( "click", function() {
+ ap++; return false;
+ } );
jQuery( "html" ).trigger( "click" );
assert.equal( win, 1, "HTML bubble" );
@@ -1159,7 +1179,9 @@ QUnit.test( "trigger(eventObject, [data], [fn])", function( assert ) {
event.stopPropagation();
assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
- event.isPropagationStopped = function() { return false; };
+ event.isPropagationStopped = function() {
+ return false;
+ };
event.stopImmediatePropagation();
assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
assert.equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
@@ -1394,7 +1416,9 @@ QUnit.test( "Submit event can be stopped (trac-11049)", function( assert ) {
return false;
} )
.find( "#myform input[type=submit]" )
- .each( function() { this.click(); } )
+ .each( function() {
+ this.click();
+ } )
.end()
.on( "submit", function() {
assert.ok( false, "submit bubbled on second handler" );
@@ -1506,10 +1530,18 @@ QUnit.test( ".on()/.off()", function( assert ) {
var event, clicked, hash, called, livec, lived, livee,
submit = 0, div = 0, livea = 0, liveb = 0;
- jQuery( "#body" ).on( "submit", "#qunit-fixture div", function() { submit++; return false; } );
- jQuery( "#body" ).on( "click", "#qunit-fixture div", function() { div++; } );
- jQuery( "#body" ).on( "click", "div#nothiddendiv", function() { livea++; } );
- jQuery( "#body" ).on( "click", "div#nothiddendivchild", function() { liveb++; } );
+ jQuery( "#body" ).on( "submit", "#qunit-fixture div", function() {
+ submit++; return false;
+ } );
+ jQuery( "#body" ).on( "click", "#qunit-fixture div", function() {
+ div++;
+ } );
+ jQuery( "#body" ).on( "click", "div#nothiddendiv", function() {
+ livea++;
+} );
+ jQuery( "#body" ).on( "click", "div#nothiddendivchild", function() {
+ liveb++;
+ } );
// Nothing should trigger on the body
jQuery( "body" ).trigger( "click" );
@@ -1569,7 +1601,9 @@ QUnit.test( ".on()/.off()", function( assert ) {
// Make sure that stopPropagation doesn't stop live events
submit = 0; div = 0; livea = 0; liveb = 0;
- jQuery( "#body" ).on( "click", "div#nothiddendivchild", function( e ) { liveb++; e.stopPropagation(); } );
+ jQuery( "#body" ).on( "click", "div#nothiddendivchild", function( e ) {
+ liveb++; e.stopPropagation();
+ } );
jQuery( "div#nothiddendivchild" ).trigger( "click" );
assert.equal( submit, 0, "stopPropagation Click on inner div" );
assert.equal( div, 1, "stopPropagation Click on inner div" );
@@ -1591,7 +1625,9 @@ QUnit.test( ".on()/.off()", function( assert ) {
// Test binding with a different context
clicked = 0;
- jQuery( "#qunit-fixture" ).on( "click", "#foo", function() { clicked++; } );
+ jQuery( "#qunit-fixture" ).on( "click", "#foo", function() {
+ clicked++;
+ } );
jQuery( "#qunit-fixture div" ).trigger( "click" );
jQuery( "#foo" ).trigger( "click" );
jQuery( "#qunit-fixture" ).trigger( "click" );
@@ -1635,14 +1671,18 @@ QUnit.test( ".on()/.off()", function( assert ) {
jQuery( "#body" ).off( "click", "#foo" );
// Verify that return false prevents default action
- jQuery( "#body" ).on( "click", "#anchor2", function() { return false; } );
+ jQuery( "#body" ).on( "click", "#anchor2", function() {
+ return false;
+ } );
hash = window.location.hash;
jQuery( "#anchor2" ).trigger( "click" );
assert.equal( window.location.hash, hash, "return false worked" );
jQuery( "#body" ).off( "click", "#anchor2" );
// Verify that .preventDefault() prevents default action
- jQuery( "#body" ).on( "click", "#anchor2", function( e ) { e.preventDefault(); } );
+ jQuery( "#body" ).on( "click", "#anchor2", function( e ) {
+ e.preventDefault();
+ } );
hash = window.location.hash;
jQuery( "#anchor2" ).trigger( "click" );
assert.equal( window.location.hash, hash, "e.preventDefault() worked" );
@@ -1650,7 +1690,9 @@ QUnit.test( ".on()/.off()", function( assert ) {
// Test binding the same handler to multiple points
called = 0;
- function callback() { called++; return false; }
+ function callback() {
+ called++; return false;
+ }
jQuery( "#body" ).on( "click", "#nothiddendiv", callback );
jQuery( "#body" ).on( "click", "#anchor2", callback );
@@ -1696,8 +1738,14 @@ QUnit.test( ".on()/.off()", function( assert ) {
livec = 0;
jQuery( "#nothiddendivchild" ).html( "<span></span>" );
- jQuery( "#body" ).on( "click", "#nothiddendivchild", function() { jQuery( "#nothiddendivchild" ).html( "" ); } );
- jQuery( "#body" ).on( "click", "#nothiddendivchild", function( e ) { if ( e.target ) {livec++;} } );
+ jQuery( "#body" ).on( "click", "#nothiddendivchild", function() {
+ jQuery( "#nothiddendivchild" ).html( "" );
+ } );
+ jQuery( "#body" ).on( "click", "#nothiddendivchild", function( e ) {
+ if ( e.target ) {
+ livec++;
+ }
+ } );
jQuery( "#nothiddendiv span" ).trigger( "click" );
assert.equal( jQuery( "#nothiddendiv span" ).length, 0, "Verify that first handler occurred and modified the DOM." );
@@ -1712,16 +1760,26 @@ QUnit.test( ".on()/.off()", function( assert ) {
livee = 0;
// bind one pair in one order
- jQuery( "#body" ).on( "click", "span#liveSpan1 a", function() { lived++; return false; } );
- jQuery( "#body" ).on( "click", "span#liveSpan1", function() { livee++; } );
+ jQuery( "#body" ).on( "click", "span#liveSpan1 a", function() {
+ lived++;
+ return false;
+ } );
+ jQuery( "#body" ).on( "click", "span#liveSpan1", function() {
+ livee++;
+ } );
jQuery( "span#liveSpan1 a" ).trigger( "click" );
assert.equal( lived, 1, "Verify that only one first handler occurred." );
assert.equal( livee, 0, "Verify that second handler doesn't." );
// and one pair in inverse
- jQuery( "#body" ).on( "click", "span#liveSpan2", function() { livee++; } );
- jQuery( "#body" ).on( "click", "span#liveSpan2 a", function() { lived++; return false; } );
+ jQuery( "#body" ).on( "click", "span#liveSpan2", function() {
+ livee++;
+ } );
+ jQuery( "#body" ).on( "click", "span#liveSpan2 a", function() {
+ lived++;
+ return false;
+ } );
lived = 0;
livee = 0;
@@ -1747,11 +1805,17 @@ QUnit.test( ".on()/.off()", function( assert ) {
// Work with deep selectors
livee = 0;
- function clickB() { livee++; }
+ function clickB() {
+ livee++;
+ }
- jQuery( "#body" ).on( "click", "#nothiddendiv div", function() { livee++; } );
+ jQuery( "#body" ).on( "click", "#nothiddendiv div", function() {
+ livee++;
+ } );
jQuery( "#body" ).on( "click", "#nothiddendiv div", clickB );
- jQuery( "#body" ).on( "mouseover", "#nothiddendiv div", function() { livee++; } );
+ jQuery( "#body" ).on( "mouseover", "#nothiddendiv div", function() {
+ livee++;
+ } );
assert.equal( livee, 0, "No clicks, deep selector." );
@@ -1825,6 +1889,7 @@ QUnit.test( "events with type matching an Object.prototype property, cloned elem
elem.appendTo( "#qunit-fixture" );
try {
+
// Make sure the original element has some event data.
elem.on( "click", function() {} );
@@ -1859,6 +1924,7 @@ QUnit[ QUnit.jQuerySelectors ? "test" : "skip" ]( "delegated event with delegate
.off( "click" );
if ( QUnit.jQuerySelectorsPos ) {
+
// Positional selector (trac-11315)
markup.find( "ul" ).eq( 0 )
.on( "click", ">li>a", function() {
@@ -1954,8 +2020,12 @@ QUnit.test( "off all bound delegated events", function( assert ) {
clicks = 0,
div = jQuery( "#body" );
- div.on( "click submit", "div#nothiddendivchild", function() { count++; } );
- div.on( "click", function() { clicks++; } );
+ div.on( "click submit", "div#nothiddendivchild", function() {
+ count++;
+ } );
+ div.on( "click", function() {
+ clicks++;
+ } );
div.off( undefined, "**" );
jQuery( "div#nothiddendivchild" ).trigger( "click" );
@@ -1974,7 +2044,9 @@ QUnit.test( "on with multiple delegated events", function( assert ) {
var count = 0,
div = jQuery( "#body" );
- div.on( "click submit", "div#nothiddendivchild", function() { count++; } );
+ div.on( "click submit", "div#nothiddendivchild", function() {
+ count++;
+ } );
jQuery( "div#nothiddendivchild" ).trigger( "click" );
jQuery( "div#nothiddendivchild" ).trigger( "submit" );
@@ -2329,7 +2401,7 @@ QUnit.test( ".on and .off", function( assert ) {
// We should have removed all the event handlers ... kinda hacky way to check this
data = jQuery.data[ jQuery( "#onandoff" )[ 0 ].expando ] || {};
- assert.equal( data[ "events" ], undefined, "no events left" );
+ assert.equal( data.events, undefined, "no events left" );
$onandoff.remove();
} );
@@ -2403,7 +2475,7 @@ QUnit.test( "special on name mapping", function( assert ) {
.trigger( "gutfeeling" ) // This one should not
.remove();
- delete jQuery.event.special[ "gutfeeling" ];
+ delete jQuery.event.special.gutfeeling;
} );
QUnit.test( ".on and .off, selective mixed removal (trac-10705)", function( assert ) {
@@ -2564,7 +2636,9 @@ QUnit.test( "addProp extensions", function( assert ) {
fireNative( $fixture[ 0 ], "click" );
$fixture.off( "click" );
- jQuery.event.addProp( "testProperty", function() { return 42; } );
+ jQuery.event.addProp( "testProperty", function() {
+ return 42;
+ } );
// Trigger a native click and ensure the property is set
$fixture.on( "click", function( event ) {
@@ -3393,6 +3467,7 @@ QUnit.test( "focus change during a focus handler (gh-4382)", function( assert )
} );
jQuery( document ).on( "focusin.focusTests", function( ev ) {
+
// Support: IE 11+
// In IE focus is async so focusin on document is fired multiple times,
// for each of the elements. In other browsers it's fired just once, for
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index edb0ff2c0..e197712fb 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1325,9 +1325,13 @@ QUnit.test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function( ass
jQuery.each( tests, function( label, input ) {
$el.html( "<a></a>" ).children().replaceWith( input );
assert.strictEqual( $el.html(), "", "replaceWith(" + label + ")" );
- $el.html( "<b></b>" ).children().replaceWith( function() { return input; } );
+ $el.html( "<b></b>" ).children().replaceWith( function() {
+ return input;
+ } );
assert.strictEqual( $el.html(), "", "replaceWith(function returning " + label + ")" );
- $el.html( "<i></i>" ).children().replaceWith( function( i ) { return input; } );
+ $el.html( "<i></i>" ).children().replaceWith( function( i ) {
+ return input;
+ } );
assert.strictEqual( $el.html(), "", "replaceWith(other function returning " + label + ")" );
$el.html( "<p></p>" ).children().replaceWith( function( i ) {
return i ?
@@ -1567,7 +1571,9 @@ QUnit.test( "clone(form element) (Bug trac-3879, trac-6655)", function( assert )
element = jQuery( "<select><option>Foo</option><option value='selected' selected>Bar</option></select>" );
- assert.equal( element.clone().find( "option" ).filter( function() { return this.selected; } ).val(), "selected", "Selected option cloned correctly" );
+ assert.equal( element.clone().find( "option" ).filter( function() {
+ return this.selected;
+ } ).val(), "selected", "Selected option cloned correctly" );
element = jQuery( "<input type='checkbox' value='foo'>" ).attr( "checked", "checked" );
clone = element.clone();
@@ -2217,8 +2223,7 @@ QUnit.test( "domManip plain-text caching (trac-6779)", function( assert ) {
for ( i = 0; i < bad.length; i++ ) {
try {
$f.append( bad[ i ] );
- }
- catch ( e ) {}
+ } catch ( e ) {}
}
assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" );
$f.remove();
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 69b075df5..73ec8928f 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -165,9 +165,9 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
// get offset tests
tests = [
- { "id": "#absolute-1", "top": 1, "left": 1 },
- { "id": "#absolute-1-1", "top": 5, "left": 5 },
- { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
+ { "id": "#absolute-1", "top": 1, "left": 1 },
+ { "id": "#absolute-1-1", "top": 5, "left": 5 },
+ { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
{ "id": "#absolute-2", "top": 20, "left": 20 }
];
jQuery.each( tests, function() {
@@ -177,9 +177,9 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
// get position
tests = [
- { "id": "#absolute-1", "top": 0, "left": 0 },
- { "id": "#absolute-1-1", "top": 1, "left": 1 },
- { "id": "#absolute-1-1-1", "top": 1, "left": 1 },
+ { "id": "#absolute-1", "top": 0, "left": 0 },
+ { "id": "#absolute-1-1", "top": 1, "left": 1 },
+ { "id": "#absolute-1-1-1", "top": 1, "left": 1 },
{ "id": "#absolute-2", "top": 19, "left": 19 }
];
jQuery.each( tests, function() {
@@ -199,17 +199,17 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
{ "id": "#absolute-2", "top": -1, "left": -1 },
{ "id": "#absolute-2", "top": 19, "left": 19 },
{ "id": "#absolute-1-1-1", "top": 15, "left": 15 },
- { "id": "#absolute-1-1-1", "top": 5, "left": 5 },
+ { "id": "#absolute-1-1-1", "top": 5, "left": 5 },
{ "id": "#absolute-1-1-1", "top": -1, "left": -1 },
- { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
+ { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
{ "id": "#absolute-1-1", "top": 10, "left": 10 },
- { "id": "#absolute-1-1", "top": 0, "left": 0 },
+ { "id": "#absolute-1-1", "top": 0, "left": 0 },
{ "id": "#absolute-1-1", "top": -1, "left": -1 },
- { "id": "#absolute-1-1", "top": 5, "left": 5 },
- { "id": "#absolute-1", "top": 2, "left": 2 },
- { "id": "#absolute-1", "top": 0, "left": 0 },
+ { "id": "#absolute-1-1", "top": 5, "left": 5 },
+ { "id": "#absolute-1", "top": 2, "left": 2 },
+ { "id": "#absolute-1", "top": 0, "left": 0 },
{ "id": "#absolute-1", "top": -1, "left": -1 },
- { "id": "#absolute-1", "top": 1, "left": 1 }
+ { "id": "#absolute-1", "top": 1, "left": 1 }
];
jQuery.each( tests, function() {
$( this.id ).offset( { "top": this.top, "left": this.left } );
@@ -228,13 +228,13 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
$( this.id )
.offset( { "left": this.left + 2 } )
- .offset( { "top": this.top + 2 } );
+ .offset( { "top": this.top + 2 } );
assert.equal( $( this.id ).offset().top, this.top + 2, "Setting one property at a time." );
assert.equal( $( this.id ).offset().left, this.left + 2, "Setting one property at a time." );
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
- "top": props.top + 1,
+ "top": props.top + 1,
"left": props.left + 1
} );
} } );
@@ -248,8 +248,8 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
// get offset
var tests = [
- { "id": "#relative-1", "top": 7, "left": 7 },
- { "id": "#relative-1-1", "top": 15, "left": 15 },
+ { "id": "#relative-1", "top": 7, "left": 7 },
+ { "id": "#relative-1-1", "top": 15, "left": 15 },
{ "id": "#relative-2", "top": 142, "left": 27 },
{ "id": "#relative-2-1", "top": 149, "left": 52 }
];
@@ -260,8 +260,8 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
// get position
tests = [
- { "id": "#relative-1", "top": 6, "left": 6 },
- { "id": "#relative-1-1", "top": 5, "left": 5 },
+ { "id": "#relative-1", "top": 6, "left": 6 },
+ { "id": "#relative-1-1", "top": 5, "left": 5 },
{ "id": "#relative-2", "top": 141, "left": 26 },
{ "id": "#relative-2-1", "top": 5, "left": 5 }
];
@@ -272,18 +272,18 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
// set offset
tests = [
- { "id": "#relative-2", "top": 200, "left": 50 },
- { "id": "#relative-2", "top": 100, "left": 10 },
- { "id": "#relative-2", "top": -5, "left": -5 },
- { "id": "#relative-2", "top": 142, "left": 27 },
+ { "id": "#relative-2", "top": 200, "left": 50 },
+ { "id": "#relative-2", "top": 100, "left": 10 },
+ { "id": "#relative-2", "top": -5, "left": -5 },
+ { "id": "#relative-2", "top": 142, "left": 27 },
{ "id": "#relative-1-1", "top": 100, "left": 100 },
- { "id": "#relative-1-1", "top": 5, "left": 5 },
- { "id": "#relative-1-1", "top": -1, "left": -1 },
- { "id": "#relative-1-1", "top": 15, "left": 15 },
+ { "id": "#relative-1-1", "top": 5, "left": 5 },
+ { "id": "#relative-1-1", "top": -1, "left": -1 },
+ { "id": "#relative-1-1", "top": 15, "left": 15 },
{ "id": "#relative-1", "top": 100, "left": 100 },
- { "id": "#relative-1", "top": 0, "left": 0 },
- { "id": "#relative-1", "top": -1, "left": -1 },
- { "id": "#relative-1", "top": 7, "left": 7 }
+ { "id": "#relative-1", "top": 0, "left": 0 },
+ { "id": "#relative-1", "top": -1, "left": -1 },
+ { "id": "#relative-1", "top": 7, "left": 7 }
];
jQuery.each( tests, function() {
$( this.id ).offset( { "top": this.top, "left": this.left } );
@@ -292,7 +292,7 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
- "top": props.top + 1,
+ "top": props.top + 1,
"left": props.left + 1
} );
} } );
@@ -306,9 +306,9 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
// get offset
var tests = [
- { "id": "#static-1", "top": 7, "left": 7 },
- { "id": "#static-1-1", "top": 15, "left": 15 },
- { "id": "#static-1-1-1", "top": 23, "left": 23 },
+ { "id": "#static-1", "top": 7, "left": 7 },
+ { "id": "#static-1-1", "top": 15, "left": 15 },
+ { "id": "#static-1-1-1", "top": 23, "left": 23 },
{ "id": "#static-2", "top": 122, left: 7 }
];
jQuery.each( tests, function() {
@@ -318,9 +318,9 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
// get position
tests = [
- { "id": "#static-1", "top": 6, "left": 6 },
- { "id": "#static-1-1", "top": 14, "left": 14 },
- { "id": "#static-1-1-1", "top": 22, "left": 22 },
+ { "id": "#static-1", "top": 6, "left": 6 },
+ { "id": "#static-1-1", "top": 14, "left": 14 },
+ { "id": "#static-1-1-1", "top": 22, "left": 22 },
{ "id": "#static-2", "top": 121, "left": 6 }
];
jQuery.each( tests, function() {
@@ -332,20 +332,20 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
tests = [
{ "id": "#static-2", "top": 200, "left": 200 },
{ "id": "#static-2", "top": 100, "left": 100 },
- { "id": "#static-2", "top": -2, "left": -2 },
- { "id": "#static-2", "top": 121, "left": 6 },
- { "id": "#static-1-1-1", "top": 50, "left": 50 },
- { "id": "#static-1-1-1", "top": 10, "left": 10 },
- { "id": "#static-1-1-1", "top": -1, "left": -1 },
- { "id": "#static-1-1-1", "top": 22, "left": 22 },
- { "id": "#static-1-1", "top": 25, "left": 25 },
- { "id": "#static-1-1", "top": 10, "left": 10 },
- { "id": "#static-1-1", "top": -3, "left": -3 },
- { "id": "#static-1-1", "top": 14, "left": 14 },
- { "id": "#static-1", "top": 30, "left": 30 },
- { "id": "#static-1", "top": 2, "left": 2 },
- { "id": "#static-1", "top": -2, "left": -2 },
- { "id": "#static-1", "top": 7, "left": 7 }
+ { "id": "#static-2", "top": -2, "left": -2 },
+ { "id": "#static-2", "top": 121, "left": 6 },
+ { "id": "#static-1-1-1", "top": 50, "left": 50 },
+ { "id": "#static-1-1-1", "top": 10, "left": 10 },
+ { "id": "#static-1-1-1", "top": -1, "left": -1 },
+ { "id": "#static-1-1-1", "top": 22, "left": 22 },
+ { "id": "#static-1-1", "top": 25, "left": 25 },
+ { "id": "#static-1-1", "top": 10, "left": 10 },
+ { "id": "#static-1-1", "top": -3, "left": -3 },
+ { "id": "#static-1-1", "top": 14, "left": 14 },
+ { "id": "#static-1", "top": 30, "left": 30 },
+ { "id": "#static-1", "top": 2, "left": 2 },
+ { "id": "#static-1", "top": -2, "left": -2 },
+ { "id": "#static-1", "top": 7, "left": 7 }
];
jQuery.each( tests, function() {
$( this.id ).offset( { "top": this.top, "left": this.left } );
@@ -354,7 +354,7 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
- "top": props.top + 1,
+ "top": props.top + 1,
"left": props.left + 1
} );
} } );
@@ -406,11 +406,11 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
tests = [
{ "id": "#fixed-1", "top": 100, "left": 100 },
- { "id": "#fixed-1", "top": 0, "left": 0 },
- { "id": "#fixed-1", "top": -4, "left": -4 },
+ { "id": "#fixed-1", "top": 0, "left": 0 },
+ { "id": "#fixed-1", "top": -4, "left": -4 },
{ "id": "#fixed-2", "top": 200, "left": 200 },
- { "id": "#fixed-2", "top": 0, "left": 0 },
- { "id": "#fixed-2", "top": -5, "left": -5 }
+ { "id": "#fixed-2", "top": 0, "left": 0 },
+ { "id": "#fixed-2", "top": -5, "left": -5 }
];
jQuery.each( tests, function() {
@@ -420,7 +420,7 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
- "top": props.top + 1,
+ "top": props.top + 1,
"left": props.left + 1
} );
} } );
@@ -516,7 +516,7 @@ testIframe( "body", "offset/body.html", function( assert, $ ) {
QUnit.test( "chaining", function( assert ) {
assert.expect( 3 );
- var coords = { "top": 1, "left": 1 };
+ var coords = { "top": 1, "left": 1 };
assert.equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
assert.equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
assert.equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (trac-5571)" );
@@ -556,17 +556,17 @@ QUnit.test( "chaining", function( assert ) {
// Initialize data about page elements
var expectations = {
- "documentElement": htmlProps( htmlPos ),
- "body": bodyProps( bodyPos ),
- "relative": divProps( "relative", "body" ),
+ "documentElement": htmlProps( htmlPos ),
+ "body": bodyProps( bodyPos ),
+ "relative": divProps( "relative", "body" ),
"relative-relative": divProps( "relative", "relative" ),
"relative-absolute": divProps( "absolute", "relative" ),
- "absolute": divProps( "absolute", "body" ),
+ "absolute": divProps( "absolute", "body" ),
"absolute-relative": divProps( "relative", "absolute" ),
"absolute-absolute": divProps( "absolute", "absolute" ),
- "fixed": divProps( "fixed" ),
- "fixed-relative": divProps( "relative", "fixed" ),
- "fixed-absolute": divProps( "absolute", "fixed" )
+ "fixed": divProps( "fixed" ),
+ "fixed-relative": divProps( "relative", "fixed" ),
+ "fixed-absolute": divProps( "absolute", "fixed" )
};
// Define position and offset expectations for page elements
@@ -592,6 +592,7 @@ QUnit.test( "chaining", function( assert ) {
// parent is not offsetParent); offset includes parent offset+border+padding
// static: same as relative
for ( ; parent; parent = expectations[ parent.parent ] ) {
+
// position:fixed
if ( props.style === "fixed" ) {
break;
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 312b37b8c..ed9f261f8 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -88,7 +88,9 @@ QUnit.test( "queue() passes in the next item in the queue as a parameter to fx q
div.queue( function( next ) {
assert.equal( ++counter, 1, "Dequeueing" );
- setTimeout( function() { next(); }, 500 );
+ setTimeout( function() {
+ next();
+ }, 500 );
} ).queue( function( next ) {
assert.equal( ++counter, 2, "Next was called" );
next();
@@ -187,7 +189,9 @@ QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
div.queue( function( next ) {
counter++;
var self = this;
- setTimeout( function() { jQuery( self ).clearQueue(); next(); }, 50 );
+ setTimeout( function() {
+ jQuery( self ).clearQueue(); next();
+ }, 50 );
} ).queue( function() {
counter++;
} );
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 086726d43..cf36b1dbb 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -35,8 +35,8 @@ QUnit.test( "empty", function( assert ) {
QUnit.test( "star", function( assert ) {
assert.expect( 2 );
- var good, i;
- var all = jQuery( "*" );
+ var good, i,
+ all = jQuery( "*" );
assert.ok( all.length >= 30, "Select all" );
good = true;
@@ -51,8 +51,8 @@ QUnit.test( "star", function( assert ) {
QUnit.test( "element", function( assert ) {
assert.expect( 37 );
- var i, lengthtest, siblingTest, html;
- var fixture = document.getElementById( "qunit-fixture" );
+ var i, lengthtest, siblingTest, html,
+ fixture = document.getElementById( "qunit-fixture" );
assert.deepEqual( jQuery( "p", fixture ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a Node context." );
assert.deepEqual( jQuery( "p", "#qunit-fixture" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a selector context." );
@@ -848,6 +848,7 @@ QUnit.test( "pseudo - nth-child", function( assert ) {
"Seeded nth-child"
);
} else {
+
// Support: Chrome 75+, Firefox 67+
// Some browsers mark disconnected elements as matching `:nth-child(n)`
// so let's skip the test.
@@ -901,6 +902,7 @@ QUnit.test( "pseudo - nth-last-child", function( assert ) {
"Seeded nth-last-child"
);
} else {
+
// Support: Chrome 75+, Firefox 67+
// Some browsers mark disconnected elements as matching `:nth-last-child(n)`
// so let's skip the test.
@@ -1037,6 +1039,7 @@ QUnit.test( "pseudo - misc", function( assert ) {
tmp = document.createElement( "div" );
tmp.id = "tmp_input";
tmp.innerHTML = "<span>Hello I am focusable.</span>";
+
// Setting tabIndex should make the element focusable
// https://html.spec.whatwg.org/#the-tabindex-attribute
document.body.appendChild( tmp );
@@ -1093,6 +1096,7 @@ QUnit.test( "pseudo - misc", function( assert ) {
);
if ( QUnit.jQuerySelectors ) {
+
// Tokenization edge cases
assert.t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code)", [ "ap" ] );
assert.t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code):contains(This link)", [ "ap" ] );
@@ -1158,6 +1162,7 @@ QUnit.test( "pseudo - :not", function( assert ) {
assert.t( ":not() failing interior", "#qunit-fixture p:not(div#blargh)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
assert.t( ":not() failing interior", "#qunit-fixture p:not(p#blargh)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
} else {
+
// Support: IE 11+
// IE doesn't support `:not(complex selector)`.
assert.ok( "skip", ":not(complex selector) not supported in selector-native" );
@@ -1178,6 +1183,7 @@ QUnit.test( "pseudo - :not", function( assert ) {
assert.t( ":not Multiple", "p:not(p,a)", [] );
assert.t( ":not Multiple", "p:not(a,p,b)", [] );
} else {
+
// Support: IE 11+
// IE doesn't support `:not(complex selector)`.
assert.ok( "skip", ":not(complex selector) not supported in selector-native" );
@@ -1207,6 +1213,7 @@ QUnit.test( "pseudo - :not", function( assert ) {
if ( QUnit.jQuerySelectors || !QUnit.isIE ) {
assert.t( ":not() Multiple Class", "#foo a:not(.blog.link)", [ "yahoo", "anchor2" ] );
} else {
+
// Support: IE 11+
// IE doesn't support `:not(complex selector)`.
assert.ok( "skip", ":not(complex selector) not supported in selector-native" );
@@ -1439,8 +1446,7 @@ QUnit.test( "pseudo - a:(dis|en)abled", function( assert ) {
assert.expect( 2 );
var enabled, disabled,
- container = jQuery( "<div></div>" ),
- anchor = jQuery( "<a href='#'>Link</a>" );
+ container = jQuery( "<div></div>" );
container.appendTo( "#qunit-fixture" );
@@ -1754,8 +1760,8 @@ QUnit[ QUnit.jQuerySelectors ? "test" : "skip" ]( "disconnected nodes", function
QUnit.testUnlessIE( "Shadow DOM nodes supported as root", function( assert ) {
assert.expect( 2 );
- var shadowHost = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" )[ 0 ];
- var shadowRoot = shadowHost.attachShadow( { mode: "open" } );
+ var shadowHost = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" )[ 0 ],
+ shadowRoot = shadowHost.attachShadow( { mode: "open" } );
shadowRoot.innerHTML = "<div class='vagabond'><p></p></div>";
assert.equal( jQuery( shadowRoot ).find( ".vagabond" ).length, 1,
@@ -1767,7 +1773,7 @@ QUnit.testUnlessIE( "Shadow DOM nodes supported as root", function( assert ) {
testIframe(
"attributes - jQuery.attr",
"selector/html5_selector.html",
- function( assert, jQuery, window, document ) {
+ function( assert, jQuery, _window, document ) {
assert.expect( 38 );
/**
@@ -1840,7 +1846,7 @@ testIframe(
// Enumerated attributes (these are not boolean content attributes)
jQuery.expandedEach = jQuery.each;
- jQuery.expandedEach( [ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
+ jQuery.expandedEach( [ "draggable", "contenteditable", "aria-disabled" ], function( _i, val ) {
t( "Enumerated attribute", "[" + val + "]", [ "div1" ] );
} );
t( "Enumerated attribute", "[spellcheck]", [ "span1" ] );
@@ -1984,7 +1990,7 @@ QUnit.test( "uniqueSort()", function( assert ) {
testIframe(
"jQuery.uniqueSort works cross-window (trac-14381)",
"selector/mixed_sort.html",
- function( assert, jQuery, window, document, actual, expected ) {
+ function( assert, _jQuery, _window, _document, actual, expected ) {
assert.expect( 1 );
assert.deepEqual( actual, expected, "Mixed array was sorted correctly" );
@@ -2313,7 +2319,7 @@ QUnit[ QUnit.jQuerySelectors ? "test" : "skip" ]( "jQuery.find.select with pre-c
"#qunit-fixture #first",
"ol#listWithTabIndex > li[tabindex]",
"#liveSpan1"
- ], function( i, selector ) {
+ ], function( _i, selector ) {
var compiled = jQuery.find.compile( selector );
assert.equal( jQuery.find.select( compiled, document ).length,
1, "Should match using a compiled selector function" );
diff --git a/test/unit/serialize.js b/test/unit/serialize.js
index 24d888fb9..cc750db2a 100644
--- a/test/unit/serialize.js
+++ b/test/unit/serialize.js
@@ -5,10 +5,10 @@ QUnit.test( "jQuery.param()", function( assert ) {
var params;
- params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" };
+ params = { "foo": "bar", "baz": 42, "quux": "All your base are belong to us" };
assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All%20your%20base%20are%20belong%20to%20us", "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" };
@@ -23,13 +23,13 @@ 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%20your%20base%20are%20belong%20to%20us", "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%20Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy%20hat%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." );
@@ -37,7 +37,7 @@ QUnit.test( "jQuery.param()", function( assert ) {
// trac-7945
assert.equal( jQuery.param( { "jquery": "1.4.2" } ), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
- params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" };
+ params = { "foo": "bar", "baz": 42, "quux": "All your base are belong to us" };
assert.equal( jQuery.param( params, true ), "foo=bar&baz=42&quux=All%20your%20base%20are%20belong%20to%20us", "simple" );
params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" };
@@ -46,25 +46,27 @@ QUnit.test( "jQuery.param()", function( assert ) {
params = { "foo": [ "a", "b", "c" ] };
assert.equal( jQuery.param( params, true ), "foo=a&foo=b&foo=c", "with array of strings" );
- params = { "foo[]":[ "baz", 42, "All your base are belong to us" ] };
+ params = { "foo[]": [ "baz", 42, "All your base are belong to us" ] };
assert.equal( jQuery.param( params, true ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All%20your%20base%20are%20belong%20to%20us", "more array" );
- params = { "foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us" };
+ params = { "foo[bar]": "baz", "foo[beep]": 42, "foo[quux]": "All your base are belong to us" };
assert.equal( jQuery.param( params, true ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All%20your%20base%20are%20belong%20to%20us", "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, true ), "a=1&a=2&b=%5Bobject%20Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy%20hat%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, true ), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject%20Object%5D&a=17", "nested arrays (not possible when 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 ) ), "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 };
assert.equal( jQuery.param( params ), "param1=", "Make sure that null params aren't traversed." );
- params = { "param1": function() {}, "param2": function() { return null; } };
+ params = { "param1": function() {}, "param2": function() {
+ return null;
+ } };
assert.equal( jQuery.param( params, false ), "param1=&param2=", "object with function property that returns null value" );
params = { "test": { "length": 3, "foo": "bar" } };
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 06974d504..acc9c732d 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -310,7 +310,9 @@ QUnit.test( "filter(Function)", function( assert ) {
return !jQuery( "a", this ).length;
} ).get(), q( "sndp", "first" ), "filter(Function)" );
- assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" );
+ assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) {
+ return !jQuery( "a", elem ).length;
+ } ).get(), q( "sndp", "first" ), "filter(Function) using arg" );
} );
QUnit.test( "filter(Element)", function( assert ) {
@@ -511,7 +513,9 @@ QUnit.test( "not(Element)", function( assert ) {
QUnit.test( "not(Function)", function( assert ) {
assert.expect( 1 );
- assert.deepEqual( jQuery( "#qunit-fixture p" ).not( function() { return jQuery( "a", this ).length; } ).get(), q( "sndp", "first" ), "not(Function)" );
+ assert.deepEqual( jQuery( "#qunit-fixture p" ).not( function() {
+ return jQuery( "a", this ).length;
+ } ).get(), q( "sndp", "first" ), "not(Function)" );
} );
QUnit.test( "not(Array)", function( assert ) {