From 08888329b38571e6981eb9ac9af6ed2766daf64f Mon Sep 17 00:00:00 2001
From: Devin McIntyre
Date: Fri, 18 Oct 2024 14:13:29 -0600
Subject: [PATCH 1/6] Squashed commit of the following:
commit d06d40a05b3d900ba36ca96370552a38c7a64afa
Merge: a462335 ebced6b
Author: Devin McIntyre
Date: Fri Oct 18 14:09:03 2024 -0600
Merge branch 'update-to-eslint-9' of https://github.com/miyasudokoro/eslint-config-jquery into update-to-eslint-9
commit a46233540aff1a82a8effbd21ef78ce7be04f836
Author: Devin McIntyre
Date: Fri Oct 18 13:51:44 2024 -0600
update to ESLint 9
commit ebced6b3c21876ad55b49245069cedb8ec7622e3
Author: Devin McIntyre
Date: Fri Oct 18 13:51:44 2024 -0600
update to ESLint 9
---
.eslintrc.js | 6 -
.gitattributes | 2 +-
.gitignore | 3 +
copy-fixtures.js | 31 +
eslint.config.js | 14 +
index.js | 77 +-
package.json | 15 +-
readme.md | 26 +-
test/fixtures/.eslintrc.js | 21 -
test/fixtures/jquery.js | 9611 ------------------------------------
10 files changed, 124 insertions(+), 9682 deletions(-)
delete mode 100644 .eslintrc.js
create mode 100644 copy-fixtures.js
create mode 100644 eslint.config.js
delete mode 100644 test/fixtures/.eslintrc.js
delete mode 100644 test/fixtures/jquery.js
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index 09be150..0000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-module.exports = {
- extends: "./index.js",
- env: {
- node: true
- }
-};
diff --git a/.gitattributes b/.gitattributes
index dfe0770..e7c1d93 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
-* text=auto
+* text eol=lf
diff --git a/.gitignore b/.gitignore
index 086707b..aaea590 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,6 @@
npm-debug.log
package-lock.json
yarn.lock
+.idea
+eslint-report.html
+/test
\ No newline at end of file
diff --git a/copy-fixtures.js b/copy-fixtures.js
new file mode 100644
index 0000000..c229c05
--- /dev/null
+++ b/copy-fixtures.js
@@ -0,0 +1,31 @@
+import { promisify } from "node:util";
+import chip from "node:child_process";
+import fs from "node:fs";
+import path from "node:path";
+
+const exec = promisify( chip.exec );
+
+await exec( "npm install --no-save jquery" );
+
+const fixtures = path.join( ".", "test", "fixtures" );
+
+try {
+ await fs.promises.mkdir( path.join( ".", "test" ) );
+ await fs.promises.mkdir( fixtures );
+} catch ( _ ) {
+ await fs.promises.rm(
+ fixtures,
+ {
+ recursive: true
+ }
+ );
+
+}
+
+await fs.promises.cp(
+ path.join( ".", "node_modules", "jquery", "src" ),
+ path.join( fixtures, "src" ),
+ {
+ recursive: true
+ }
+);
diff --git a/eslint.config.js b/eslint.config.js
new file mode 100644
index 0000000..77cdbeb
--- /dev/null
+++ b/eslint.config.js
@@ -0,0 +1,14 @@
+import jquery from "./index.js";
+import globals from "globals";
+
+export default [
+ {
+ "languageOptions": {
+ "globals": {
+ ...globals.amd,
+ ...globals.browser
+ }
+ }
+ },
+ jquery
+];
diff --git a/index.js b/index.js
index 1b1928b..c69e053 100644
--- a/index.js
+++ b/index.js
@@ -1,30 +1,37 @@
-module.exports = {
+
+import stylistic from "@stylistic/eslint-plugin-js";
+
+export default {
+ plugins: {
+ "@stylistic/js": stylistic
+ },
rules: {
- "no-negated-in-lhs": "error",
+ "no-unsafe-negation": "error",
"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" ],
+ "curly": [ "error", "all" ],
+ "@stylistic/js/object-curly-spacing": [ "error", "always" ],
+ "@stylistic/js/computed-property-spacing": [ "error", "always" ],
+ "@stylistic/js/array-bracket-spacing": [ "error", "always" ],
+ "eqeqeq": [ "error", "smart" ],
"no-unused-expressions": "error",
"no-sequences": "error",
"no-nested-ternary": "error",
"no-unreachable": "error",
- "wrap-iife": [ "error", "inside" ],
+ "@stylistic/js/wrap-iife": [ "error", "inside" ],
"no-caller": "error",
- quotes: [ "error", "double" ],
+ "@stylistic/js/quotes": [ "error", "double" ],
"no-undef": "error",
"no-unused-vars": [
"error",
{
args: "all",
- argsIgnorePattern: "^_"
+ argsIgnorePattern: "^_",
+ caughtErrors: "none"
}
],
- "operator-linebreak": [ "error", "after" ],
- "comma-style": [ "error", "last" ],
- camelcase: [
+ "@stylistic/js/operator-linebreak": [ "error", "after" ],
+ "@stylistic/js/comma-style": [ "error", "last" ],
+ "camelcase": [
"error",
{
properties: "never"
@@ -36,7 +43,7 @@ module.exports = {
allowPattern: "^[a-z]+(_[a-z]+)+$"
}
],
- "max-len": [
+ "@stylistic/js/max-len": [
"error",
{
code: 100,
@@ -45,24 +52,24 @@ module.exports = {
ignoreRegExpLiterals: true
}
],
- "no-mixed-spaces-and-tabs": "error",
- "no-trailing-spaces": "error",
+ "@stylistic/js/no-mixed-spaces-and-tabs": "error",
+ "@stylistic/js/no-trailing-spaces": "error",
"no-irregular-whitespace": "error",
"no-multi-str": "error",
- "comma-dangle": [ "error", "never" ],
- "comma-spacing": [
+ "@stylistic/js/comma-dangle": [ "error", "never" ],
+ "@stylistic/js/comma-spacing": [
"error",
{
before: false,
after: true
}
],
- "space-before-blocks": [ "error", "always" ],
- "space-in-parens": [ "error", "always" ],
- "keyword-spacing": [ 2 ],
- "template-curly-spacing": [ "error", "always" ],
- semi: [ "error", "always" ],
- "semi-spacing": [
+ "@stylistic/js/space-before-blocks": [ "error", "always" ],
+ "@stylistic/js/space-in-parens": [ "error", "always" ],
+ "@stylistic/js/keyword-spacing": [ 2 ],
+ "@stylistic/js/template-curly-spacing": [ "error", "always" ],
+ "@stylistic/js/semi": [ "error", "always" ],
+ "@stylistic/js/semi-spacing": [
"error",
{
@@ -71,35 +78,35 @@ module.exports = {
after: true
}
],
- "no-extra-semi": "error",
- "space-infix-ops": "error",
- "eol-last": "error",
- "lines-around-comment": [
+ "@stylistic/js/no-extra-semi": "error",
+ "@stylistic/js/space-infix-ops": "error",
+ "@stylistic/js/eol-last": "error",
+ "@stylistic/js/lines-around-comment": [
"error",
{
beforeLineComment: true
}
],
- "linebreak-style": [ "error", "unix" ],
+ "@stylistic/js/linebreak-style": [ "error", "unix" ],
"no-with": "error",
- "brace-style": "error",
- "space-before-function-paren": [ "error", "never" ],
+ "@stylistic/js/brace-style": "error",
+ "@stylistic/js/space-before-function-paren": [ "error", "never" ],
"no-loop-func": "error",
- "no-spaced-func": "error",
- "key-spacing": [
+ "@stylistic/js/function-call-spacing": [ "error", "never" ],
+ "@stylistic/js/key-spacing": [
"error",
{
beforeColon: false,
afterColon: true
}
],
- "space-unary-ops": [
+ "@stylistic/js/space-unary-ops": [
"error",
{
words: false,
nonwords: false
}
],
- "no-multiple-empty-lines": 2
+ "@stylistic/js/no-multiple-empty-lines": 2
}
};
diff --git a/package.json b/package.json
index f1d678f..3acc480 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,13 @@
{
"name": "eslint-config-jquery",
- "version": "3.0.2",
+ "version": "4.0.0",
"description": "jQuery eslint config",
"main": "index.js",
+ "type": "module",
"scripts": {
- "test": "eslint ."
+ "test": "npm run copy-fixtures && npm run lint",
+ "lint": "eslint",
+ "copy-fixtures": "node copy-fixtures.js"
},
"repository": {
"type": "git",
@@ -25,7 +28,13 @@
],
"author": "Gaidarenko Oleg ",
"license": "MIT",
+ "dependencies": {
+ "@stylistic/eslint-plugin-js": "^2.9.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=9.0.0"
+ },
"devDependencies": {
- "eslint": "^8.5.0"
+ "eslint": "^9.12.0"
}
}
diff --git a/readme.md b/readme.md
index 0b47976..da6690f 100644
--- a/readme.md
+++ b/readme.md
@@ -6,11 +6,19 @@
npm install --save-dev eslint-config-jquery
```
-Configure ESLint with a `.eslintrc` file using the following contents:
-```json
-{
- "extends": "jquery"
-}
+Version 4.0.0 and above work for ESLint version 9.0.0 and above. Use version 3.0.2 for older ESLint versions.
+
+In your eslint.config file, import it and add it to your flat config array.
+
+```javascript
+import jquery from "eslint-config-jquery";
+
+export default [
+ // ... any other configurations,
+ jquery,
+ // ... any other configurations
+];
+
```
## Status
@@ -20,3 +28,11 @@ This config follows the spirit of the jQuery [code style](https://contribute.jqu
## Semver policy
Same approach as in ESLint, see https://github.com/eslint/eslint#user-content-semantic-versioning-policy.
+
+## Testing
+
+To avoid a circular dependency, testing copies JQuery source code into the test directory before running linting for
+this project.
+
+Note: JQuery 3.7.1 has an invalid eslint ignore statement that makes the tests fail for this project, but that must be
+fixed in JQuery itself.
diff --git a/test/fixtures/.eslintrc.js b/test/fixtures/.eslintrc.js
deleted file mode 100644
index cc9b8b4..0000000
--- a/test/fixtures/.eslintrc.js
+++ /dev/null
@@ -1,21 +0,0 @@
-module.exports = {
- globals: {
- window: true,
- define: true,
- module: true,
- Symbol: false
- },
-
- extends: "../../.eslintrc.js",
-
- root: true,
-
- rules: {
-
- // For the built version
- // TODO: do not use the built version to check the code
- "no-multiple-empty-lines": "off",
- "max-len": "off",
- "one-var": "off"
- }
-};
diff --git a/test/fixtures/jquery.js b/test/fixtures/jquery.js
deleted file mode 100644
index 6bb16b4..0000000
--- a/test/fixtures/jquery.js
+++ /dev/null
@@ -1,9611 +0,0 @@
-/*!
- * jQuery JavaScript Library v4.0.0-pre dc06d68bdc4c2562b5cc530f21e668a17d78ee2d
- * https://jquery.com/
- *
- * Copyright JS Foundation and other contributors
- * Released under the MIT license
- * https://jquery.org/license
- *
- * Date: 2020-04-29T14:37Z
- */
-( function( global, factory ) {
-
- "use strict";
-
- if ( typeof module === "object" && typeof module.exports === "object" ) {
-
- // For CommonJS and CommonJS-like environments where a proper `window`
- // is present, execute the factory and get jQuery.
- // For environments that do not have a `window` with a `document`
- // (such as Node.js), expose a factory as module.exports.
- // This accentuates the need for the creation of a real `window`.
- // e.g. var jQuery = require("jquery")(window);
- // See ticket #14549 for more info.
- module.exports = global.document ?
- factory( global, true ) :
- function( w ) {
- if ( !w.document ) {
- throw new Error( "jQuery requires a window with a document" );
- }
- return factory( w );
- };
- } else {
- factory( global );
- }
-
-// Pass this if window is not defined yet
-} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
-
-"use strict";
-
-var arr = [];
-
-var getProto = Object.getPrototypeOf;
-
-var slice = arr.slice;
-
-// Support: IE 11+, Edge 18+
-// Provide fallback for browsers without Array#flat.
-var flat = arr.flat ? function( array ) {
- return arr.flat.call( array );
-} : function( array ) {
- return arr.concat.apply( [], array );
-};
-
-var push = arr.push;
-
-var indexOf = arr.indexOf;
-
-// [[Class]] -> type pairs
-var class2type = {};
-
-var toString = class2type.toString;
-
-var hasOwn = class2type.hasOwnProperty;
-
-var fnToString = hasOwn.toString;
-
-var ObjectFunctionString = fnToString.call( Object );
-
-// All support tests are defined in their respective modules.
-var support = {};
-
-function isWindow( obj ) {
- return obj != null && obj === obj.window;
-}
-
-var document = window.document;
-
-var preservedScriptAttributes = {
- type: true,
- src: true,
- nonce: true,
- noModule: true
-};
-
-function DOMEval( code, node, doc ) {
- doc = doc || document;
-
- var i, val,
- script = doc.createElement( "script" );
-
- script.text = code;
- if ( node ) {
- for ( i in preservedScriptAttributes ) {
-
- // Support: Firefox <=64 - 66+, Edge <=18+
- // Some browsers don't support the "nonce" property on scripts.
- // On the other hand, just using `getAttribute` is not enough as
- // the `nonce` attribute is reset to an empty string whenever it
- // becomes browsing-context connected.
- // See https://github.com/whatwg/html/issues/2369
- // See https://html.spec.whatwg.org/#nonce-attributes
- // The `node.getAttribute` check was added for the sake of
- // `jQuery.globalEval` so that it can fake a nonce-containing node
- // via an object.
- val = node[ i ] || node.getAttribute && node.getAttribute( i );
- if ( val ) {
- script.setAttribute( i, val );
- }
- }
- }
- doc.head.appendChild( script ).parentNode.removeChild( script );
-}
-
-function toType( obj ) {
- if ( obj == null ) {
- return obj + "";
- }
-
- return typeof obj === "object" ?
- class2type[ toString.call( obj ) ] || "object" :
- typeof obj;
-}
-
-var version = "4.0.0-pre dc06d68bdc4c2562b5cc530f21e668a17d78ee2d",
-
- rhtmlSuffix = /HTML$/i,
-
- // Define a local copy of jQuery
- jQuery = function( selector, context ) {
-
- // The jQuery object is actually just the init constructor 'enhanced'
- // Need init if jQuery is called (just allow error to be thrown if not included)
- return new jQuery.fn.init( selector, context );
- };
-
-jQuery.fn = jQuery.prototype = {
-
- // The current version of jQuery being used
- jquery: version,
-
- constructor: jQuery,
-
- // The default length of a jQuery object is 0
- length: 0,
-
- toArray: function() {
- return slice.call( this );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
-
- // Return all the elements in a clean array
- if ( num == null ) {
- return slice.call( this );
- }
-
- // Return just the one element from the set
- return num < 0 ? this[ num + this.length ] : this[ num ];
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems ) {
-
- // Build a new jQuery matched element set
- var ret = jQuery.merge( this.constructor(), elems );
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- each: function( callback ) {
- return jQuery.each( this, callback );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map( this, function( elem, i ) {
- return callback.call( elem, i, elem );
- } ) );
- },
-
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ) );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- even: function() {
- return this.pushStack( jQuery.grep( this, function( _elem, i ) {
- return ( i + 1 ) % 2;
- } ) );
- },
-
- odd: function() {
- return this.pushStack( jQuery.grep( this, function( _elem, i ) {
- return i % 2;
- } ) );
- },
-
- eq: function( i ) {
- var len = this.length,
- j = +i + ( i < 0 ? len : 0 );
- return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
- },
-
- end: function() {
- return this.prevObject || this.constructor();
- }
-};
-
-jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[ 0 ] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
-
- // Skip the boolean and the target
- target = arguments[ i ] || {};
- i++;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && typeof target !== "function" ) {
- target = {};
- }
-
- // Extend jQuery itself if only one argument is passed
- if ( i === length ) {
- target = this;
- i--;
- }
-
- for ( ; i < length; i++ ) {
-
- // Only deal with non-null/undefined values
- if ( ( options = arguments[ i ] ) != null ) {
-
- // Extend the base object
- for ( name in options ) {
- copy = options[ name ];
-
- // Prevent Object.prototype pollution
- // Prevent never-ending loop
- if ( name === "__proto__" || target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
- ( copyIsArray = Array.isArray( copy ) ) ) ) {
- src = target[ name ];
-
- // Ensure proper type for the source value
- if ( copyIsArray && !Array.isArray( src ) ) {
- clone = [];
- } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
- clone = {};
- } else {
- clone = src;
- }
- copyIsArray = false;
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend( {
-
- // Unique for each copy of jQuery on the page
- expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
-
- // Assume jQuery is ready without the ready module
- isReady: true,
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- noop: function() {},
-
- isPlainObject: function( obj ) {
- var proto, Ctor;
-
- // Detect obvious negatives
- // Use toString instead of jQuery.type to catch host objects
- if ( !obj || toString.call( obj ) !== "[object Object]" ) {
- return false;
- }
-
- proto = getProto( obj );
-
- // Objects with no prototype (e.g., `Object.create( null )`) are plain
- if ( !proto ) {
- return true;
- }
-
- // Objects with prototype are plain iff they were constructed by a global Object function
- Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
- return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
- },
-
- isEmptyObject: function( obj ) {
- var name;
-
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- // Evaluates a script in a provided context; falls back to the global one
- // if not specified.
- globalEval: function( code, options, doc ) {
- DOMEval( code, { nonce: options && options.nonce }, doc );
- },
-
- each: function( obj, callback ) {
- var length, i = 0;
-
- if ( isArrayLike( obj ) ) {
- length = obj.length;
- for ( ; i < length; i++ ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
- break;
- }
- }
- }
-
- return obj;
- },
-
-
- // Retrieve the text value of an array of DOM nodes
- text: function( elem ) {
- var node,
- ret = "",
- i = 0,
- nodeType = elem.nodeType;
-
- if ( !nodeType ) {
-
- // If no nodeType, this is expected to be an array
- while ( ( node = elem[ i++ ] ) ) {
-
- // Do not traverse comment nodes
- ret += jQuery.text( node );
- }
- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
-
- // Use textContent for elements
- // innerText usage removed for consistency of new lines (jQuery #11153)
- if ( typeof elem.textContent === "string" ) {
- return elem.textContent;
- } else {
-
- // Traverse its children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- ret += jQuery.text( elem );
- }
- }
- } else if ( nodeType === 3 || nodeType === 4 ) {
- return elem.nodeValue;
- }
-
- // Do not include comment or processing instruction nodes
-
- return ret;
- },
-
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var ret = results || [];
-
- if ( arr != null ) {
- if ( isArrayLike( Object( arr ) ) ) {
- jQuery.merge( ret,
- typeof arr === "string" ?
- [ arr ] : arr
- );
- } else {
- push.call( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- return arr == null ? -1 : indexOf.call( arr, elem, i );
- },
-
- isXMLDoc: function( elem ) {
- var namespace = elem.namespaceURI,
- docElem = ( elem.ownerDocument || elem ).documentElement;
-
- // Assume HTML when documentElement doesn't yet exist, such as inside
- // document fragments.
- return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
- },
-
- merge: function( first, second ) {
- var len = +second.length,
- j = 0,
- i = first.length;
-
- for ( ; j < len; j++ ) {
- first[ i++ ] = second[ j ];
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, invert ) {
- var callbackInverse,
- matches = [],
- i = 0,
- length = elems.length,
- callbackExpect = !invert;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- callbackInverse = !callback( elems[ i ], i );
- if ( callbackInverse !== callbackExpect ) {
- matches.push( elems[ i ] );
- }
- }
-
- return matches;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var length, value,
- i = 0,
- ret = [];
-
- // Go through the array, translating each of the items to their new values
- if ( isArrayLike( elems ) ) {
- length = elems.length;
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( i in elems ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret.push( value );
- }
- }
- }
-
- // Flatten any nested arrays
- return flat( ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // jQuery.support is not used in Core but other projects attach their
- // properties to it so it needs to exist.
- support: support
-} );
-
-if ( typeof Symbol === "function" ) {
- jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
-}
-
-// Populate the class2type map
-jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
-function( _i, name ) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-} );
-
-function isArrayLike( obj ) {
-
- var length = !!obj && obj.length,
- type = toType( obj );
-
- if ( typeof obj === "function" || isWindow( obj ) ) {
- return false;
- }
-
- return type === "array" || length === 0 ||
- typeof length === "number" && length > 0 && ( length - 1 ) in obj;
-}
-
-function nodeName( elem, name ) {
-
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
-
-}
-
-var documentElement = document.documentElement;
-
-var pop = arr.pop;
-
-// https://www.w3.org/TR/css3-selectors/#whitespace
-var whitespace = "[\\x20\\t\\r\\n\\f]";
-
-var isIE = document.documentMode;
-
-var rbuggyQSA = [],
- testEl = document.createElement( "div" ),
- input = document.createElement( "input" );
-
-// Support: IE 9 - 11+
-// IE's :disabled selector does not pick up the children of disabled fieldsets
-if ( isIE ) {
- rbuggyQSA.push( ":enabled", ":disabled" );
-}
-
-// Support: IE 11+, Edge 15 - 18+
-// IE 11/Edge don't find elements on a `[name='']` query in some cases.
-// Adding a temporary attribute to the document before the selection works
-// around the issue.
-// Interestingly, IE 10 & older don't seem to have the issue.
-input.setAttribute( "name", "" );
-testEl.appendChild( input );
-if ( !testEl.querySelectorAll( "[name='']" ).length ) {
- rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
- whitespace + "*(?:''|\"\")" );
-}
-
-rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
-
-var rbuggyQSA$1 = rbuggyQSA;
-
-// Support: IE 9 - 11+, Edge 12 - 18+
-// IE/Edge don't support the :scope pseudo-class.
-try {
- document.querySelectorAll( ":scope" );
- support.scope = true;
-} catch ( e ) {}
-
-// Note: an element does not contain itself
-jQuery.contains = function( a, b ) {
- var adown = a.nodeType === 9 ? a.documentElement : a,
- bup = b && b.parentNode;
-
- return a === bup || !!( bup && bup.nodeType === 1 && (
-
- // Support: IE 9 - 11+
- // IE doesn't have `contains` on SVG.
- adown.contains ?
- adown.contains( bup ) :
- a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
- ) );
-};
-
-// CSS string/identifier serialization
-// https://drafts.csswg.org/cssom/#common-serializing-idioms
-var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
-
-function fcssescape( ch, asCodePoint ) {
- if ( asCodePoint ) {
-
- // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
- if ( ch === "\0" ) {
- return "\uFFFD";
- }
-
- // Control characters and (dependent upon position) numbers get escaped as code points
- return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
- }
-
- // Other potentially-special ASCII characters get backslash-escaped
- return "\\" + ch;
-}
-
-jQuery.escapeSelector = function( sel ) {
- return ( sel + "" ).replace( rcssescape, fcssescape );
-};
-
-var sort = arr.sort;
-
-var hasDuplicate;
-
-// Document order sorting
-function sortOrder( a, b ) {
-
- // Flag for duplicate removal
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
-
- // Sort on method existence if only one input has compareDocumentPosition
- var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
- if ( compare ) {
- return compare;
- }
-
- // Calculate position if both inputs belong to the same document
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
- a.compareDocumentPosition( b ) :
-
- // Otherwise we know they are disconnected
- 1;
-
- // Disconnected nodes
- if ( compare & 1 ) {
-
- // Choose the first element that is related to the document
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( a == document || a.ownerDocument == document &&
- jQuery.contains( document, a ) ) {
- return -1;
- }
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( b == document || b.ownerDocument == document &&
- jQuery.contains( document, b ) ) {
- return 1;
- }
-
- // Maintain original order
- return 0;
- }
-
- return compare & 4 ? -1 : 1;
-}
-
-/**
- * Document sorting and removing duplicates
- * @param {ArrayLike} results
- */
-jQuery.uniqueSort = function( results ) {
- var elem,
- duplicates = [],
- j = 0,
- i = 0;
-
- hasDuplicate = false;
-
- sort.call( results, sortOrder );
-
- if ( hasDuplicate ) {
- while ( ( elem = results[ i++ ] ) ) {
- if ( elem === results[ i ] ) {
- j = duplicates.push( i );
- }
- }
- while ( j-- ) {
- results.splice( duplicates[ j ], 1 );
- }
- }
-
- return results;
-};
-
-var preferredDoc = document,
- matches = documentElement.matches || documentElement.msMatchesSelector;
-
-( function() {
-
-var i,
- Expr,
- outermostContext,
-
- // Local document vars
- document,
- documentElement,
- documentIsHTML,
-
- // Instance-specific data
- expando = jQuery.expando,
- dirruns = 0,
- done = 0,
- classCache = createCache(),
- tokenCache = createCache(),
- compilerCache = createCache(),
- nonnativeSelectorCache = createCache(),
-
- booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" +
- "loop|multiple|open|readonly|required|scoped",
-
- // Regular expressions
-
- // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
- identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
- "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
-
- // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors
- attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
-
- // Operator (capture 2)
- "*([*^$|!~]?=)" + whitespace +
-
- // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
- "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
- whitespace + "*\\]",
-
- pseudos = ":(" + identifier + ")(?:\\((" +
-
- // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
- // 1. quoted (capture 3; capture 4 or capture 5)
- "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
-
- // 2. simple (capture 6)
- "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
-
- // 3. anything else (capture 2)
- ".*" +
- ")\\)|)",
-
- // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
- rwhitespace = new RegExp( whitespace + "+", "g" ),
- rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
-
- rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
- rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" +
- whitespace + "*" ),
- rdescend = new RegExp( whitespace + "|>" ),
-
- rpseudo = new RegExp( pseudos ),
- ridentifier = new RegExp( "^" + identifier + "$" ),
-
- matchExpr = {
- ID: new RegExp( "^#(" + identifier + ")" ),
- CLASS: new RegExp( "^\\.(" + identifier + ")" ),
- TAG: new RegExp( "^(" + identifier + "|[*])" ),
- ATTR: new RegExp( "^" + attributes ),
- PSEUDO: new RegExp( "^" + pseudos ),
- CHILD: new RegExp(
- "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
- whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
- whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
-
- // For use in libraries implementing .is()
- // We use this for POS matching in `select`
- needsContext: new RegExp( "^" + whitespace +
- "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
- "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
- },
-
- rinputs = /^(?:input|select|textarea|button)$/i,
- rheader = /^h\d$/i,
-
- // Easily-parseable/retrievable ID or TAG or CLASS selectors
- rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
-
- rsibling = /[+~]/,
-
- // CSS escapes
- // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
- runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace +
- "?|\\\\([^\\r\\n\\f])", "g" ),
- funescape = function( escape, nonHex ) {
- var high = "0x" + escape.slice( 1 ) - 0x10000;
-
- if ( nonHex ) {
-
- // Strip the backslash prefix from a non-hex escape sequence
- return nonHex;
- }
-
- // Replace a hexadecimal escape sequence with the encoded Unicode code point
- // Support: IE <=11+
- // For values outside the Basic Multilingual Plane (BMP), manually construct a
- // surrogate pair
- return high < 0 ?
- String.fromCharCode( high + 0x10000 ) :
- String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
- },
-
- // Used for iframes; see `setDocument`.
- // Support: IE 9 - 11+, Edge 12 - 18+
- // Removing the function wrapper causes a "Permission Denied"
- // error in IE/Edge.
- unloadHandler = function() {
- setDocument();
- },
-
- inDisabledFieldset = addCombinator(
- function( elem ) {
- return elem.disabled === true && nodeName( elem, "fieldset" );
- },
- { dir: "parentNode", next: "legend" }
- );
-
-function selectorError( msg ) {
- throw new Error( "Syntax error, unrecognized expression: " + msg );
-}
-
-function find( selector, context, results, seed ) {
- var m, i, elem, nid, match, groups, newSelector,
- newContext = context && context.ownerDocument,
-
- // nodeType defaults to 9, since context defaults to document
- nodeType = context ? context.nodeType : 9;
-
- results = results || [];
-
- // Return early from calls with invalid selector or context
- if ( typeof selector !== "string" || !selector ||
- nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
-
- return results;
- }
-
- // Try to shortcut find operations (as opposed to filters) in HTML documents
- if ( !seed ) {
- setDocument( context );
- context = context || document;
-
- if ( documentIsHTML ) {
-
- // If the selector is sufficiently simple, try using a "get*By*" DOM method
- // (excepting DocumentFragment context, where the methods don't exist)
- if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
-
- // ID selector
- if ( ( m = match[ 1 ] ) ) {
-
- // Document context
- if ( nodeType === 9 ) {
- if ( ( elem = context.getElementById( m ) ) ) {
- push.call( results, elem );
- }
- return results;
-
- // Element context
- } else {
- if ( newContext && ( elem = newContext.getElementById( m ) ) &&
- jQuery.contains( context, elem ) ) {
-
- push.call( results, elem );
- return results;
- }
- }
-
- // Type selector
- } else if ( match[ 2 ] ) {
- push.apply( results, context.getElementsByTagName( selector ) );
- return results;
-
- // Class selector
- } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) {
- push.apply( results, context.getElementsByClassName( m ) );
- return results;
- }
- }
-
- // Take advantage of querySelectorAll
- if ( !nonnativeSelectorCache[ selector + " " ] &&
- ( !rbuggyQSA$1 || !rbuggyQSA$1.test( selector ) ) ) {
-
- newSelector = selector;
- newContext = context;
-
- // qSA considers elements outside a scoping root when evaluating child or
- // descendant combinators, which is not what we want.
- // In such cases, we work around the behavior by prefixing every selector in the
- // list with an ID selector referencing the scope context.
- // The technique has to be used as well when a leading combinator is used
- // as such selectors are not recognized by querySelectorAll.
- // Thanks to Andrew Dupont for this technique.
- if ( nodeType === 1 &&
- ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
-
- // Expand context for sibling selectors
- newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
- context;
-
- // We can use :scope instead of the ID hack if the browser
- // supports it & if we're not changing the context.
- if ( newContext !== context || !support.scope ) {
-
- // Capture the context ID, setting it first if necessary
- if ( ( nid = context.getAttribute( "id" ) ) ) {
- nid = jQuery.escapeSelector( nid );
- } else {
- context.setAttribute( "id", ( nid = expando ) );
- }
- }
-
- // Prefix every selector in the list
- groups = tokenize( selector );
- i = groups.length;
- while ( i-- ) {
- groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
- toSelector( groups[ i ] );
- }
- newSelector = groups.join( "," );
- }
-
- try {
- push.apply( results,
- newContext.querySelectorAll( newSelector )
- );
- return results;
- } catch ( qsaError ) {
- nonnativeSelectorCache( selector, true );
- } finally {
- if ( nid === expando ) {
- context.removeAttribute( "id" );
- }
- }
- }
- }
- }
-
- // All others
- return select( selector.replace( rtrim, "$1" ), context, results, seed );
-}
-
-/**
- * Create key-value caches of limited size
- * @returns {function(string, object)} Returns the Object data after storing it on itself with
- * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
- * deleting the oldest entry
- */
-function createCache() {
- var keys = [];
-
- function cache( key, value ) {
-
- // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
- if ( keys.push( key + " " ) > Expr.cacheLength ) {
-
- // Only keep the most recent entries
- delete cache[ keys.shift() ];
- }
- return ( cache[ key + " " ] = value );
- }
- return cache;
-}
-
-/**
- * Mark a function for special use by jQuery selector module
- * @param {Function} fn The function to mark
- */
-function markFunction( fn ) {
- fn[ expando ] = true;
- return fn;
-}
-
-/**
- * Returns a function to use in pseudos for input types
- * @param {String} type
- */
-function createInputPseudo( type ) {
- return function( elem ) {
- return nodeName( elem, "input" ) && elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for buttons
- * @param {String} type
- */
-function createButtonPseudo( type ) {
- return function( elem ) {
- return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) &&
- elem.type === type;
- };
-}
-
-/**
- * Returns a function to use in pseudos for :enabled/:disabled
- * @param {Boolean} disabled true for :disabled; false for :enabled
- */
-function createDisabledPseudo( disabled ) {
-
- // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
- return function( elem ) {
-
- // Only certain elements can match :enabled or :disabled
- // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
- // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
- if ( "form" in elem ) {
-
- // Check for inherited disabledness on relevant non-disabled elements:
- // * listed form-associated elements in a disabled fieldset
- // https://html.spec.whatwg.org/multipage/forms.html#category-listed
- // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
- // * option elements in a disabled optgroup
- // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
- // All such elements have a "form" property.
- if ( elem.parentNode && elem.disabled === false ) {
-
- // Option elements defer to a parent optgroup if present
- if ( "label" in elem ) {
- if ( "label" in elem.parentNode ) {
- return elem.parentNode.disabled === disabled;
- } else {
- return elem.disabled === disabled;
- }
- }
-
- // Support: IE 6 - 11+
- // Use the isDisabled shortcut property to check for disabled fieldset ancestors
- return elem.isDisabled === disabled ||
-
- // Where there is no isDisabled, check manually
- /* jshint -W018 */
- elem.isDisabled !== !disabled &&
- inDisabledFieldset( elem ) === disabled;
- }
-
- return elem.disabled === disabled;
-
- // Try to winnow out elements that can't be disabled before trusting the disabled property.
- // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
- // even exist on them, let alone have a boolean value.
- } else if ( "label" in elem ) {
- return elem.disabled === disabled;
- }
-
- // Remaining elements are neither :enabled nor :disabled
- return false;
- };
-}
-
-/**
- * Returns a function to use in pseudos for positionals
- * @param {Function} fn
- */
-function createPositionalPseudo( fn ) {
- return markFunction( function( argument ) {
- argument = +argument;
- return markFunction( function( seed, matches ) {
- var j,
- matchIndexes = fn( [], seed.length, argument ),
- i = matchIndexes.length;
-
- // Match elements found at the specified indexes
- while ( i-- ) {
- if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
- seed[ j ] = !( matches[ j ] = seed[ j ] );
- }
- }
- } );
- } );
-}
-
-/**
- * Checks a node for validity as a jQuery selector context
- * @param {Element|Object=} context
- * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
- */
-function testContext( context ) {
- return context && typeof context.getElementsByTagName !== "undefined" && context;
-}
-
-/**
- * Sets document-related variables once based on the current document
- * @param {Element|Object} [node] An element or document object to use to set the document
- */
-function setDocument( node ) {
- var subWindow,
- doc = node ? node.ownerDocument || node : preferredDoc;
-
- // Return early if doc is invalid or already selected
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( doc == document || doc.nodeType !== 9 ) {
- return;
- }
-
- // Update global variables
- document = doc;
- documentElement = document.documentElement;
- documentIsHTML = !jQuery.isXMLDoc( document );
-
- // Support: IE 9 - 11+, Edge 12 - 18+
- // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( preferredDoc != document &&
- ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
-
- // Support: IE 9 - 11+, Edge 12 - 18+
- subWindow.addEventListener( "unload", unloadHandler );
- }
-}
-
-find.matches = function( expr, elements ) {
- return find( expr, null, null, elements );
-};
-
-find.matchesSelector = function( elem, expr ) {
- setDocument( elem );
-
- if ( documentIsHTML &&
- !nonnativeSelectorCache[ expr + " " ] &&
- ( !rbuggyQSA$1 || !rbuggyQSA$1.test( expr ) ) ) {
-
- try {
- return matches.call( elem, expr );
- } catch ( e ) {
- nonnativeSelectorCache( expr, true );
- }
- }
-
- return find( expr, document, null, [ elem ] ).length > 0;
-};
-
-Expr = jQuery.expr = {
-
- // Can be adjusted by the user
- cacheLength: 50,
-
- createPseudo: markFunction,
-
- match: matchExpr,
-
- find: {
- ID: function( id, context ) {
- if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
- var elem = context.getElementById( id );
- return elem ? [ elem ] : [];
- }
- },
-
- TAG: function( tag, context ) {
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- return context.getElementsByTagName( tag );
-
- // DocumentFragment nodes don't have gEBTN
- } else {
- return context.querySelectorAll( tag );
- }
- },
-
- CLASS: function( className, context ) {
- if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
- return context.getElementsByClassName( className );
- }
- }
- },
-
- relative: {
- ">": { dir: "parentNode", first: true },
- " ": { dir: "parentNode" },
- "+": { dir: "previousSibling", first: true },
- "~": { dir: "previousSibling" }
- },
-
- preFilter: {
- ATTR: function( match ) {
- match[ 1 ] = match[ 1 ].replace( runescape, funescape );
-
- // Move the given value to match[3] whether quoted or unquoted
- match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" )
- .replace( runescape, funescape );
-
- if ( match[ 2 ] === "~=" ) {
- match[ 3 ] = " " + match[ 3 ] + " ";
- }
-
- return match.slice( 0, 4 );
- },
-
- CHILD: function( match ) {
-
- /* matches from matchExpr["CHILD"]
- 1 type (only|nth|...)
- 2 what (child|of-type)
- 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
- 4 xn-component of xn+y argument ([+-]?\d*n|)
- 5 sign of xn-component
- 6 x of xn-component
- 7 sign of y-component
- 8 y of y-component
- */
- match[ 1 ] = match[ 1 ].toLowerCase();
-
- if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
-
- // nth-* requires argument
- if ( !match[ 3 ] ) {
- selectorError( match[ 0 ] );
- }
-
- // numeric x and y parameters for Expr.filter.CHILD
- // remember that false/true cast respectively to 0/1
- match[ 4 ] = +( match[ 4 ] ?
- match[ 5 ] + ( match[ 6 ] || 1 ) :
- 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" )
- );
- match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
-
- // other types prohibit arguments
- } else if ( match[ 3 ] ) {
- selectorError( match[ 0 ] );
- }
-
- return match;
- },
-
- PSEUDO: function( match ) {
- var excess,
- unquoted = !match[ 6 ] && match[ 2 ];
-
- if ( matchExpr.CHILD.test( match[ 0 ] ) ) {
- return null;
- }
-
- // Accept quoted arguments as-is
- if ( match[ 3 ] ) {
- match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
-
- // Strip excess characters from unquoted arguments
- } else if ( unquoted && rpseudo.test( unquoted ) &&
-
- // Get excess from tokenize (recursively)
- ( excess = tokenize( unquoted, true ) ) &&
-
- // advance to the next closing parenthesis
- ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
-
- // excess is a negative index
- match[ 0 ] = match[ 0 ].slice( 0, excess );
- match[ 2 ] = unquoted.slice( 0, excess );
- }
-
- // Return only captures needed by the pseudo filter method (type and argument)
- return match.slice( 0, 3 );
- }
- },
-
- filter: {
- ID: function( id ) {
- var attrId = id.replace( runescape, funescape );
- return function( elem ) {
- return elem.getAttribute( "id" ) === attrId;
- };
- },
-
- TAG: function( nodeNameSelector ) {
- var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
- return nodeNameSelector === "*" ?
- function() {
- return true;
-} :
- function( elem ) {
- return nodeName( elem, expectedNodeName );
- };
- },
-
- CLASS: function( className ) {
- var pattern = classCache[ className + " " ];
-
- return pattern ||
- ( pattern = new RegExp( "(^|" + whitespace + ")" + className +
- "(" + whitespace + "|$)" ) ) &&
- classCache( className, function( elem ) {
- return pattern.test(
- typeof elem.className === "string" && elem.className ||
- typeof elem.getAttribute !== "undefined" &&
- elem.getAttribute( "class" ) ||
- ""
- );
- } );
- },
-
- ATTR: function( name, operator, check ) {
- return function( elem ) {
- var result = jQuery.attr( elem, name );
-
- if ( result == null ) {
- return operator === "!=";
- }
- if ( !operator ) {
- return true;
- }
-
- result += "";
-
- if ( operator === "=" ) {
- return result === check;
- }
- if ( operator === "!=" ) {
- return result !== check;
- }
- if ( operator === "^=" ) {
- return check && result.indexOf( check ) === 0;
- }
- if ( operator === "*=" ) {
- return check && result.indexOf( check ) > -1;
- }
- if ( operator === "$=" ) {
- return check && result.slice( -check.length ) === check;
- }
- if ( operator === "~=" ) {
- return ( " " + result.replace( rwhitespace, " " ) + " " )
- .indexOf( check ) > -1;
- }
- if ( operator === "|=" ) {
- return result === check || result.slice( 0, check.length + 1 ) === check + "-";
- }
-
- return false;
- };
- },
-
- CHILD: function( type, what, _argument, first, last ) {
- var simple = type.slice( 0, 3 ) !== "nth",
- forward = type.slice( -4 ) !== "last",
- ofType = what === "of-type";
-
- return first === 1 && last === 0 ?
-
- // Shortcut for :nth-*(n)
- function( elem ) {
- return !!elem.parentNode;
- } :
-
- function( elem, _context, xml ) {
- var cache, outerCache, node, nodeIndex, start,
- dir = simple !== forward ? "nextSibling" : "previousSibling",
- parent = elem.parentNode,
- name = ofType && elem.nodeName.toLowerCase(),
- useCache = !xml && !ofType,
- diff = false;
-
- if ( parent ) {
-
- // :(first|last|only)-(child|of-type)
- if ( simple ) {
- while ( dir ) {
- node = elem;
- while ( ( node = node[ dir ] ) ) {
- if ( ofType ?
- nodeName( node, name ) :
- node.nodeType === 1 ) {
-
- return false;
- }
- }
-
- // Reverse direction for :only-* (if we haven't yet done so)
- start = dir = type === "only" && !start && "nextSibling";
- }
- return true;
- }
-
- start = [ forward ? parent.firstChild : parent.lastChild ];
-
- // non-xml :nth-child(...) stores cache data on `parent`
- if ( forward && useCache ) {
-
- // Seek `elem` from a previously-cached index
- outerCache = parent[ expando ] || ( parent[ expando ] = {} );
- cache = outerCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex && cache[ 2 ];
- node = nodeIndex && parent.childNodes[ nodeIndex ];
-
- while ( ( node = ++nodeIndex && node && node[ dir ] ||
-
- // Fallback to seeking `elem` from the start
- ( diff = nodeIndex = 0 ) || start.pop() ) ) {
-
- // When found, cache indexes on `parent` and break
- if ( node.nodeType === 1 && ++diff && node === elem ) {
- outerCache[ type ] = [ dirruns, nodeIndex, diff ];
- break;
- }
- }
-
- } else {
-
- // Use previously-cached element index if available
- if ( useCache ) {
- outerCache = elem[ expando ] || ( elem[ expando ] = {} );
- cache = outerCache[ type ] || [];
- nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
- diff = nodeIndex;
- }
-
- // xml :nth-child(...)
- // or :nth-last-child(...) or :nth(-last)?-of-type(...)
- if ( diff === false ) {
-
- // Use the same loop as above to seek `elem` from the start
- while ( ( node = ++nodeIndex && node && node[ dir ] ||
- ( diff = nodeIndex = 0 ) || start.pop() ) ) {
-
- if ( ( ofType ?
- nodeName( node, name ) :
- node.nodeType === 1 ) &&
- ++diff ) {
-
- // Cache the index of each encountered element
- if ( useCache ) {
- outerCache = node[ expando ] ||
- ( node[ expando ] = {} );
- outerCache[ type ] = [ dirruns, diff ];
- }
-
- if ( node === elem ) {
- break;
- }
- }
- }
- }
- }
-
- // Incorporate the offset, then check against cycle size
- diff -= last;
- return diff === first || ( diff % first === 0 && diff / first >= 0 );
- }
- };
- },
-
- PSEUDO: function( pseudo, argument ) {
-
- // pseudo-class names are case-insensitive
- // https://www.w3.org/TR/selectors/#pseudo-classes
- // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
- // Remember that setFilters inherits from pseudos
- var args,
- fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
- selectorError( "unsupported pseudo: " + pseudo );
-
- // The user may use createPseudo to indicate that
- // arguments are needed to create the filter function
- // just as jQuery does
- if ( fn[ expando ] ) {
- return fn( argument );
- }
-
- // But maintain support for old signatures
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
- markFunction( function( seed, matches ) {
- var idx,
- matched = fn( seed, argument ),
- i = matched.length;
- while ( i-- ) {
- idx = indexOf.call( seed, matched[ i ] );
- seed[ idx ] = !( matches[ idx ] = matched[ i ] );
- }
- } ) :
- function( elem ) {
- return fn( elem, 0, args );
- };
- }
-
- return fn;
- }
- },
-
- pseudos: {
-
- // Potentially complex pseudos
- not: markFunction( function( selector ) {
-
- // Trim the selector passed to compile
- // to avoid treating leading and trailing
- // spaces as combinators
- var input = [],
- results = [],
- matcher = compile( selector.replace( rtrim, "$1" ) );
-
- return matcher[ expando ] ?
- markFunction( function( seed, matches, _context, xml ) {
- var elem,
- unmatched = matcher( seed, null, xml, [] ),
- i = seed.length;
-
- // Match elements unmatched by `matcher`
- while ( i-- ) {
- if ( ( elem = unmatched[ i ] ) ) {
- seed[ i ] = !( matches[ i ] = elem );
- }
- }
- } ) :
- function( elem, _context, xml ) {
- input[ 0 ] = elem;
- matcher( input, null, xml, results );
-
- // Don't keep the element (issue #299)
- input[ 0 ] = null;
- return !results.pop();
- };
- } ),
-
- has: markFunction( function( selector ) {
- return function( elem ) {
- return find( selector, elem ).length > 0;
- };
- } ),
-
- contains: markFunction( function( text ) {
- text = text.replace( runescape, funescape );
- return function( elem ) {
- return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1;
- };
- } ),
-
- // "Whether an element is represented by a :lang() selector
- // is based solely on the element's language value
- // being equal to the identifier C,
- // or beginning with the identifier C immediately followed by "-".
- // The matching of C against the element's language value is performed case-insensitively.
- // The identifier C does not have to be a valid language name."
- // https://www.w3.org/TR/selectors/#lang-pseudo
- lang: markFunction( function( lang ) {
-
- // lang value must be a valid identifier
- if ( !ridentifier.test( lang || "" ) ) {
- selectorError( "unsupported lang: " + lang );
- }
- lang = lang.replace( runescape, funescape ).toLowerCase();
- return function( elem ) {
- var elemLang;
- do {
- if ( ( elemLang = documentIsHTML ?
- elem.lang :
- elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
-
- elemLang = elemLang.toLowerCase();
- return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
- }
- } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
- return false;
- };
- } ),
-
- // Miscellaneous
- target: function( elem ) {
- var hash = window.location && window.location.hash;
- return hash && hash.slice( 1 ) === elem.id;
- },
-
- root: function( elem ) {
- return elem === documentElement;
- },
-
- focus: function( elem ) {
- return elem === document.activeElement &&
- document.hasFocus() &&
- !!( elem.type || elem.href || ~elem.tabIndex );
- },
-
- // Boolean properties
- enabled: createDisabledPseudo( false ),
- disabled: createDisabledPseudo( true ),
-
- checked: function( elem ) {
-
- // In CSS3, :checked should return both checked and selected elements
- // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
- return ( nodeName( elem, "input" ) && !!elem.checked ) ||
- ( nodeName( elem, "option" ) && !!elem.selected );
- },
-
- selected: function( elem ) {
-
- // Support: IE <=11+
- // Accessing the selectedIndex property
- // forces the browser to treat the default option as
- // selected when in an optgroup.
- if ( elem.parentNode ) {
- // eslint-disable-next-line no-unused-expressions
- elem.parentNode.selectedIndex;
- }
-
- return elem.selected === true;
- },
-
- // Contents
- empty: function( elem ) {
-
- // https://www.w3.org/TR/selectors/#empty-pseudo
- // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
- // but not by others (comment: 8; processing instruction: 7; etc.)
- // nodeType < 6 works because attributes (2) do not appear as children
- for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
- if ( elem.nodeType < 6 ) {
- return false;
- }
- }
- return true;
- },
-
- parent: function( elem ) {
- return !Expr.pseudos.empty( elem );
- },
-
- // Element/input types
- header: function( elem ) {
- return rheader.test( elem.nodeName );
- },
-
- input: function( elem ) {
- return rinputs.test( elem.nodeName );
- },
-
- button: function( elem ) {
- return nodeName( elem, "input" ) && elem.type === "button" ||
- nodeName( elem, "button" );
- },
-
- text: function( elem ) {
- return nodeName( elem, "input" ) && elem.type === "text";
- },
-
- // Position-in-collection
- first: createPositionalPseudo( function() {
- return [ 0 ];
- } ),
-
- last: createPositionalPseudo( function( _matchIndexes, length ) {
- return [ length - 1 ];
- } ),
-
- eq: createPositionalPseudo( function( _matchIndexes, length, argument ) {
- return [ argument < 0 ? argument + length : argument ];
- } ),
-
- even: createPositionalPseudo( function( matchIndexes, length ) {
- var i = 0;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- odd: createPositionalPseudo( function( matchIndexes, length ) {
- var i = 1;
- for ( ; i < length; i += 2 ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- lt: createPositionalPseudo( function( matchIndexes, length, argument ) {
- var i;
-
- if ( argument < 0 ) {
- i = argument + length;
- } else if ( argument > length ) {
- i = length;
- } else {
- i = argument;
- }
-
- for ( ; --i >= 0; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } ),
-
- gt: createPositionalPseudo( function( matchIndexes, length, argument ) {
- var i = argument < 0 ? argument + length : argument;
- for ( ; ++i < length; ) {
- matchIndexes.push( i );
- }
- return matchIndexes;
- } )
- }
-};
-
-Expr.pseudos.nth = Expr.pseudos.eq;
-
-// Add button/input type pseudos
-for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
- Expr.pseudos[ i ] = createInputPseudo( i );
-}
-for ( i in { submit: true, reset: true } ) {
- Expr.pseudos[ i ] = createButtonPseudo( i );
-}
-
-// Easy API for creating new setFilters
-function setFilters() {}
-setFilters.prototype = Expr.filters = Expr.pseudos;
-Expr.setFilters = new setFilters();
-
-function tokenize( selector, parseOnly ) {
- var matched, match, tokens, type,
- soFar, groups, preFilters,
- cached = tokenCache[ selector + " " ];
-
- if ( cached ) {
- return parseOnly ? 0 : cached.slice( 0 );
- }
-
- soFar = selector;
- groups = [];
- preFilters = Expr.preFilter;
-
- while ( soFar ) {
-
- // Comma and first run
- if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
- if ( match ) {
-
- // Don't consume trailing commas as valid
- soFar = soFar.slice( match[ 0 ].length ) || soFar;
- }
- groups.push( ( tokens = [] ) );
- }
-
- matched = false;
-
- // Combinators
- if ( ( match = rcombinators.exec( soFar ) ) ) {
- matched = match.shift();
- tokens.push( {
- value: matched,
-
- // Cast descendant combinators to space
- type: match[ 0 ].replace( rtrim, " " )
- } );
- soFar = soFar.slice( matched.length );
- }
-
- // Filters
- for ( type in Expr.filter ) {
- if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
- ( match = preFilters[ type ]( match ) ) ) ) {
- matched = match.shift();
- tokens.push( {
- value: matched,
- type: type,
- matches: match
- } );
- soFar = soFar.slice( matched.length );
- }
- }
-
- if ( !matched ) {
- break;
- }
- }
-
- // Return the length of the invalid excess
- // if we're just parsing
- // Otherwise, throw an error or return tokens
- if ( parseOnly ) {
- return soFar.length;
- }
-
- return soFar ?
- selectorError( selector ) :
-
- // Cache the tokens
- tokenCache( selector, groups ).slice( 0 );
-}
-
-function toSelector( tokens ) {
- var i = 0,
- len = tokens.length,
- selector = "";
- for ( ; i < len; i++ ) {
- selector += tokens[ i ].value;
- }
- return selector;
-}
-
-function addCombinator( matcher, combinator, base ) {
- var dir = combinator.dir,
- skip = combinator.next,
- key = skip || dir,
- checkNonElements = base && key === "parentNode",
- doneName = done++;
-
- return combinator.first ?
-
- // Check against closest ancestor/preceding element
- function( elem, context, xml ) {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- return matcher( elem, context, xml );
- }
- }
- return false;
- } :
-
- // Check against all ancestor/preceding elements
- function( elem, context, xml ) {
- var oldCache, outerCache,
- newCache = [ dirruns, doneName ];
-
- // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
- if ( xml ) {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- if ( matcher( elem, context, xml ) ) {
- return true;
- }
- }
- }
- } else {
- while ( ( elem = elem[ dir ] ) ) {
- if ( elem.nodeType === 1 || checkNonElements ) {
- outerCache = elem[ expando ] || ( elem[ expando ] = {} );
-
- if ( skip && nodeName( elem, skip ) ) {
- elem = elem[ dir ] || elem;
- } else if ( ( oldCache = outerCache[ key ] ) &&
- oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
-
- // Assign to newCache so results back-propagate to previous elements
- return ( newCache[ 2 ] = oldCache[ 2 ] );
- } else {
-
- // Reuse newcache so results back-propagate to previous elements
- outerCache[ key ] = newCache;
-
- // A match means we're done; a fail means we have to keep checking
- if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
- return true;
- }
- }
- }
- }
- }
- return false;
- };
-}
-
-function elementMatcher( matchers ) {
- return matchers.length > 1 ?
- function( elem, context, xml ) {
- var i = matchers.length;
- while ( i-- ) {
- if ( !matchers[ i ]( elem, context, xml ) ) {
- return false;
- }
- }
- return true;
- } :
- matchers[ 0 ];
-}
-
-function multipleContexts( selector, contexts, results ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- find( selector, contexts[ i ], results );
- }
- return results;
-}
-
-function condense( unmatched, map, filter, context, xml ) {
- var elem,
- newUnmatched = [],
- i = 0,
- len = unmatched.length,
- mapped = map != null;
-
- for ( ; i < len; i++ ) {
- if ( ( elem = unmatched[ i ] ) ) {
- if ( !filter || filter( elem, context, xml ) ) {
- newUnmatched.push( elem );
- if ( mapped ) {
- map.push( i );
- }
- }
- }
- }
-
- return newUnmatched;
-}
-
-function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
- if ( postFilter && !postFilter[ expando ] ) {
- postFilter = setMatcher( postFilter );
- }
- if ( postFinder && !postFinder[ expando ] ) {
- postFinder = setMatcher( postFinder, postSelector );
- }
- return markFunction( function( seed, results, context, xml ) {
- var temp, i, elem, matcherOut,
- preMap = [],
- postMap = [],
- preexisting = results.length,
-
- // Get initial elements from seed or context
- elems = seed ||
- multipleContexts( selector || "*",
- context.nodeType ? [ context ] : context, [] ),
-
- // Prefilter to get matcher input, preserving a map for seed-results synchronization
- matcherIn = preFilter && ( seed || !selector ) ?
- condense( elems, preMap, preFilter, context, xml ) :
- elems;
-
- if ( matcher ) {
-
- // If we have a postFinder, or filtered seed, or non-seed postFilter
- // or preexisting results,
- matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-
- // ...intermediate processing is necessary
- [] :
-
- // ...otherwise use results directly
- results;
-
- // Find primary matches
- matcher( matcherIn, matcherOut, context, xml );
- } else {
- matcherOut = matcherIn;
- }
-
- // Apply postFilter
- if ( postFilter ) {
- temp = condense( matcherOut, postMap );
- postFilter( temp, [], context, xml );
-
- // Un-match failing elements by moving them back to matcherIn
- i = temp.length;
- while ( i-- ) {
- if ( ( elem = temp[ i ] ) ) {
- matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
- }
- }
- }
-
- if ( seed ) {
- if ( postFinder || preFilter ) {
- if ( postFinder ) {
-
- // Get the final matcherOut by condensing this intermediate into postFinder contexts
- temp = [];
- i = matcherOut.length;
- while ( i-- ) {
- if ( ( elem = matcherOut[ i ] ) ) {
-
- // Restore matcherIn since elem is not yet a final match
- temp.push( ( matcherIn[ i ] = elem ) );
- }
- }
- postFinder( null, ( matcherOut = [] ), temp, xml );
- }
-
- // Move matched elements from seed to results to keep them synchronized
- i = matcherOut.length;
- while ( i-- ) {
- if ( ( elem = matcherOut[ i ] ) &&
- ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) {
-
- seed[ temp ] = !( results[ temp ] = elem );
- }
- }
- }
-
- // Add elements to results, through postFinder if defined
- } else {
- matcherOut = condense(
- matcherOut === results ?
- matcherOut.splice( preexisting, matcherOut.length ) :
- matcherOut
- );
- if ( postFinder ) {
- postFinder( null, results, matcherOut, xml );
- } else {
- push.apply( results, matcherOut );
- }
- }
- } );
-}
-
-function matcherFromTokens( tokens ) {
- var checkContext, matcher, j,
- len = tokens.length,
- leadingRelative = Expr.relative[ tokens[ 0 ].type ],
- implicitRelative = leadingRelative || Expr.relative[ " " ],
- i = leadingRelative ? 1 : 0,
-
- // The foundational matcher ensures that elements are reachable from top-level context(s)
- matchContext = addCombinator( function( elem ) {
- return elem === checkContext;
- }, implicitRelative, true ),
- matchAnyContext = addCombinator( function( elem ) {
- return indexOf.call( checkContext, elem ) > -1;
- }, implicitRelative, true ),
- matchers = [ function( elem, context, xml ) {
- var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
- ( checkContext = context ).nodeType ?
- matchContext( elem, context, xml ) :
- matchAnyContext( elem, context, xml ) );
-
- // Avoid hanging onto element (issue #299)
- checkContext = null;
- return ret;
- } ];
-
- for ( ; i < len; i++ ) {
- if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
- matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
- } else {
- matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
-
- // Return special upon seeing a positional matcher
- if ( matcher[ expando ] ) {
-
- // Find the next relative operator (if any) for proper handling
- j = ++i;
- for ( ; j < len; j++ ) {
- if ( Expr.relative[ tokens[ j ].type ] ) {
- break;
- }
- }
- return setMatcher(
- i > 1 && elementMatcher( matchers ),
- i > 1 && toSelector(
-
- // If the preceding token was a descendant combinator, insert an implicit any-element `*`
- tokens.slice( 0, i - 1 )
- .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
- ).replace( rtrim, "$1" ),
- matcher,
- i < j && matcherFromTokens( tokens.slice( i, j ) ),
- j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
- j < len && toSelector( tokens )
- );
- }
- matchers.push( matcher );
- }
- }
-
- return elementMatcher( matchers );
-}
-
-function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
- var bySet = setMatchers.length > 0,
- byElement = elementMatchers.length > 0,
- superMatcher = function( seed, context, xml, results, outermost ) {
- var elem, j, matcher,
- matchedCount = 0,
- i = "0",
- unmatched = seed && [],
- setMatched = [],
- contextBackup = outermostContext,
-
- // We must always have either seed elements or outermost context
- elems = seed || byElement && Expr.find.TAG( "*", outermost ),
-
- // Use integer dirruns iff this is the outermost matcher
- dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 );
-
- if ( outermost ) {
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- outermostContext = context == document || context || outermost;
- }
-
- // Add elements passing elementMatchers directly to results
- for ( ; ( elem = elems[ i ] ) != null; i++ ) {
- if ( byElement && elem ) {
- j = 0;
-
- // Support: IE 11+, Edge 17 - 18+
- // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
- // two documents; shallow comparisons work.
- // eslint-disable-next-line eqeqeq
- if ( !context && elem.ownerDocument != document ) {
- setDocument( elem );
- xml = !documentIsHTML;
- }
- while ( ( matcher = elementMatchers[ j++ ] ) ) {
- if ( matcher( elem, context || document, xml ) ) {
- push.call( results, elem );
- break;
- }
- }
- if ( outermost ) {
- dirruns = dirrunsUnique;
- }
- }
-
- // Track unmatched elements for set filters
- if ( bySet ) {
-
- // They will have gone through all possible matchers
- if ( ( elem = !matcher && elem ) ) {
- matchedCount--;
- }
-
- // Lengthen the array for every element, matched or not
- if ( seed ) {
- unmatched.push( elem );
- }
- }
- }
-
- // `i` is now the count of elements visited above, and adding it to `matchedCount`
- // makes the latter nonnegative.
- matchedCount += i;
-
- // Apply set filters to unmatched elements
- // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
- // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
- // no element matchers and no seed.
- // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
- // case, which will result in a "00" `matchedCount` that differs from `i` but is also
- // numerically zero.
- if ( bySet && i !== matchedCount ) {
- j = 0;
- while ( ( matcher = setMatchers[ j++ ] ) ) {
- matcher( unmatched, setMatched, context, xml );
- }
-
- if ( seed ) {
-
- // Reintegrate element matches to eliminate the need for sorting
- if ( matchedCount > 0 ) {
- while ( i-- ) {
- if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
- setMatched[ i ] = pop.call( results );
- }
- }
- }
-
- // Discard index placeholder values to get only actual matches
- setMatched = condense( setMatched );
- }
-
- // Add matches to results
- push.apply( results, setMatched );
-
- // Seedless set matches succeeding multiple successful matchers stipulate sorting
- if ( outermost && !seed && setMatched.length > 0 &&
- ( matchedCount + setMatchers.length ) > 1 ) {
-
- jQuery.uniqueSort( results );
- }
- }
-
- // Override manipulation of globals by nested matchers
- if ( outermost ) {
- dirruns = dirrunsUnique;
- outermostContext = contextBackup;
- }
-
- return unmatched;
- };
-
- return bySet ?
- markFunction( superMatcher ) :
- superMatcher;
-}
-
-function compile( selector, match /* Internal Use Only */ ) {
- var i,
- setMatchers = [],
- elementMatchers = [],
- cached = compilerCache[ selector + " " ];
-
- if ( !cached ) {
-
- // Generate a function of recursive functions that can be used to check each element
- if ( !match ) {
- match = tokenize( selector );
- }
- i = match.length;
- while ( i-- ) {
- cached = matcherFromTokens( match[ i ] );
- if ( cached[ expando ] ) {
- setMatchers.push( cached );
- } else {
- elementMatchers.push( cached );
- }
- }
-
- // Cache the compiled function
- cached = compilerCache( selector,
- matcherFromGroupMatchers( elementMatchers, setMatchers ) );
-
- // Save selector and tokenization
- cached.selector = selector;
- }
- return cached;
-}
-
-/**
- * A low-level selection function that works with jQuery's compiled
- * selector functions
- * @param {String|Function} selector A selector or a pre-compiled
- * selector function built with jQuery selector compile
- * @param {Element} context
- * @param {Array} [results]
- * @param {Array} [seed] A set of elements to match against
- */
-function select( selector, context, results, seed ) {
- var i, tokens, token, type, find,
- compiled = typeof selector === "function" && selector,
- match = !seed && tokenize( ( selector = compiled.selector || selector ) );
-
- results = results || [];
-
- // Try to minimize operations if there is only one selector in the list and no seed
- // (the latter of which guarantees us context)
- if ( match.length === 1 ) {
-
- // Reduce context if the leading compound selector is an ID
- tokens = match[ 0 ] = match[ 0 ].slice( 0 );
- if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
- context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
-
- context = ( Expr.find.ID(
- token.matches[ 0 ].replace( runescape, funescape ),
- context
- ) || [] )[ 0 ];
- if ( !context ) {
- return results;
-
- // Precompiled matchers will still verify ancestry, so step up a level
- } else if ( compiled ) {
- context = context.parentNode;
- }
-
- selector = selector.slice( tokens.shift().value.length );
- }
-
- // Fetch a seed set for right-to-left matching
- i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length;
- while ( i-- ) {
- token = tokens[ i ];
-
- // Abort if we hit a combinator
- if ( Expr.relative[ ( type = token.type ) ] ) {
- break;
- }
- if ( ( find = Expr.find[ type ] ) ) {
-
- // Search, expanding context for leading sibling combinators
- if ( ( seed = find(
- token.matches[ 0 ].replace( runescape, funescape ),
- rsibling.test( tokens[ 0 ].type ) &&
- testContext( context.parentNode ) || context
- ) ) ) {
-
- // If seed is empty or no tokens remain, we can return early
- tokens.splice( i, 1 );
- selector = seed.length && toSelector( tokens );
- if ( !selector ) {
- push.apply( results, seed );
- return results;
- }
-
- break;
- }
- }
- }
- }
-
- // Compile and execute a filtering function if one is not provided
- // Provide `match` to avoid retokenization if we modified the selector above
- ( compiled || compile( selector, match ) )(
- seed,
- context,
- !documentIsHTML,
- results,
- !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
- );
- return results;
-}
-
-// Initialize against the default document
-setDocument();
-
-jQuery.find = find;
-
-} )();
-
-function dir( elem, dir, until ) {
- var matched = [],
- truncate = until !== undefined;
-
- while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
- if ( elem.nodeType === 1 ) {
- if ( truncate && jQuery( elem ).is( until ) ) {
- break;
- }
- matched.push( elem );
- }
- }
- return matched;
-}
-
-function siblings( n, elem ) {
- var matched = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- matched.push( n );
- }
- }
-
- return matched;
-}
-
-var rneedsContext = jQuery.expr.match.needsContext;
-
-// rsingleTag matches a string consisting of a single HTML element with no attributes
-// and captures the element's name
-var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
-
-// Implement the identical functionality for filter and not
-function winnow( elements, qualifier, not ) {
- if ( typeof qualifier === "function" ) {
- return jQuery.grep( elements, function( elem, i ) {
- return !!qualifier.call( elem, i, elem ) !== not;
- } );
- }
-
- // Single element
- if ( qualifier.nodeType ) {
- return jQuery.grep( elements, function( elem ) {
- return ( elem === qualifier ) !== not;
- } );
- }
-
- // Arraylike of elements (jQuery, arguments, Array)
- if ( typeof qualifier !== "string" ) {
- return jQuery.grep( elements, function( elem ) {
- return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
- } );
- }
-
- // Filtered directly for both simple and complex selectors
- return jQuery.filter( qualifier, elements, not );
-}
-
-jQuery.filter = function( expr, elems, not ) {
- var elem = elems[ 0 ];
-
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
-
- if ( elems.length === 1 && elem.nodeType === 1 ) {
- return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
- }
-
- return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
- return elem.nodeType === 1;
- } ) );
-};
-
-jQuery.fn.extend( {
- find: function( selector ) {
- var i, ret,
- len = this.length,
- self = this;
-
- if ( typeof selector !== "string" ) {
- return this.pushStack( jQuery( selector ).filter( function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( self[ i ], this ) ) {
- return true;
- }
- }
- } ) );
- }
-
- ret = this.pushStack( [] );
-
- for ( i = 0; i < len; i++ ) {
- jQuery.find( selector, self[ i ], ret );
- }
-
- return len > 1 ? jQuery.uniqueSort( ret ) : ret;
- },
- filter: function( selector ) {
- return this.pushStack( winnow( this, selector || [], false ) );
- },
- not: function( selector ) {
- return this.pushStack( winnow( this, selector || [], true ) );
- },
- is: function( selector ) {
- return !!winnow(
- this,
-
- // If this is a positional/relative selector, check membership in the returned set
- // so $("p:first").is("p:last") won't return true for a doc with two "p".
- typeof selector === "string" && rneedsContext.test( selector ) ?
- jQuery( selector ) :
- selector || [],
- false
- ).length;
- }
-} );
-
-// Initialize a jQuery object
-
-// A central reference to the root jQuery(document)
-var rootjQuery,
-
- // A simple way to check for HTML strings
- // Prioritize #id over to avoid XSS via location.hash (#9521)
- // Strict HTML recognition (#11290: must start with <)
- // Shortcut simple #id case for speed
- rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
-
- init = jQuery.fn.init = function( selector, context, root ) {
- var match, elem;
-
- // HANDLE: $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // Method init() accepts an alternate rootjQuery
- // so migrate can support jQuery.sub (gh-2101)
- root = root || rootjQuery;
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector[ 0 ] === "<" &&
- selector[ selector.length - 1 ] === ">" &&
- selector.length >= 3 ) {
-
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && ( match[ 1 ] || !context ) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[ 1 ] ) {
- context = context instanceof jQuery ? context[ 0 ] : context;
-
- // Option to run scripts is true for back-compat
- // Intentionally let the error be thrown if parseHTML is not present
- jQuery.merge( this, jQuery.parseHTML(
- match[ 1 ],
- context && context.nodeType ? context.ownerDocument || context : document,
- true
- ) );
-
- // HANDLE: $(html, props)
- if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
- for ( match in context ) {
-
- // Properties of context are called as methods if possible
- if ( typeof this[ match ] === "function" ) {
- this[ match ]( context[ match ] );
-
- // ...and otherwise set as attributes
- } else {
- this.attr( match, context[ match ] );
- }
- }
- }
-
- return this;
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[ 2 ] );
-
- if ( elem ) {
-
- // Inject the element directly into the jQuery object
- this[ 0 ] = elem;
- this.length = 1;
- }
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || root ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(DOMElement)
- } else if ( selector.nodeType ) {
- this[ 0 ] = selector;
- this.length = 1;
- return this;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( typeof selector === "function" ) {
- return root.ready !== undefined ?
- root.ready( selector ) :
-
- // Execute immediately if ready is not present
- selector( jQuery );
- }
-
- return jQuery.makeArray( selector, this );
- };
-
-// Give the init function the jQuery prototype for later instantiation
-init.prototype = jQuery.fn;
-
-// Initialize central reference
-rootjQuery = jQuery( document );
-
-var rparentsprev = /^(?:parents|prev(?:Until|All))/,
-
- // Methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
-
-jQuery.fn.extend( {
- has: function( target ) {
- var targets = jQuery( target, this ),
- l = targets.length;
-
- return this.filter( function() {
- var i = 0;
- for ( ; i < l; i++ ) {
- if ( jQuery.contains( this, targets[ i ] ) ) {
- return true;
- }
- }
- } );
- },
-
- closest: function( selectors, context ) {
- var cur,
- i = 0,
- l = this.length,
- matched = [],
- targets = typeof selectors !== "string" && jQuery( selectors );
-
- // Positional selectors never match, since there's no _selection_ context
- if ( !rneedsContext.test( selectors ) ) {
- for ( ; i < l; i++ ) {
- for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
-
- // Always skip document fragments
- if ( cur.nodeType < 11 && ( targets ?
- targets.index( cur ) > -1 :
-
- // Don't pass non-elements to jQuery#find
- cur.nodeType === 1 &&
- jQuery.find.matchesSelector( cur, selectors ) ) ) {
-
- matched.push( cur );
- break;
- }
- }
- }
- }
-
- return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
- },
-
- // Determine the position of an element within the set
- index: function( elem ) {
-
- // No argument, return index in parent
- if ( !elem ) {
- return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
- }
-
- // Index in selector
- if ( typeof elem === "string" ) {
- return indexOf.call( jQuery( elem ), this[ 0 ] );
- }
-
- // Locate the position of the desired element
- return indexOf.call( this,
-
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[ 0 ] : elem
- );
- },
-
- add: function( selector, context ) {
- return this.pushStack(
- jQuery.uniqueSort(
- jQuery.merge( this.get(), jQuery( selector, context ) )
- )
- );
- },
-
- addBack: function( selector ) {
- return this.add( selector == null ?
- this.prevObject : this.prevObject.filter( selector )
- );
- }
-} );
-
-function sibling( cur, dir ) {
- while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
- return cur;
-}
-
-jQuery.each( {
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, _i, until ) {
- return dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return sibling( elem, "nextSibling" );
- },
- prev: function( elem ) {
- return sibling( elem, "previousSibling" );
- },
- nextAll: function( elem ) {
- return dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, _i, until ) {
- return dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, _i, until ) {
- return dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return siblings( ( elem.parentNode || {} ).firstChild, elem );
- },
- children: function( elem ) {
- return siblings( elem.firstChild );
- },
- contents: function( elem ) {
- if ( elem.contentDocument != null &&
-
- // Support: IE 11+
- //