Build: ESLint details

Use eslint pragmas, fix new errors, etc

Closes gh-3148
This commit is contained in:
Oleg Gaidarenko 2016-05-10 12:12:28 +03:00
parent a4474c9a00
commit 58c6ca9822
46 changed files with 349 additions and 457 deletions

View File

@ -1,4 +1,6 @@
external
node_modules
dist/jquery.min.js
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
@ -8,5 +10,3 @@ test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js
test/node_smoke_tests/lib/ensure_iterability.js
node_modules
dist

146
.eslintrc
View File

@ -1,145 +1,7 @@
{
"env": {},
"globals": {},
"rules": {
"no-cond-assign": [
"error",
"except-parens"
],
"curly": [
"error",
"all"
],
"object-curly-spacing": [
"error",
"always"
],
"computed-property-spacing": [
"error",
"always"
],
"array-bracket-spacing": [
"error",
"always"
],
"eqeqeq": [
"error",
"smart"
],
// Shows errors where jshint wouldn't (see jshint "expr" rule)
// clarifing this with eslint team
// "no-unused-expressions": "error",
"wrap-iife": [
"error",
"inside"
],
"no-caller": "error",
"quotes": [
"error",
"double",
"avoid-escape"
],
"no-undef": "error",
"no-unused-vars": "error",
"operator-linebreak": [
"error",
"after"
],
"comma-style": [
"error",
"last"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"dot-notation": [
"error",
{
"allowPattern": "^[a-z]+(_[a-z]+)+$"
}
],
"max-len": [
"error",
{
"code": 100,
"ignoreComments": true
}
],
"no-mixed-spaces-and-tabs": "error",
"no-trailing-spaces": "error",
"no-multi-str": "error",
"comma-dangle": [
"error",
"never"
],
"comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"space-before-blocks": [
"error",
"always"
],
"space-in-parens": [
"error",
"always"
],
"keyword-spacing": [
2
],
"semi": [
"error",
"always"
],
"semi-spacing": [
"error",
{
// Because of the `for ( ; ...)` requirement
// "before": true,
"after": true
}
],
"space-infix-ops": "error",
"eol-last": "error",
"lines-around-comment": [
"error",
{
"beforeLineComment": true
}
],
"linebreak-style": [
"error",
"unix"
],
"no-with": "error",
"brace-style": "error",
"space-before-function-paren": [
"error",
"never"
],
"no-loop-func": "error",
"no-spaced-func": "error",
"key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true
}
],
"space-unary-ops": [
"error",
{
"words": false,
"nonwords": false
}
],
"no-multiple-empty-lines": 2
"extends": "eslint-config-jquery",
"root": true,
"env": {
"node": true
}
}

2
.gitignore vendored
View File

@ -10,7 +10,7 @@
npm-debug.log
/dist
/dist/jquery*
/node_modules
/test/node_smoke_tests/lib/ensure_iterability.js

View File

@ -1,10 +0,0 @@
external
test/data/jquery-1.9.1.js
test/data/badcall.js
test/data/badjson.js
test/data/json_obj.js
test/data/readywaitasset.js
test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js
test/node_smoke_tests/lib/ensure_iterability.js

View File

@ -180,7 +180,7 @@ module.exports = function( grunt ) {
// Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" );
grunt.registerTask( "lint", [ "jsonlint" ] );
grunt.registerTask( "lint", [ "jsonlint", "eslint:all" ] );
// Don't run Node-related tests in Node.js < 1.0.0 as they require an old
// jsdom version that needs compiling, making it harder for people to compile
@ -194,6 +194,7 @@ module.exports = function( grunt ) {
// Short list as a high frequency watch task
grunt.registerTask( "dev", [
"build:*:*",
"newer:eslint:dev",
"uglify",
"remove_map_comment",
"dist:*"
@ -202,5 +203,5 @@ module.exports = function( grunt ) {
grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );
grunt.registerTask( "precommit_lint", [ "newer:jsonlint" ] );
grunt.registerTask( "precommit_lint", [ "newer:jsonlint", "newer:eslint:all" ] );
};

View File

@ -1,7 +0,0 @@
{
"env": {
"node": true
},
"extends": "../.eslintrc",
"root": true
}

View File

@ -21,6 +21,7 @@ module.exports = function( Release ) {
Release.define( {
npmPublish: true,
issueTracker: "github",
/**
* Ensure the repo is in a proper state before release
* @param {Function} callback
@ -28,6 +29,7 @@ module.exports = function( Release ) {
checkRepoState: function( callback ) {
ensureSizzle( Release, callback );
},
/**
* Set the version in the src folder for distributing AMD
*/
@ -37,6 +39,7 @@ module.exports = function( Release ) {
contents = contents.replace( /@VERSION/g, Release.newVersion );
fs.writeFileSync( corePath, contents, "utf8" );
},
/**
* Generates any release artifacts that should be included in the release.
* The callback must be invoked with an array of files that should be
@ -54,6 +57,7 @@ module.exports = function( Release ) {
Release._setSrcVersion();
callback( files );
},
/**
* Acts as insertion point for restoring Release.dir.repo
* It was changed to reuse npm publish code in jquery-release
@ -65,6 +69,7 @@ module.exports = function( Release ) {
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags();
},
/**
* Publish to distribution repo and npm
* @param {Function} callback

View File

@ -38,7 +38,7 @@ module.exports = function( grunt ) {
// Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true,
wrap: {
start: wrapper[ 0 ].replace( /\/\*jshint .* \*\/\n/, "" ),
start: wrapper[ 0 ].replace( /\/\*eslint .* \*\/\n/, "" ),
end: globals.replace(
/\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig,
""
@ -64,7 +64,12 @@ module.exports = function( grunt ) {
// Convert var modules
if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
contents = contents
.replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
.replace(
/define\([\w\W]*?return/,
"var " +
( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
" ="
)
.replace( rdefineEnd, "" );
// Sizzle treatment
@ -130,6 +135,7 @@ module.exports = function( grunt ) {
excluded = [],
included = [],
version = grunt.config( "pkg.version" ),
/**
* Recursively calls the excluder to remove on all modules in the list
* @param {Array} list
@ -167,6 +173,7 @@ module.exports = function( grunt ) {
} );
}
},
/**
* Adds the specified module to the excluded or included list, depending on the flag
* @param {String} flag A module path relative to

View File

@ -1,5 +1,3 @@
/* jshint node: true */
"use strict";
// Run Node with provided parameters: the first one being the Grunt

17
dist/.eslintrc vendored Normal file
View File

@ -0,0 +1,17 @@
{
"extends": "../src/.eslintrc",
"rules": {
// That is okay for built version
"no-multiple-empty-lines": "off",
// Because sizze is not compatible to jquery code style
"lines-around-comment": "off",
"space-in-parens": "off",
"camelcase": "off",
"computed-property-spacing": "off",
"max-len": "off",
"dot-notation": "off",
"semi-spacing": "off",
"brace-style": "off"
}
}

View File

@ -29,6 +29,7 @@
"commitplease": "2.3.1",
"core-js": "2.2.2",
"cross-spawn": "2.2.3",
"eslint-config-jquery": "0.1.2",
"grunt": "1.0.1",
"grunt-babel": "6.0.0",
"grunt-cli": "1.2.0",

View File

@ -1,15 +1,18 @@
{
"env": {
"browser"
// Support: IE <=9 only, Android <=4.0 only
// The above browsers are failing a lot of tests in the ES5
// test suite at http://test262.ecmascript.org.
"parserOptions": {
"ecmaVersion": 3
},
"extends": "../.eslintrc",
"root": true,
"globals": {
"window": true,
"JSON": false,
"jQuery": true,
"define": true,
"module": true,
"noGlobal": true
},
"rules": {
"strict": ["error", "function"]
}
}

View File

@ -306,6 +306,7 @@ jQuery.extend( {
processData: true,
async: true,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
/*
timeout: 0,
data: null,

View File

@ -143,11 +143,16 @@ jQuery.extend( {
while ( i-- ) {
option = options[ i ];
/* eslint-disable no-cond-assign */
if ( option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true;
}
/* eslint-enable no-cond-assign */
}
// Force browsers to behave consistently when non-matching value is set

View File

@ -1,3 +1,7 @@
/* global Symbol */
// Defining this global in .eslintrc would create a danger of using the global
// unguarded in another place, it seems safer to define global only for this module
define( [
"./var/arr",
"./var/document",
@ -252,7 +256,11 @@ jQuery.extend( {
},
isEmptyObject: function( obj ) {
/* eslint-disable no-unused-vars */
// See https://github.com/eslint/eslint/issues/6125
var name;
for ( name in obj ) {
return false;
}
@ -442,15 +450,9 @@ jQuery.extend( {
support: support
} );
// JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global
// unguarded in another place, it seems safer to just disable JSHint for these
// three lines.
/* jshint ignore: start */
if ( typeof Symbol === "function" ) {
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
}
/* jshint ignore: end */
// Populate the class2type map
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),

View File

@ -10,8 +10,12 @@ function adjustCSS( elem, prop, valueParts, tween ) {
scale = 1,
maxIterations = 20,
currentValue = tween ?
function() { return tween.cur(); } :
function() { return jQuery.css( elem, prop, "" ); },
function() {
return tween.cur();
} :
function() {
return jQuery.css( elem, prop, "" );
},
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),

View File

@ -13,7 +13,6 @@ return function( owner ) {
// - Node.DOCUMENT_NODE
// - Object
// - Any
/* jshint -W018 */
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
};

View File

@ -37,7 +37,7 @@ function adoptValue( value, resolve, reject ) {
// For Promises/A+, convert exceptions into rejections
// Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
// Deferred#then to conditionally suppress rejection.
} catch ( /*jshint -W002 */ value ) {
} catch ( value ) {
// Support: Android 4.0 only
// Strict mode functions invoked without .call/.apply get global-object context

6
src/effects.js vendored
View File

@ -78,7 +78,6 @@ function createTween( value, prop, animation ) {
}
function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
isBox = "width" in props || "height" in props,
anim = this,
@ -220,9 +219,12 @@ function defaultPrefilter( elem, props, opts ) {
showHide( [ elem ], true );
}
/* jshint -W083 */
/* eslint-disable no-loop-func */
anim.done( function() {
/* eslint-enable no-loop-func */
// The final step of a "hide" animation is actually hiding the element
if ( !hidden ) {
showHide( [ elem ] );

View File

@ -2,7 +2,7 @@
// This file is included in a different way from all the others
// so the "use strict" pragma is not needed.
/* jshint strict: false */
/* eslint strict: "off" */
/* ExcludeEnd */

View File

@ -29,8 +29,14 @@ define( [
"use strict";
var
/* eslint-disable max-len */
// See https://github.com/eslint/eslint/issues/3229
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
/* eslint-enable */
// Support: IE <=10 - 11, Edge 12 - 13
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/

View File

@ -1 +1,3 @@
define( [ "./selector-sizzle" ], function() {} );
define( [ "./selector-sizzle" ], function() {
"use strict";
} );

View File

@ -13,7 +13,6 @@ var risSimple = /^.[^:#\[\.,]*$/;
function winnow( elements, qualifier, not ) {
if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not;
} );

View File

@ -1,4 +1,4 @@
/*jshint unused:false */
/*eslint-disable no-unused-vars*/
/*!
* jQuery JavaScript Library v@VERSION
* https://jquery.com/
@ -38,7 +38,7 @@
}
// Pass this if window is not defined yet
}( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
@ -50,4 +50,4 @@
// build.js inserts compiled jQuery here
return jQuery;
} ) );
} );

View File

@ -2,8 +2,12 @@
"env": {
"browser": true
},
"extends": "../.eslintrc",
"root": true,
// Support: IE <=9 only, Android <=4.0 only
// The above browsers are failing a lot of tests in the ES5
// test suite at http://test262.ecmascript.org.
"parserOptions": {
"ecmaVersion": 3
},
"globals": {
"require": false,
"define": false,
@ -38,7 +42,7 @@
"externalHost": true
},
"rules": {
// See https://github.com/eslint/eslint/issues/6125
// See https://github.com/eslint/eslint/issues/2342
"no-unused-vars": "off",
// Too much errors
@ -48,7 +52,7 @@
"camelcase": "off",
"dot-notaion": "off",
// Not a lot really too much, but waiting for autofix for these rules
// Not really too much - waiting autofix features for these rules
"lines-around-comment": "off",
"dot-notation": "off"
}

View File

@ -1,7 +1,6 @@
/*jshint multistr:true, quotmark:false */
/* eslint no-multi-str: "off" */
var fireNative, originaljQuery, original$,
baseURL = "",
var baseURL = "",
supportjQuery = this.jQuery,
// see RFC 2606
@ -12,8 +11,8 @@ this.isLocal = window.location.protocol === "file:";
// Setup global variables before loading jQuery for testing .noConflict()
supportjQuery.noConflict( true );
originaljQuery = this.jQuery = undefined;
original$ = this.$ = "replaced";
window.originaljQuery = this.jQuery = undefined;
window.original$ = this.$ = "replaced";
/**
* Returns an array of elements with the given IDs
@ -44,7 +43,7 @@ function match( message, selector, expectedIds, context ) {
i = 0;
for ( ; i < f.length; i++ ) {
s += ( s && "," ) + '"' + f[ i ].id + '"';
s += ( s && "," ) + "\"" + f[ i ].id + "\"";
}
this.deepEqual( f, q.apply( q, expectedIds ), message + " (" + selector + ")" );
@ -75,38 +74,38 @@ QUnit.assert.selectInFixture = function( message, selector, expectedIds ) {
};
this.createDashboardXML = function() {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
var string = "<?xml version='1.0' encoding='UTF-8'?> \
<dashboard> \
<locations class="foo"> \
<location for="bar" checked="different"> \
<infowindowtab normal="ab" mixedCase="yes"> \
<tab title="Location"><![CDATA[blabla]]></tab> \
<tab title="Users"><![CDATA[blublu]]></tab> \
<locations class='foo'> \
<location for='bar' checked='different'> \
<infowindowtab normal='ab' mixedCase='yes'> \
<tab title='Location'><![CDATA[blabla]]></tab> \
<tab title='Users'><![CDATA[blublu]]></tab> \
</infowindowtab> \
</location> \
</locations> \
</dashboard>';
</dashboard>";
return jQuery.parseXML( string );
};
this.createWithFriesXML = function() {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \
var string = "<?xml version='1.0' encoding='UTF-8'?> \
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' \
xmlns:xsd='http://www.w3.org/2001/XMLSchema' \
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> \
<soap:Body> \
<jsconf xmlns="http://{{ externalHost }}/ns1"> \
<response xmlns:ab="http://{{ externalHost }}/ns2"> \
<jsconf xmlns='http://{{ externalHost }}/ns1'> \
<response xmlns:ab='http://{{ externalHost }}/ns2'> \
<meta> \
<component id="seite1" class="component"> \
<properties xmlns:cd="http://{{ externalHost }}/ns3"> \
<property name="prop1"> \
<component id='seite1' class='component'> \
<properties xmlns:cd='http://{{ externalHost }}/ns3'> \
<property name='prop1'> \
<thing /> \
<value>1</value> \
</property> \
<property name="prop2"> \
<thing att="something" /> \
<property name='prop2'> \
<thing att='something' /> \
</property> \
<foo_bar>foo</foo_bar> \
</properties> \
@ -115,7 +114,7 @@ this.createWithFriesXML = function() {
</response> \
</jsconf> \
</soap:Body> \
</soap:Envelope>';
</soap:Envelope>";
return jQuery.parseXML( string.replace( /\{\{\s*externalHost\s*\}\}/g, externalHost ) );
};
@ -123,7 +122,7 @@ this.createWithFriesXML = function() {
this.createXMLFragment = function() {
var xml, frag;
if ( window.ActiveXObject ) {
xml = new ActiveXObject( "msxml2.domdocument" );
xml = new window.ActiveXObject( "msxml2.domdocument" );
} else {
xml = document.implementation.createDocument( "", "", null );
}
@ -135,7 +134,7 @@ this.createXMLFragment = function() {
return frag;
};
fireNative = document.createEvent ?
window.fireNative = document.createEvent ?
function( node, type ) {
var event = document.createEvent( "HTMLEvents" );
@ -263,8 +262,8 @@ QUnit.config.autostart = false;
this.loadTests = function() {
// Leverage QUnit URL parsing to detect testSwarm environment and "basic" testing mode
QUnit.isSwarm = ( QUnit.urlParams[ "swarmURL" ] + "" ).indexOf( "http" ) === 0;
QUnit.basicTests = ( QUnit.urlParams[ "module" ] + "" ) === "basic";
QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";
// Get testSubproject from testrunner first
require( [ "data/testrunner.js" ], function() {

View File

@ -1,10 +1,7 @@
{
"env": {
"node": true
"es6": true
},
"parserOptions": {
"ecmaVersion": 6
},
"extends": "../.eslintrc",
"extends" : "../../.eslintrc",
"root": true
}

View File

@ -1,5 +1,3 @@
/* jshint esnext: true */
"use strict";
var assert = require( "assert" );

View File

@ -1,5 +1,3 @@
/* jshint esnext: true */
"use strict";
var assert = require( "assert" );

View File

@ -1,7 +1,4 @@
{
"env": {
"node": true
},
"extends": "../.eslintrc",
"extends": "../../.eslintrc",
"root": true
}

View File

@ -1692,7 +1692,6 @@ testIframe(
);
QUnit.test( "Iterability of jQuery objects (gh-1693)", function( assert ) {
/* jshint unused: false */
assert.expect( 1 );
var i, elem, result;

View File

@ -78,7 +78,7 @@ QUnit.test( "on(), with data", function( assert ) {
handler = function( event ) {
assert.ok( event.data, "on() with data, check passed data exists" );
assert.equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" );
assert.equal( event.data.foo, "bar", "on() with data, Check value of passed data" );
};
jQuery( "#firstp" ).on( "click", { "foo": "bar" }, handler ).trigger( "click" ).off( "click", handler );
@ -95,7 +95,7 @@ QUnit.test( "click(), with data", function( assert ) {
assert.expect( 3 );
var handler = function( event ) {
assert.ok( event.data, "on() with data, check passed data exists" );
assert.equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" );
assert.equal( event.data.foo, "bar", "on() with data, Check value of passed data" );
};
jQuery( "#firstp" ).on( "click", { "foo": "bar" }, handler ).trigger( "click" ).off( "click", handler );
@ -199,7 +199,7 @@ QUnit.test( "on(), namespace with special add", function( assert ) {
assert.ok( true, "Test event fired." );
} );
jQuery.event.special[ "test" ] = {
jQuery.event.special.test = {
_default: function( e, data ) {
assert.equal( e.type, "test", "Make sure we're dealing with a test event." );
assert.ok( data, "And that trigger data was passed." );
@ -251,7 +251,7 @@ QUnit.test( "on(), namespace with special add", function( assert ) {
// Should trigger 2
div.appendTo( "#qunit-fixture" ).remove();
delete jQuery.event.special[ "test" ];
delete jQuery.event.special.test;
} );
QUnit.test( "on(), no data", function( assert ) {
@ -726,8 +726,8 @@ 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[ "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." );
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." );
// Should trigger 1
jQuery( obj ).trigger( "test" );
@ -1601,7 +1601,7 @@ QUnit.test( ".on()/.off()", function( assert ) {
// Test binding with different this object
jQuery( "#body" ).on( "click", "#foo", jQuery.proxy( function() {
assert.equal( this[ "foo" ], "bar", "on with event scope" ); }, { "foo": "bar" }
assert.equal( this.foo, "bar", "on with event scope" ); }, { "foo": "bar" }
) );
jQuery( "#foo" ).trigger( "click" );
jQuery( "#body" ).off( "click", "#foo" );
@ -2234,7 +2234,7 @@ QUnit.test( ".on and .off", function( assert ) {
QUnit.test( "special on name mapping", function( assert ) {
assert.expect( 7 );
jQuery.event.special[ "slap" ] = {
jQuery.event.special.slap = {
bindType: "click",
delegateType: "swing",
handle: function( event ) {
@ -2265,9 +2265,9 @@ QUnit.test( "special on name mapping", function( assert ) {
.trigger( "swing" )
.end()
.remove();
delete jQuery.event.special[ "slap" ];
delete jQuery.event.special.slap;
jQuery.event.special[ "gutfeeling" ] = {
jQuery.event.special.gutfeeling = {
bindType: "click",
delegateType: "click",
handle: function( event ) {
@ -2356,9 +2356,9 @@ QUnit.test( "clone() delegated events (#11076)", function( assert ) {
clone = table.clone( true );
clone.find( "td" ).trigger( "click" );
assert.equal( counter[ "center" ], 1, "first child" );
assert.equal( counter[ "fold" ], 1, "last child" );
assert.equal( counter[ "centerfold" ], 2, "all children" );
assert.equal( counter.center, 1, "first child" );
assert.equal( counter.fold, 1, "last child" );
assert.equal( counter.centerfold, 2, "all children" );
table.remove();
clone.remove();
@ -2902,6 +2902,7 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e
"make sure originalEvent type is correct" );
assert.equal( event.type, "focusin", "make sure type is correct" );
} );
jQuery( "#donor-input" ).on( "focus", function() {
assert.ok( true, "got a focus event from the input" );
done();

View File

@ -609,7 +609,7 @@ QUnit.test( "append(xml)", function( assert ) {
// IE
for ( n = 0, len = aActiveX.length; n < len; n++ ) {
try {
elem = new ActiveXObject( aActiveX[ n ] );
elem = new window.ActiveXObject( aActiveX[ n ] );
return elem;
} catch ( _ ) {}
}
@ -1211,7 +1211,7 @@ QUnit.test( "insertAfter(jQuery)", function( assert ) {
function testReplaceWith( val, assert ) {
var tmp, y, child, child2, set, non_existent, $div,
var tmp, y, child, child2, set, nonExistent, $div,
expected = 29;
assert.expect( expected );
@ -1295,8 +1295,8 @@ function testReplaceWith( val, assert ) {
assert.deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [],
"Replacement with following sibling (context removed)" );
non_existent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) );
assert.equal( non_existent.length, 0, "Length of non existent element." );
nonExistent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) );
assert.equal( nonExistent.length, 0, "Length of non existent element." );
$div = jQuery( "<div class='replacewith'></div>" ).appendTo( "#qunit-fixture" );
$div.replaceWith( val( "<div class='replacewith'></div><script>" +
@ -2464,7 +2464,7 @@ QUnit.test( "script evaluation (#11795)", function( assert ) {
if ( jQuery.ajax ) {
Globals.register( "testBar" );
jQuery( "#qunit-fixture" ).append( "<script src='" + url( "data/testbar.php" ) + "'/>" );
assert.strictEqual( window[ "testBar" ], "bar", "Global script evaluation" );
assert.strictEqual( window.testBar, "bar", "Global script evaluation" );
} else {
assert.ok( true, "No jQuery.ajax" );
assert.ok( true, "No jQuery.ajax" );
@ -2745,8 +2745,8 @@ QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
jQuery( fixture ).append( "<script src=\"data:text/javascript,testFoo = 'foo';\"></script>" );
setTimeout( function() {
if ( window[ "testSrcFoo" ] === "foo" ) {
assert.strictEqual( window[ "testFoo" ], window[ "testSrcFoo" ], "data-URI script executed" );
if ( window.testSrcFoo === "foo" ) {
assert.strictEqual( window.testFoo, window.testSrcFoo, "data-URI script executed" );
} else {
assert.ok( true, "data-URI script is not supported by this environment" );

View File

@ -79,8 +79,8 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $, iframe ) {
{ "id": "#absolute-1", "top": 1, "left": 1 }
];
jQuery.each( tests, function() {
assert.equal( jQuery( this[ "id" ], doc ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
assert.equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
assert.equal( jQuery( this.id, doc ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
assert.equal( jQuery( this.id, doc ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
} );
// get position
@ -88,8 +88,8 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $, iframe ) {
{ "id": "#absolute-1", "top": 0, "left": 0 }
];
jQuery.each( tests, function() {
assert.equal( jQuery( this[ "id" ], doc ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
assert.equal( jQuery( this[ "id" ], doc ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
assert.equal( jQuery( this.id, doc ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
assert.equal( jQuery( this.id, doc ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
} );
} );
@ -106,8 +106,8 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
{ "id": "#absolute-2", "top": 20, "left": 20 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
} );
// get position
@ -118,8 +118,8 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
{ "id": "#absolute-2", "top": 19, "left": 19 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
assert.equal( $( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
assert.equal( $( this.id ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
} );
// test #5781
@ -147,34 +147,34 @@ testIframe( "absolute", "offset/absolute.html", function( assert, $ ) {
{ "id": "#absolute-1", "top": 1, "left": 1 }
];
jQuery.each( tests, function() {
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
$( this.id ).offset( { "top": this.top, "left": this.left } );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
var top = this[ "top" ], left = this[ "left" ];
var top = this.top, left = this.left;
$( this[ "id" ] ).offset( function( i, val ) {
$( this.id ).offset( function( i, val ) {
assert.equal( val.top, top, "Verify incoming top position." );
assert.equal( val.left, left, "Verify incoming top position." );
return { "top": top + 1, "left": left + 1 };
} );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + " })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + " })" );
assert.equal( $( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + ( this.top + 1 ) + " })" );
assert.equal( $( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + ( this.left + 1 ) + " })" );
$( this[ "id" ] )
.offset( { "left": this[ "left" ] + 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( { "left": this.left + 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.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
"top": props.top + 1,
"left": props.left + 1
} );
} } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + ( this.top + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + ( this.left + 1 ) + ", using: fn })" );
} );
} );
@ -189,8 +189,8 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
{ "id": "#relative-2-1", "top": 149, "left": 52 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
} );
// get position
@ -201,8 +201,8 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
{ "id": "#relative-2-1", "top": 5, "left": 5 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" );
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" );
assert.equal( $( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
assert.equal( $( this.id ).position().left, this.left, "jQuery('" + this.id + "').position().left" );
} );
// set offset
@ -221,18 +221,18 @@ testIframe( "relative", "offset/relative.html", function( assert, $ ) {
{ "id": "#relative-1", "top": 7, "left": 7 }
];
jQuery.each( tests, function() {
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
$( this.id ).offset( { "top": this.top, "left": this.left } );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
"top": props.top + 1,
"left": props.left + 1
} );
} } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + ( this.top + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + ( this.left + 1 ) + ", using: fn })" );
} );
} );
@ -247,8 +247,8 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
{ "id": "#static-2", "top": 122, left: 7 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
} );
// get position
@ -259,8 +259,8 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
{ "id": "#static-2", "top": 121, "left": 6 }
];
jQuery.each( tests, function() {
assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "top" ] + "').position().top" );
assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" );
assert.equal( $( this.id ).position().top, this.top, "jQuery('" + this.top + "').position().top" );
assert.equal( $( this.id ).position().left, this.left, "jQuery('" + this.left + "').position().left" );
} );
// set offset
@ -283,18 +283,18 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
{ "id": "#static-1", "top": 7, "left": 7 }
];
jQuery.each( tests, function() {
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
$( this.id ).offset( { "top": this.top, "left": this.left } );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
"top": props.top + 1,
"left": props.left + 1
} );
} } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + ( this.top + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + ( this.left + 1 ) + ", using: fn })" );
} );
} );
@ -328,10 +328,10 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
assert.ok( true, "Browser doesn't support scroll position." );
} else if ( window.supportsFixedPosition ) {
assert.equal( $( this[ "id" ] ).offset().top, this[ "offsetTop" ], "jQuery('" + this[ "id" ] + "').offset().top" );
assert.equal( $( this[ "id" ] ).position().top, this[ "positionTop" ], "jQuery('" + this[ "id" ] + "').position().top" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" );
assert.equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" );
assert.equal( $( this.id ).offset().top, this.offsetTop, "jQuery('" + this.id + "').offset().top" );
assert.equal( $( this.id ).position().top, this.positionTop, "jQuery('" + this.id + "').position().top" );
assert.equal( $( this.id ).offset().left, this.offsetLeft, "jQuery('" + this.id + "').offset().left" );
assert.equal( $( this.id ).position().left, this.positionLeft, "jQuery('" + this.id + "').position().left" );
} else {
// need to have same number of assertions
@ -353,18 +353,18 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
jQuery.each( tests, function() {
if ( window.supportsFixedPosition ) {
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" );
$( this.id ).offset( { "top": this.top, "left": this.left } );
assert.equal( $( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset({ top: " + this.top + " })" );
assert.equal( $( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset({ left: " + this.left + " })" );
$( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) {
$( this.id ).offset( { "top": this.top, "left": this.left, "using": function( props ) {
$( this ).css( {
"top": props.top + 1,
"left": props.left + 1
} );
} } );
assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" );
assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().top, this.top + 1, "jQuery('" + this.id + "').offset({ top: " + ( this.top + 1 ) + ", using: fn })" );
assert.equal( $( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + ( this.left + 1 ) + ", using: fn })" );
} else {
// need to have same number of assertions
@ -549,8 +549,10 @@ QUnit.test( "iframe scrollTop/Left (see gh-1945)", function( assert ) {
// Mobile Safari resize the iframe by its content meaning it's not possible to scroll
// the iframe but only its parent element.
// It seems (not confirmed) in android 4.0 it's not possible to scroll iframes from the code.
if ( /iphone os/i.test( navigator.userAgent ) ||
/android 4\.0/i.test( navigator.userAgent ) ) {
if (
/iphone os/i.test( navigator.userAgent ) ||
/android 4\.0/i.test( navigator.userAgent )
) {
assert.equal( true, true, "Can't scroll iframes in this environment" );
assert.equal( true, true, "Can't scroll iframes in this environment" );

View File

@ -493,7 +493,7 @@ testIframe(
"Sizzle cache collides with multiple Sizzles on a page",
"selector/sizzle_cache.html",
function( assert, jQuery, window, document ) {
var $cached = window[ "$cached" ];
var $cached = window.$cached;
assert.expect( 4 );
assert.notStrictEqual( jQuery, $cached, "Loaded two engines" );

View File

@ -92,7 +92,7 @@ QUnit.test( "jQuery.param() Constructed prop values", function( assert ) {
/** @constructor */
function Record() {
this[ "prop" ] = "val";
this.prop = "val";
}
var MyString = String,