repo stringlengths 5 106 | file_url stringlengths 78 301 | file_path stringlengths 4 211 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:56:49 2026-01-05 02:23:25 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/deferred.js | src/deferred.js | import { jQuery } from "./core.js";
import { slice } from "./var/slice.js";
import "./callbacks.js";
function Identity( v ) {
return v;
}
function Thrower( ex ) {
throw ex;
}
function adoptValue( value, resolve, reject, noValue ) {
var method;
try {
// Check for promise aspect first to privilege synchronous behavior
if ( value && typeof( method = value.promise ) === "function" ) {
method.call( value ).done( resolve ).fail( reject );
// Other thenables
} else if ( value && typeof( method = value.then ) === "function" ) {
method.call( value, resolve, reject );
// Other non-thenables
} else {
// Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
// * false: [ value ].slice( 0 ) => resolve( value )
// * true: [ value ].slice( 1 ) => resolve()
resolve.apply( undefined, [ value ].slice( noValue ) );
}
// 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 ( value ) {
reject( value );
}
}
jQuery.extend( {
Deferred: function( func ) {
var tuples = [
// action, add listener, callbacks,
// ... .then handlers, argument index, [final state]
[ "notify", "progress", jQuery.Callbacks( "memory" ),
jQuery.Callbacks( "memory" ), 2 ],
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
],
state = "pending",
promise = {
state: function() {
return state;
},
always: function() {
deferred.done( arguments ).fail( arguments );
return this;
},
catch: function( fn ) {
return promise.then( null, fn );
},
// Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( _i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = typeof fns[ tuple[ 4 ] ] === "function" &&
fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && typeof returned.promise === "function" ) {
returned.promise()
.progress( newDefer.notify )
.done( newDefer.resolve )
.fail( newDefer.reject );
} else {
newDefer[ tuple[ 0 ] + "With" ](
this,
fn ? [ returned ] : arguments
);
}
} );
} );
fns = null;
} ).promise();
},
then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0;
function resolve( depth, deferred, handler, special ) {
return function() {
var that = this,
args = arguments,
mightThrow = function() {
var returned, then;
// Support: Promises/A+ section 2.3.3.3.3
// https://promisesaplus.com/#point-59
// Ignore double-resolution attempts
if ( depth < maxDepth ) {
return;
}
returned = handler.apply( that, args );
// Support: Promises/A+ section 2.3.1
// https://promisesaplus.com/#point-48
if ( returned === deferred.promise() ) {
throw new TypeError( "Thenable self-resolution" );
}
// Support: Promises/A+ sections 2.3.3.1, 3.5
// https://promisesaplus.com/#point-54
// https://promisesaplus.com/#point-75
// Retrieve `then` only once
then = returned &&
// Support: Promises/A+ section 2.3.4
// https://promisesaplus.com/#point-64
// Only check objects and functions for thenability
( typeof returned === "object" ||
typeof returned === "function" ) &&
returned.then;
// Handle a returned thenable
if ( typeof then === "function" ) {
// Special processors (notify) just wait for resolution
if ( special ) {
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special )
);
// Normal processors (resolve) also hook into progress
} else {
// ...and disregard older resolution values
maxDepth++;
then.call(
returned,
resolve( maxDepth, deferred, Identity, special ),
resolve( maxDepth, deferred, Thrower, special ),
resolve( maxDepth, deferred, Identity,
deferred.notifyWith )
);
}
// Handle all other returned values
} else {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Identity ) {
that = undefined;
args = [ returned ];
}
// Process the value(s)
// Default process is resolve
( special || deferred.resolveWith )( that, args );
}
},
// Only normal processors (resolve) catch and reject exceptions
process = special ?
mightThrow :
function() {
try {
mightThrow();
} catch ( e ) {
if ( jQuery.Deferred.exceptionHook ) {
jQuery.Deferred.exceptionHook( e,
process.error );
}
// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitute handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Thrower ) {
that = undefined;
args = [ e ];
}
deferred.rejectWith( that, args );
}
}
};
// Support: Promises/A+ section 2.3.3.3.1
// https://promisesaplus.com/#point-57
// Re-resolve promises immediately to dodge false rejection from
// subsequent errors
if ( depth ) {
process();
} else {
// Call an optional hook to record the error, in case of exception
// since it's otherwise lost when execution goes async
if ( jQuery.Deferred.getErrorHook ) {
process.error = jQuery.Deferred.getErrorHook();
}
window.setTimeout( process );
}
};
}
return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add(
resolve(
0,
newDefer,
typeof onProgress === "function" ?
onProgress :
Identity,
newDefer.notifyWith
)
);
// fulfilled_handlers.add( ... )
tuples[ 1 ][ 3 ].add(
resolve(
0,
newDefer,
typeof onFulfilled === "function" ?
onFulfilled :
Identity
)
);
// rejected_handlers.add( ... )
tuples[ 2 ][ 3 ].add(
resolve(
0,
newDefer,
typeof onRejected === "function" ?
onRejected :
Thrower
)
);
} ).promise();
},
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
return obj != null ? jQuery.extend( obj, promise ) : promise;
}
},
deferred = {};
// Add list-specific methods
jQuery.each( tuples, function( i, tuple ) {
var list = tuple[ 2 ],
stateString = tuple[ 5 ];
// promise.progress = list.add
// promise.done = list.add
// promise.fail = list.add
promise[ tuple[ 1 ] ] = list.add;
// Handle state
if ( stateString ) {
list.add(
function() {
// state = "resolved" (i.e., fulfilled)
// state = "rejected"
state = stateString;
},
// rejected_callbacks.disable
// fulfilled_callbacks.disable
tuples[ 3 - i ][ 2 ].disable,
// rejected_handlers.disable
// fulfilled_handlers.disable
tuples[ 3 - i ][ 3 ].disable,
// progress_callbacks.lock
tuples[ 0 ][ 2 ].lock,
// progress_handlers.lock
tuples[ 0 ][ 3 ].lock
);
}
// progress_handlers.fire
// fulfilled_handlers.fire
// rejected_handlers.fire
list.add( tuple[ 3 ].fire );
// deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
return this;
};
// deferred.notifyWith = list.fireWith
// deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
} );
// Make the deferred a promise
promise.promise( deferred );
// Call given func if any
if ( func ) {
func.call( deferred, deferred );
}
// All done!
return deferred;
},
// Deferred helper
when: function( singleValue ) {
var
// count of uncompleted subordinates
remaining = arguments.length,
// count of unprocessed arguments
i = remaining,
// subordinate fulfillment data
resolveContexts = Array( i ),
resolveValues = slice.call( arguments ),
// the primary Deferred
primary = jQuery.Deferred(),
// subordinate callback factory
updateFunc = function( i ) {
return function( value ) {
resolveContexts[ i ] = this;
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( !( --remaining ) ) {
primary.resolveWith( resolveContexts, resolveValues );
}
};
};
// Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) {
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
!remaining );
// Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( primary.state() === "pending" ||
typeof( resolveValues[ i ] && resolveValues[ i ].then ) === "function" ) {
return primary.then();
}
}
// Multiple arguments are aggregated like Promise.all array elements
while ( i-- ) {
adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
}
return primary.promise();
}
} );
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector.js | src/selector.js | import { jQuery } from "./core.js";
import { nodeName } from "./core/nodeName.js";
import { document as preferredDoc } from "./var/document.js";
import { indexOf } from "./var/indexOf.js";
import { pop } from "./var/pop.js";
import { push } from "./var/push.js";
import { whitespace } from "./var/whitespace.js";
import { rbuggyQSA } from "./selector/rbuggyQSA.js";
import { rtrimCSS } from "./var/rtrimCSS.js";
import { isIE } from "./var/isIE.js";
import { identifier } from "./selector/var/identifier.js";
import { rleadingCombinator } from "./selector/var/rleadingCombinator.js";
import { rdescend } from "./selector/var/rdescend.js";
import { rsibling } from "./selector/var/rsibling.js";
import { matches } from "./selector/var/matches.js";
import { createCache } from "./selector/createCache.js";
import { testContext } from "./selector/testContext.js";
import { filterMatchExpr } from "./selector/filterMatchExpr.js";
import { preFilter } from "./selector/preFilter.js";
import { selectorError } from "./selector/selectorError.js";
import { unescapeSelector } from "./selector/unescapeSelector.js";
import { tokenize } from "./selector/tokenize.js";
import { toSelector } from "./selector/toSelector.js";
// The following utils are attached directly to the jQuery object.
import "./attributes/attr.js"; // jQuery.attr
import "./selector/escapeSelector.js";
import "./selector/uniqueSort.js";
var i,
outermostContext,
// Local document vars
document,
documentElement,
documentIsHTML,
// Instance-specific data
dirruns = 0,
done = 0,
classCache = createCache(),
compilerCache = createCache(),
nonnativeSelectorCache = createCache(),
// Regular expressions
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
rwhitespace = new RegExp( whitespace + "+", "g" ),
ridentifier = new RegExp( "^" + identifier + "$" ),
matchExpr = jQuery.extend( {
// 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" )
}, filterMatchExpr ),
rinputs = /^(?:input|select|textarea|button)$/i,
rheader = /^h\d$/i,
// Easily-parseable/retrievable ID or TAG or CLASS selectors
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
// Used for iframes; see `setDocument`.
// Support: IE 9 - 11+
// Removing the function wrapper causes a "Permission Denied"
// error in IE.
unloadHandler = function() {
setDocument();
},
inDisabledFieldset = addCombinator(
function( elem ) {
return elem.disabled === true && nodeName( elem, "fieldset" );
},
{ dir: "parentNode", next: "legend" }
);
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 || !rbuggyQSA.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 ) || rleadingCombinator.test( selector ) ) ) {
// Expand context for sibling selectors
newContext = rsibling.test( selector ) &&
testContext( context.parentNode ) ||
context;
// Outside of IE, if we're not changing the context we can
// use :scope instead of an ID.
// Support: IE 11+
// IE sometimes throws a "Permission denied" error when strict-comparing
// two documents; shallow comparisons work.
// eslint-disable-next-line eqeqeq
if ( newContext != context || isIE ) {
// Capture the context ID, setting it first if necessary
if ( ( nid = context.getAttribute( "id" ) ) ) {
nid = jQuery.escapeSelector( nid );
} else {
context.setAttribute( "id", ( nid = jQuery.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 === jQuery.expando ) {
context.removeAttribute( "id" );
}
}
}
}
}
// All others
return select( selector.replace( rtrimCSS, "$1" ), context, results, seed );
}
/**
* Mark a function for special use by jQuery selector module
* @param {Function} fn The function to mark
*/
function markFunction( fn ) {
fn[ jQuery.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
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 ] );
}
}
} );
} );
}
/**
* 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+
// IE sometimes throws 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+
// Accessing iframe documents after unload throws "permission denied" errors (see trac-13936)
// Support: IE 11+
// IE sometimes throws a "Permission denied" error when strict-comparing
// two documents; shallow comparisons work.
// eslint-disable-next-line eqeqeq
if ( isIE && preferredDoc != document &&
( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
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 || !rbuggyQSA.test( expr ) ) ) {
try {
return matches.call( elem, expr );
} catch ( e ) {
nonnativeSelectorCache( expr, true );
}
}
return find( expr, document, null, [ elem ] ).length > 0;
};
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: preFilter,
filter: {
ID: function( id ) {
var attrId = unescapeSelector( id );
return function( elem ) {
return elem.getAttribute( "id" ) === attrId;
};
},
TAG: function( nodeNameSelector ) {
var expectedNodeName = unescapeSelector( nodeNameSelector ).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[ jQuery.expando ] ||
( parent[ jQuery.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[ jQuery.expando ] ||
( elem[ jQuery.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[ jQuery.expando ] ||
( node[ jQuery.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 fn = jQuery.expr.pseudos[ pseudo ] ||
jQuery.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[ jQuery.expando ] ) {
return fn( argument );
}
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( rtrimCSS, "$1" ) );
return matcher[ jQuery.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
// (see https://github.com/jquery/sizzle/issues/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 = unescapeSelector( text );
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 = unescapeSelector( lang ).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 ( isIE && 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 !jQuery.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;
} )
}
};
jQuery.expr.pseudos.nth = jQuery.expr.pseudos.eq;
// Add button/input type pseudos
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
jQuery.expr.pseudos[ i ] = createInputPseudo( i );
}
for ( i in { submit: true, reset: true } ) {
jQuery.expr.pseudos[ i ] = createButtonPseudo( i );
}
// Easy API for creating new setFilters
function setFilters() {}
setFilters.prototype = jQuery.expr.pseudos;
jQuery.expr.setFilters = new setFilters();
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[ jQuery.expando ] || ( elem[ jQuery.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[ jQuery.expando ] ) {
postFilter = setMatcher( postFilter );
}
if ( postFinder && !postFinder[ jQuery.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 = jQuery.expr.relative[ tokens[ 0 ].type ],
implicitRelative = leadingRelative || jQuery.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 ) {
// Support: IE 11+
// IE sometimes throws a "Permission denied" error when strict-comparing
// two documents; shallow comparisons work.
// eslint-disable-next-line eqeqeq
var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || (
( checkContext = context ).nodeType ?
matchContext( elem, context, xml ) :
matchAnyContext( elem, context, xml ) );
// Avoid hanging onto element
// (see https://github.com/jquery/sizzle/issues/299)
checkContext = null;
return ret;
} ];
for ( ; i < len; i++ ) {
if ( ( matcher = jQuery.expr.relative[ tokens[ i ].type ] ) ) {
matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
} else {
matcher = jQuery.expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
// Return special upon seeing a positional matcher
if ( matcher[ jQuery.expando ] ) {
// Find the next relative operator (if any) for proper handling
j = ++i;
for ( ; j < len; j++ ) {
if ( jQuery.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( rtrimCSS, "$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 && jQuery.expr.find.TAG( "*", outermost ),
// Use integer dirruns iff this is the outermost matcher
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | true |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/jquery.js | src/jquery.js | import { jQuery } from "./core.js";
import "./selector.js";
import "./traversing.js";
import "./callbacks.js";
import "./deferred.js";
import "./deferred/exceptionHook.js";
import "./core/ready.js";
import "./data.js";
import "./queue.js";
import "./queue/delay.js";
import "./attributes.js";
import "./event.js";
import "./event/trigger.js";
import "./manipulation.js";
import "./manipulation/_evalUrl.js";
import "./wrap.js";
import "./css.js";
import "./css/hiddenVisibleSelectors.js";
import "./css/showHide.js";
import "./serialize.js";
import "./ajax.js";
import "./ajax/xhr.js";
import "./ajax/script.js";
import "./ajax/jsonp.js";
import "./ajax/binary.js";
import "./ajax/load.js";
import "./core/parseXML.js";
import "./core/parseHTML.js";
import "./effects.js";
import "./effects/animatedSelector.js";
import "./offset.js";
import "./dimensions.js";
import "./deprecated.js";
import "./exports/amd.js";
import "./exports/global.js";
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/serialize.js | src/serialize.js | import { jQuery } from "./core.js";
import { toType } from "./core/toType.js";
import { rcheckableType } from "./var/rcheckableType.js";
import "./core/init.js";
import "./traversing.js"; // filter
import "./attributes/prop.js";
var
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
rsubmittable = /^(?:input|select|textarea|keygen)/i;
function buildParams( prefix, obj, traditional, add ) {
var name;
if ( Array.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
} else {
// Item is non-scalar (array or object), encode its numeric index.
buildParams(
prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
v,
traditional,
add
);
}
} );
} else if ( !traditional && toType( obj ) === "object" ) {
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
// Serialize scalar item.
add( prefix, obj );
}
}
// Serialize an array of form elements or a set of
// key/values into a query string
jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, valueOrFunction ) {
// If value is a function, invoke it and use its return value
var value = typeof valueOrFunction === "function" ?
valueOrFunction() :
valueOrFunction;
s[ s.length ] = encodeURIComponent( key ) + "=" +
encodeURIComponent( value == null ? "" : value );
};
if ( a == null ) {
return "";
}
// If an array was passed in, assume that it is an array of form elements.
if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
} );
} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
}
}
// Return the resulting serialization
return s.join( "&" );
};
jQuery.fn.extend( {
serialize: function() {
return jQuery.param( this.serializeArray() );
},
serializeArray: function() {
return this.map( function() {
// Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this;
} ).filter( function() {
var type = this.type;
// Use .is( ":disabled" ) so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
} ).map( function( _i, elem ) {
var val = jQuery( this ).val();
if ( val == null ) {
return null;
}
if ( Array.isArray( val ) ) {
return jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
} );
}
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
} ).get();
}
} );
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/wrapper-factory.js | src/wrapper-factory.js | /*!
* jQuery JavaScript Library v@VERSION
* https://jquery.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.com/license/
*
* Date: @DATE
*/
// Expose a factory as `jQueryFactory`. Aimed at environments without
// a real `window` where an emulated window needs to be constructed. Example:
//
// const jQuery = require( "jquery/factory" )( window );
//
// See ticket trac-14549 for more info.
function jQueryFactoryWrapper( window, noGlobal ) {
"use strict";
if ( !window.document ) {
throw new Error( "jQuery requires a window with a document" );
}
// @CODE
// build.js inserts compiled jQuery here
return jQuery;
}
function jQueryFactory( window ) {
"use strict";
return jQueryFactoryWrapper( window, true );
}
module.exports = { jQueryFactory: jQueryFactory };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/event.js | src/event.js | import { jQuery } from "./core.js";
import { documentElement } from "./var/documentElement.js";
import { rnothtmlwhite } from "./var/rnothtmlwhite.js";
import { rcheckableType } from "./var/rcheckableType.js";
import { slice } from "./var/slice.js";
import { isIE } from "./var/isIE.js";
import { acceptData } from "./data/var/acceptData.js";
import { dataPriv } from "./data/var/dataPriv.js";
import { nodeName } from "./core/nodeName.js";
import "./core/init.js";
import "./selector.js";
var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
function on( elem, types, selector, data, fn, one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
on( elem, type, selector, data, types[ type ], one );
}
return elem;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return elem;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
} );
}
/*
* Helper functions for managing events -- not part of the public interface.
* Props to Dean Edwards' addEvent library for many of the ideas.
*/
jQuery.event = {
add: function( elem, types, handler, data, selector ) {
var handleObjIn, eventHandle, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData = dataPriv.get( elem );
// Only attach events to objects that accept data
if ( !acceptData( elem ) ) {
return;
}
// Caller can pass in an object of custom data in lieu of the handler
if ( handler.handler ) {
handleObjIn = handler;
handler = handleObjIn.handler;
selector = handleObjIn.selector;
}
// Ensure that invalid selectors throw exceptions at attach time
// Evaluate against documentElement in case elem is a non-element node (e.g., document)
if ( selector ) {
jQuery.find.matchesSelector( documentElement, selector );
}
// Make sure that the handler has a unique ID, used to find/remove it later
if ( !handler.guid ) {
handler.guid = jQuery.guid++;
}
// Init the element's event structure and main handler, if this is the first
if ( !( events = elemData.events ) ) {
events = elemData.events = Object.create( null );
}
if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
};
}
// Handle multiple events separated by a space
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// There *must* be a type, no attaching namespace-only handlers
if ( !type ) {
continue;
}
// If event changes its type, use the special event handlers for the changed type
special = jQuery.event.special[ type ] || {};
// If selector defined, determine special event api type, otherwise given type
type = ( selector ? special.delegateType : special.bindType ) || type;
// Update special based on newly reset type
special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers
handleObj = jQuery.extend( {
type: type,
origType: origType,
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join( "." )
}, handleObjIn );
// Init the event handler queue if we're the first
if ( !( handlers = events[ type ] ) ) {
handlers = events[ type ] = [];
handlers.delegateCount = 0;
// Only use addEventListener if the special events handler returns false
if ( !special.setup ||
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle );
}
}
}
if ( special.add ) {
special.add.call( elem, handleObj );
if ( !handleObj.handler.guid ) {
handleObj.handler.guid = handler.guid;
}
}
// Add to the element's handler list, delegates in front
if ( selector ) {
handlers.splice( handlers.delegateCount++, 0, handleObj );
} else {
handlers.push( handleObj );
}
}
},
// Detach an event or set of events from an element
remove: function( elem, types, handler, selector, mappedTypes ) {
var j, origCount, tmp,
events, t, handleObj,
special, handlers, type, namespaces, origType,
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
if ( !elemData || !( events = elemData.events ) ) {
return;
}
// Once for each type.namespace in types; type may be omitted
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element
if ( !type ) {
for ( type in events ) {
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
}
continue;
}
special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || [];
tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
// Remove matching events
origCount = j = handlers.length;
while ( j-- ) {
handleObj = handlers[ j ];
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
handlers.splice( j, 1 );
if ( handleObj.selector ) {
handlers.delegateCount--;
}
if ( special.remove ) {
special.remove.call( elem, handleObj );
}
}
}
// Remove generic event handler if we removed something and no more handlers exist
// (avoids potential for endless recursion during removal of special event handlers)
if ( origCount && !handlers.length ) {
if ( !special.teardown ||
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
jQuery.removeEvent( elem, type, elemData.handle );
}
delete events[ type ];
}
}
// Remove data and the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) {
dataPriv.remove( elem, "handle events" );
}
},
dispatch: function( nativeEvent ) {
var i, j, ret, matched, handleObj, handlerQueue,
args = new Array( arguments.length ),
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( nativeEvent ),
handlers = (
dataPriv.get( this, "events" ) || Object.create( null )
)[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[ 0 ] = event;
for ( i = 1; i < arguments.length; i++ ) {
args[ i ] = arguments[ i ];
}
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
return;
}
// Determine handlers
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
// If the event is namespaced, then each handler is only invoked if it is
// specially universal or its namespaces are a superset of the event's.
if ( !event.rnamespace || handleObj.namespace === false ||
event.rnamespace.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) {
if ( ( event.result = ret ) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
}
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
},
handlers: function( event, handlers ) {
var i, handleObj, sel, matchedHandlers, matchedSelectors,
handlerQueue = [],
delegateCount = handlers.delegateCount,
cur = event.target;
// Find delegate handlers
if ( delegateCount &&
// Support: Firefox <=42 - 66+
// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
// Support: IE 11+
// ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
!( event.type === "click" && event.button >= 1 ) ) {
for ( ; cur !== this; cur = cur.parentNode || this ) {
// Don't check non-elements (trac-13208)
// Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
matchedHandlers = [];
matchedSelectors = {};
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
// Don't conflict with Object.prototype properties (trac-13203)
sel = handleObj.selector + " ";
if ( matchedSelectors[ sel ] === undefined ) {
matchedSelectors[ sel ] = handleObj.needsContext ?
jQuery( sel, this ).index( cur ) > -1 :
jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( matchedSelectors[ sel ] ) {
matchedHandlers.push( handleObj );
}
}
if ( matchedHandlers.length ) {
handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
}
}
}
}
// Add the remaining (directly-bound) handlers
cur = this;
if ( delegateCount < handlers.length ) {
handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
}
return handlerQueue;
},
addProp: function( name, hook ) {
Object.defineProperty( jQuery.Event.prototype, name, {
enumerable: true,
configurable: true,
get: typeof hook === "function" ?
function() {
if ( this.originalEvent ) {
return hook( this.originalEvent );
}
} :
function() {
if ( this.originalEvent ) {
return this.originalEvent[ name ];
}
},
set: function( value ) {
Object.defineProperty( this, name, {
enumerable: true,
configurable: true,
writable: true,
value: value
} );
}
} );
},
fix: function( originalEvent ) {
return originalEvent[ jQuery.expando ] ?
originalEvent :
new jQuery.Event( originalEvent );
},
special: jQuery.extend( Object.create( null ), {
load: {
// Prevent triggered image.load events from bubbling to window.load
noBubble: true
},
click: {
// Utilize native event to ensure correct state for checkable inputs
setup: function( data ) {
// For mutual compressibility with _default, replace `this` access with a local var.
// `|| data` is dead code meant only to preserve the variable through minification.
var el = this || data;
// Claim the first handler
if ( rcheckableType.test( el.type ) &&
el.click && nodeName( el, "input" ) ) {
// dataPriv.set( el, "click", ... )
leverageNative( el, "click", true );
}
// Return false to allow normal processing in the caller
return false;
},
trigger: function( data ) {
// For mutual compressibility with _default, replace `this` access with a local var.
// `|| data` is dead code meant only to preserve the variable through minification.
var el = this || data;
// Force setup before triggering a click
if ( rcheckableType.test( el.type ) &&
el.click && nodeName( el, "input" ) ) {
leverageNative( el, "click" );
}
// Return non-false to allow normal event-path propagation
return true;
},
// For cross-browser consistency, suppress native .click() on links
// Also prevent it if we're currently inside a leveraged native-event stack
_default: function( event ) {
var target = event.target;
return rcheckableType.test( target.type ) &&
target.click && nodeName( target, "input" ) &&
dataPriv.get( target, "click" ) ||
nodeName( target, "a" );
}
},
beforeunload: {
postDispatch: function( event ) {
if ( event.result !== undefined ) {
// Setting `event.originalEvent.returnValue` in modern
// browsers does the same as just calling `preventDefault()`,
// the browsers ignore the value anyway.
// Incidentally, IE 11 is the only browser from our supported
// ones which respects the value returned from a `beforeunload`
// handler attached by `addEventListener`; other browsers do
// so only for inline handlers, so not setting the value
// directly shouldn't reduce any functionality.
event.preventDefault();
}
}
}
} )
};
// Ensure the presence of an event listener that handles manually-triggered
// synthetic events by interrupting progress until reinvoked in response to
// *native* events that it fires directly, ensuring that state changes have
// already occurred before other listeners are invoked.
function leverageNative( el, type, isSetup ) {
// Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add
if ( !isSetup ) {
if ( dataPriv.get( el, type ) === undefined ) {
jQuery.event.add( el, type, returnTrue );
}
return;
}
// Register the controller as a special universal handler for all event namespaces
dataPriv.set( el, type, false );
jQuery.event.add( el, type, {
namespace: false,
handler: function( event ) {
var result,
saved = dataPriv.get( this, type );
// This controller function is invoked under multiple circumstances,
// differentiated by the stored value in `saved`:
// 1. For an outer synthetic `.trigger()`ed event (detected by
// `event.isTrigger & 1` and non-array `saved`), it records arguments
// as an array and fires an [inner] native event to prompt state
// changes that should be observed by registered listeners (such as
// checkbox toggling and focus updating), then clears the stored value.
// 2. For an [inner] native event (detected by `saved` being
// an array), it triggers an inner synthetic event, records the
// result, and preempts propagation to further jQuery listeners.
// 3. For an inner synthetic event (detected by `event.isTrigger & 1` and
// array `saved`), it prevents double-propagation of surrogate events
// but otherwise allows everything to proceed (particularly including
// further listeners).
// Possible `saved` data shapes: `[...], `{ value }`, `false`.
if ( ( event.isTrigger & 1 ) && this[ type ] ) {
// Interrupt processing of the outer synthetic .trigger()ed event
if ( !saved.length ) {
// Store arguments for use when handling the inner native event
// There will always be at least one argument (an event object),
// so this array will not be confused with a leftover capture object.
saved = slice.call( arguments );
dataPriv.set( this, type, saved );
// Trigger the native event and capture its result
this[ type ]();
result = dataPriv.get( this, type );
dataPriv.set( this, type, false );
if ( saved !== result ) {
// Cancel the outer synthetic event
event.stopImmediatePropagation();
event.preventDefault();
// Support: Chrome 86+
// In Chrome, if an element having a focusout handler is
// blurred by clicking outside of it, it invokes the handler
// synchronously. If that handler calls `.remove()` on
// the element, the data is cleared, leaving `result`
// undefined. We need to guard against this.
return result && result.value;
}
// If this is an inner synthetic event for an event with a bubbling
// surrogate (focus or blur), assume that the surrogate already
// propagated from triggering the native event and prevent that
// from happening again here.
} else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
event.stopPropagation();
}
// If this is a native event triggered above, everything is now in order.
// Fire an inner synthetic event with the original arguments.
} else if ( saved.length ) {
// ...and capture the result
dataPriv.set( this, type, {
value: jQuery.event.trigger(
saved[ 0 ],
saved.slice( 1 ),
this
)
} );
// Abort handling of the native event by all jQuery handlers while allowing
// native handlers on the same element to run. On target, this is achieved
// by stopping immediate propagation just on the jQuery event. However,
// the native event is re-wrapped by a jQuery one on each level of the
// propagation so the only way to stop it for jQuery is to stop it for
// everyone via native `stopPropagation()`. This is not a problem for
// focus/blur which don't bubble, but it does also stop click on checkboxes
// and radios. We accept this limitation.
event.stopPropagation();
event.isImmediatePropagationStopped = returnTrue;
}
}
} );
}
jQuery.removeEvent = function( elem, type, handle ) {
// This "if" is needed for plain objects
if ( elem.removeEventListener ) {
elem.removeEventListener( type, handle );
}
};
jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword
if ( !( this instanceof jQuery.Event ) ) {
return new jQuery.Event( src, props );
}
// Event object
if ( src && src.type ) {
this.originalEvent = src;
this.type = src.type;
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented ?
returnTrue :
returnFalse;
// Create target properties
this.target = src.target;
this.currentTarget = src.currentTarget;
this.relatedTarget = src.relatedTarget;
// Event type
} else {
this.type = src;
}
// Put explicitly provided properties onto the event object
if ( props ) {
jQuery.extend( this, props );
}
// Create a timestamp if incoming event doesn't have one
this.timeStamp = src && src.timeStamp || Date.now();
// Mark it as fixed
this[ jQuery.expando ] = true;
};
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = {
constructor: jQuery.Event,
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
isSimulated: false,
preventDefault: function() {
var e = this.originalEvent;
this.isDefaultPrevented = returnTrue;
if ( e && !this.isSimulated ) {
e.preventDefault();
}
},
stopPropagation: function() {
var e = this.originalEvent;
this.isPropagationStopped = returnTrue;
if ( e && !this.isSimulated ) {
e.stopPropagation();
}
},
stopImmediatePropagation: function() {
var e = this.originalEvent;
this.isImmediatePropagationStopped = returnTrue;
if ( e && !this.isSimulated ) {
e.stopImmediatePropagation();
}
this.stopPropagation();
}
};
// Includes all common event props including KeyEvent and MouseEvent specific props
jQuery.each( {
altKey: true,
bubbles: true,
cancelable: true,
changedTouches: true,
ctrlKey: true,
detail: true,
eventPhase: true,
metaKey: true,
pageX: true,
pageY: true,
shiftKey: true,
view: true,
"char": true,
code: true,
charCode: true,
key: true,
keyCode: true,
button: true,
buttons: true,
clientX: true,
clientY: true,
offsetX: true,
offsetY: true,
pointerId: true,
pointerType: true,
screenX: true,
screenY: true,
targetTouches: true,
toElement: true,
touches: true,
which: true
}, jQuery.event.addProp );
jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
// Support: IE 11+
// Attach a single focusin/focusout handler on the document while someone wants focus/blur.
// This is because the former are synchronous in IE while the latter are async. In other
// browsers, all those handlers are invoked synchronously.
function focusMappedHandler( nativeEvent ) {
// `eventHandle` would already wrap the event, but we need to change the `type` here.
var event = jQuery.event.fix( nativeEvent );
event.type = nativeEvent.type === "focusin" ? "focus" : "blur";
event.isSimulated = true;
// focus/blur don't bubble while focusin/focusout do; simulate the former by only
// invoking the handler at the lower level.
if ( event.target === event.currentTarget ) {
// The setup part calls `leverageNative`, which, in turn, calls
// `jQuery.event.add`, so event handle will already have been set
// by this point.
dataPriv.get( this, "handle" )( event );
}
}
jQuery.event.special[ type ] = {
// Utilize native event if possible so blur/focus sequence is correct
setup: function() {
// Claim the first handler
// dataPriv.set( this, "focus", ... )
// dataPriv.set( this, "blur", ... )
leverageNative( this, type, true );
if ( isIE ) {
this.addEventListener( delegateType, focusMappedHandler );
} else {
// Return false to allow normal processing in the caller
return false;
}
},
trigger: function() {
// Force setup before trigger
leverageNative( this, type );
// Return non-false to allow normal event-path propagation
return true;
},
teardown: function() {
if ( isIE ) {
this.removeEventListener( delegateType, focusMappedHandler );
} else {
// Return false to indicate standard teardown should be applied
return false;
}
},
// Suppress native focus or blur if we're currently inside
// a leveraged native-event stack
_default: function( event ) {
return dataPriv.get( event.target, type );
},
delegateType: delegateType
};
} );
// Create mouseenter/leave events using mouseover/out and event-time checks
// so that event delegation works in jQuery.
// Do the same for pointerenter/pointerleave and pointerover/pointerout
jQuery.each( {
mouseenter: "mouseover",
mouseleave: "mouseout",
pointerenter: "pointerover",
pointerleave: "pointerout"
}, function( orig, fix ) {
jQuery.event.special[ orig ] = {
delegateType: fix,
bindType: fix,
handle: function( event ) {
var ret,
target = this,
related = event.relatedTarget,
handleObj = event.handleObj;
// For mouseenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments );
event.type = fix;
}
return ret;
}
};
} );
jQuery.fn.extend( {
on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn );
},
one: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn, 1 );
},
off: function( types, selector, fn ) {
var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event
handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
handleObj.namespace ?
handleObj.origType + "." + handleObj.namespace :
handleObj.origType,
handleObj.selector,
handleObj.handler
);
return this;
}
if ( typeof types === "object" ) {
// ( types-object [, selector] )
for ( type in types ) {
this.off( type, selector, types[ type ] );
}
return this;
}
if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] )
fn = selector;
selector = undefined;
}
if ( fn === false ) {
fn = returnFalse;
}
return this.each( function() {
jQuery.event.remove( this, types, fn, selector );
} );
}
} );
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/queue.js | src/queue.js | import { jQuery } from "./core.js";
import { dataPriv } from "./data/var/dataPriv.js";
import "./deferred.js";
import "./callbacks.js";
jQuery.extend( {
queue: function( elem, type, data ) {
var queue;
if ( elem ) {
type = ( type || "fx" ) + "queue";
queue = dataPriv.get( elem, type );
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !queue || Array.isArray( data ) ) {
queue = dataPriv.set( elem, type, jQuery.makeArray( data ) );
} else {
queue.push( data );
}
}
return queue || [];
}
},
dequeue: function( elem, type ) {
type = type || "fx";
var queue = jQuery.queue( elem, type ),
startLength = queue.length,
fn = queue.shift(),
hooks = jQuery._queueHooks( elem, type ),
next = function() {
jQuery.dequeue( elem, type );
};
// If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) {
fn = queue.shift();
startLength--;
}
if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if ( type === "fx" ) {
queue.unshift( "inprogress" );
}
// Clear up the last queue stop function
delete hooks.stop;
fn.call( elem, next, hooks );
}
if ( !startLength && hooks ) {
hooks.empty.fire();
}
},
// Not public - generate a queueHooks object, or return the current one
_queueHooks: function( elem, type ) {
var key = type + "queueHooks";
return dataPriv.get( elem, key ) || dataPriv.set( elem, key, {
empty: jQuery.Callbacks( "once memory" ).add( function() {
dataPriv.remove( elem, [ type + "queue", key ] );
} )
} );
}
} );
jQuery.fn.extend( {
queue: function( type, data ) {
var setter = 2;
if ( typeof type !== "string" ) {
data = type;
type = "fx";
setter--;
}
if ( arguments.length < setter ) {
return jQuery.queue( this[ 0 ], type );
}
return data === undefined ?
this :
this.each( function() {
var queue = jQuery.queue( this, type, data );
// Ensure a hooks for this queue
jQuery._queueHooks( this, type );
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
jQuery.dequeue( this, type );
}
} );
},
dequeue: function( type ) {
return this.each( function() {
jQuery.dequeue( this, type );
} );
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, obj ) {
var tmp,
count = 1,
defer = jQuery.Deferred(),
elements = this,
i = this.length,
resolve = function() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
}
};
if ( typeof type !== "string" ) {
obj = type;
type = undefined;
}
type = type || "fx";
while ( i-- ) {
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
if ( tmp && tmp.empty ) {
count++;
tmp.empty.add( resolve );
}
}
resolve();
return defer.promise( obj );
}
} );
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/traversing.js | src/traversing.js | import { jQuery } from "./core.js";
import { getProto } from "./var/getProto.js";
import { indexOf } from "./var/indexOf.js";
import { dir } from "./traversing/var/dir.js";
import { siblings } from "./traversing/var/siblings.js";
import { rneedsContext } from "./traversing/var/rneedsContext.js";
import { nodeName } from "./core/nodeName.js";
import "./core/init.js";
import "./traversing/findFilter.js";
import "./selector.js";
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+
// <object> elements with no `data` attribute has an object
// `contentDocument` with a `null` prototype.
getProto( elem.contentDocument ) ) {
return elem.contentDocument;
}
// Support: IE 9 - 11+
// Treat the template element as a regular one in browsers that
// don't support it.
if ( nodeName( elem, "template" ) ) {
elem = elem.content || elem;
}
return jQuery.merge( [], elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
var matched = jQuery.map( this, fn, until );
if ( name.slice( -5 ) !== "Until" ) {
selector = until;
}
if ( selector && typeof selector === "string" ) {
matched = jQuery.filter( selector, matched );
}
if ( this.length > 1 ) {
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
jQuery.uniqueSort( matched );
}
// Reverse order for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) {
matched.reverse();
}
}
return this.pushStack( matched );
};
} );
export { jQuery, jQuery as $ };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/script.js | src/ajax/script.js | import { jQuery } from "../core.js";
import { document } from "../var/document.js";
import "../ajax.js";
function canUseScriptTag( s ) {
// A script tag can only be used for async, cross domain or forced-by-attrs requests.
// Requests with headers cannot use a script tag. However, when both `scriptAttrs` &
// `headers` options are specified, both are impossible to satisfy together; we
// prefer `scriptAttrs` then.
// Sync requests remain handled differently to preserve strict script ordering.
return s.scriptAttrs || (
!s.headers &&
(
s.crossDomain ||
// When dealing with JSONP (`s.dataTypes` include "json" then)
// don't use a script tag so that error responses still may have
// `responseJSON` set. Continue using a script tag for JSONP requests that:
// * are cross-domain as AJAX requests won't work without a CORS setup
// * have `scriptAttrs` set as that's a script-only functionality
// Note that this means JSONP requests violate strict CSP script-src settings.
// A proper solution is to migrate from using JSONP to a CORS setup.
( s.async && jQuery.inArray( "json", s.dataTypes ) < 0 )
)
);
}
// Install script dataType. Don't specify `contents.script` so that an explicit
// `dataType: "script"` is required (see gh-2432, gh-4822)
jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text );
return text;
}
}
} );
// Handle cache's special case and crossDomain
jQuery.ajaxPrefilter( "script", function( s ) {
if ( s.cache === undefined ) {
s.cache = false;
}
// These types of requests are handled via a script tag
// so force their methods to GET.
if ( canUseScriptTag( s ) ) {
s.type = "GET";
}
} );
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function( s ) {
if ( canUseScriptTag( s ) ) {
var script, callback;
return {
send: function( _, complete ) {
script = jQuery( "<script>" )
.attr( s.scriptAttrs || {} )
.prop( { charset: s.scriptCharset, src: s.url } )
.on( "load error", callback = function( evt ) {
script.remove();
callback = null;
if ( evt ) {
complete( evt.type === "error" ? 404 : 200, evt.type );
}
} );
// Use native DOM manipulation to avoid our domManip AJAX trickery
document.head.appendChild( script[ 0 ] );
},
abort: function() {
if ( callback ) {
callback();
}
}
};
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/binary.js | src/ajax/binary.js | import { jQuery } from "../core.js";
import "../ajax.js";
jQuery.ajaxPrefilter( function( s, origOptions ) {
// Binary data needs to be passed to XHR as-is without stringification.
if ( typeof s.data !== "string" && !jQuery.isPlainObject( s.data ) &&
!Array.isArray( s.data ) &&
// Don't disable data processing if explicitly set by the user.
!( "processData" in origOptions ) ) {
s.processData = false;
}
// `Content-Type` for requests with `FormData` bodies needs to be set
// by the browser as it needs to append the `boundary` it generated.
if ( s.data instanceof window.FormData ) {
s.contentType = false;
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/jsonp.js | src/ajax/jsonp.js | import { jQuery } from "../core.js";
import { nonce } from "./var/nonce.js";
import { rquery } from "./var/rquery.js";
import "../ajax.js";
var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
this[ callback ] = true;
return callback;
}
} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "jsonp", function( s, originalSettings, jqXHR ) {
var callbackName, overwritten, responseContainer,
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
"url" :
typeof s.data === "string" &&
( s.contentType || "" )
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
);
// Get callback name, remembering preexisting value associated with it
callbackName = s.jsonpCallback = typeof s.jsonpCallback === "function" ?
s.jsonpCallback() :
s.jsonpCallback;
// Insert callback into url or form data
if ( jsonProp ) {
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
} else if ( s.jsonp !== false ) {
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
}
// Use data converter to retrieve json after script execution
s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
return responseContainer[ 0 ];
};
// Force json dataType
s.dataTypes[ 0 ] = "json";
// Install callback
overwritten = window[ callbackName ];
window[ callbackName ] = function() {
responseContainer = arguments;
};
// Clean-up function (fires after converters)
jqXHR.always( function() {
// If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
// Otherwise restore preexisting value
} else {
window[ callbackName ] = overwritten;
}
// Save back as free
if ( s[ callbackName ] ) {
// Make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
// Save the callback name for future use
oldCallbacks.push( callbackName );
}
// Call if it was a function and we have a response
if ( responseContainer && typeof overwritten === "function" ) {
overwritten( responseContainer[ 0 ] );
}
responseContainer = overwritten = undefined;
} );
// Delegate to script
return "script";
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/xhr.js | src/ajax/xhr.js | import { jQuery } from "../core.js";
import "../ajax.js";
jQuery.ajaxSettings.xhr = function() {
return new window.XMLHttpRequest();
};
var xhrSuccessStatus = {
// File protocol always yields status code 0, assume 200
0: 200
};
jQuery.ajaxTransport( function( options ) {
var callback;
return {
send: function( headers, complete ) {
var i,
xhr = options.xhr();
xhr.open(
options.type,
options.url,
options.async,
options.username,
options.password
);
// Apply custom fields if provided
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
}
}
// Override mime type if needed
if ( options.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( options.mimeType );
}
// X-Requested-With header
// For cross-domain requests, seeing as conditions for a preflight are
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Set headers
for ( i in headers ) {
xhr.setRequestHeader( i, headers[ i ] );
}
// Callback
callback = function( type ) {
return function() {
if ( callback ) {
callback = xhr.onload = xhr.onerror = xhr.onabort = xhr.ontimeout = null;
if ( type === "abort" ) {
xhr.abort();
} else if ( type === "error" ) {
complete(
// File: protocol always yields status 0; see trac-8605, trac-14207
xhr.status,
xhr.statusText
);
} else {
complete(
xhrSuccessStatus[ xhr.status ] || xhr.status,
xhr.statusText,
// For XHR2 non-text, let the caller handle it (gh-2498)
( xhr.responseType || "text" ) === "text" ?
{ text: xhr.responseText } :
{ binary: xhr.response },
xhr.getAllResponseHeaders()
);
}
}
};
};
// Listen to events
xhr.onload = callback();
xhr.onabort = xhr.onerror = xhr.ontimeout = callback( "error" );
// Create the abort callback
callback = callback( "abort" );
try {
// Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null );
} catch ( e ) {
// trac-14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) {
throw e;
}
}
},
abort: function() {
if ( callback ) {
callback();
}
}
};
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/load.js | src/ajax/load.js | import { jQuery } from "../core.js";
import { stripAndCollapse } from "../core/stripAndCollapse.js";
import "../core/parseHTML.js";
import "../ajax.js";
import "../traversing.js";
import "../manipulation.js";
import "../selector.js";
/**
* Load a url into a page
*/
jQuery.fn.load = function( url, params, callback ) {
var selector, type, response,
self = this,
off = url.indexOf( " " );
if ( off > -1 ) {
selector = stripAndCollapse( url.slice( off ) );
url = url.slice( 0, off );
}
// If it's a function
if ( typeof params === "function" ) {
// We assume that it's the callback
callback = params;
params = undefined;
// Otherwise, build a param string
} else if ( params && typeof params === "object" ) {
type = "POST";
}
// If we have elements to modify, make the request
if ( self.length > 0 ) {
jQuery.ajax( {
url: url,
// If "type" variable is undefined, then "GET" method will be used.
// Make value of this field explicit since
// user can override it through ajaxSetup method
type: type || "GET",
dataType: "html",
data: params
} ).done( function( responseText ) {
// Save response for use in complete callback
response = arguments;
self.html( selector ?
// If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result
responseText );
// If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error"
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
} );
} );
}
return this;
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/var/location.js | src/ajax/var/location.js | export var location = window.location;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/var/nonce.js | src/ajax/var/nonce.js | export var nonce = { guid: Date.now() };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/ajax/var/rquery.js | src/ajax/var/rquery.js | export var rquery = /\?/;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/exports/global.js | src/exports/global.js | import { jQuery } from "../core.js";
var
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$;
jQuery.noConflict = function( deep ) {
if ( window.$ === jQuery ) {
window.$ = _$;
}
if ( deep && window.jQuery === jQuery ) {
window.jQuery = _jQuery;
}
return jQuery;
};
// Expose jQuery and $ identifiers, even in AMD
// (trac-7102#comment:10, gh-557)
// and CommonJS for browser emulators (trac-13566)
if ( typeof noGlobal === "undefined" ) {
window.jQuery = window.$ = jQuery;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/exports/amd.js | src/exports/amd.js | import { jQuery } from "../core.js";
// Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust
// way to register. Lowercase jquery is used because AMD module names are
// derived from file names, and jQuery is normally delivered in a lowercase
// file name. Do this after creating the global so that if an AMD module wants
// to call noConflict to hide this version of jQuery, it will work.
// Note that for maximum portability, libraries that are not jQuery should
// declare themselves as anonymous modules, and avoid setting a global if an
// AMD loader is present. jQuery is a special case. For more information, see
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() {
return jQuery;
} );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/deferred/exceptionHook.js | src/deferred/exceptionHook.js | import { jQuery } from "../core.js";
import "../deferred.js";
// These usually indicate a programmer mistake during development,
// warn about them ASAP rather than swallowing them by default.
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error
// captured before the async barrier to get the original error cause
// which may otherwise be hidden.
jQuery.Deferred.exceptionHook = function( error, asyncError ) {
if ( error && rerrorNames.test( error.name ) ) {
window.console.warn(
"jQuery.Deferred exception",
error,
asyncError
);
}
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/finalPropName.js | src/css/finalPropName.js | import { document } from "../var/document.js";
var cssPrefixes = [ "Webkit", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style;
// Return a vendor-prefixed property or undefined
function vendorPropName( name ) {
// Check for vendor prefixed names
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in emptyStyle ) {
return name;
}
}
}
// Return a potentially-mapped vendor prefixed property
export function finalPropName( name ) {
if ( name in emptyStyle ) {
return name;
}
return vendorPropName( name ) || name;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/showHide.js | src/css/showHide.js | import { jQuery } from "../core.js";
import { dataPriv } from "../data/var/dataPriv.js";
import { isHiddenWithinTree } from "../css/var/isHiddenWithinTree.js";
var defaultDisplayMap = {};
function getDefaultDisplay( elem ) {
var temp,
doc = elem.ownerDocument,
nodeName = elem.nodeName,
display = defaultDisplayMap[ nodeName ];
if ( display ) {
return display;
}
temp = doc.body.appendChild( doc.createElement( nodeName ) );
display = jQuery.css( temp, "display" );
temp.parentNode.removeChild( temp );
if ( display === "none" ) {
display = "block";
}
defaultDisplayMap[ nodeName ] = display;
return display;
}
export function showHide( elements, show ) {
var display, elem,
values = [],
index = 0,
length = elements.length;
// Determine new display value for elements that need to change
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
display = elem.style.display;
if ( show ) {
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
// check is required in this first loop unless we have a nonempty display value (either
// inline or about-to-be-restored)
if ( display === "none" ) {
values[ index ] = dataPriv.get( elem, "display" ) || null;
if ( !values[ index ] ) {
elem.style.display = "";
}
}
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
values[ index ] = getDefaultDisplay( elem );
}
} else {
if ( display !== "none" ) {
values[ index ] = "none";
// Remember what we're overwriting
dataPriv.set( elem, "display", display );
}
}
}
// Set the display of the elements in a second loop to avoid constant reflow
for ( index = 0; index < length; index++ ) {
if ( values[ index ] != null ) {
elements[ index ].style.display = values[ index ];
}
}
return elements;
}
jQuery.fn.extend( {
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
return this.each( function() {
if ( isHiddenWithinTree( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
} );
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/support.js | src/css/support.js | import { jQuery } from "../core.js";
import { document } from "../var/document.js";
import { documentElement } from "../var/documentElement.js";
import { support } from "../var/support.js";
import { isIE } from "../var/isIE.js";
var reliableTrDimensionsVal, reliableColDimensionsVal,
table = document.createElement( "table" );
// Executing table tests requires only one layout, so they're executed
// at the same time to save the second computation.
function computeTableStyleTests() {
if (
// This is a singleton, we need to execute it only once
!table ||
// Finish early in limited (non-browser) environments
!table.style
) {
return;
}
var trStyle,
col = document.createElement( "col" ),
tr = document.createElement( "tr" ),
td = document.createElement( "td" );
table.style.cssText = "position:absolute;left:-11111px;" +
"border-collapse:separate;border-spacing:0";
tr.style.cssText = "box-sizing:content-box;border:1px solid;height:1px";
td.style.cssText = "height:9px;width:9px;padding:0";
col.span = 2;
documentElement
.appendChild( table )
.appendChild( col )
.parentNode
.appendChild( tr )
.appendChild( td )
.parentNode
.appendChild( td.cloneNode( true ) );
// Don't run until window is visible
if ( table.offsetWidth === 0 ) {
documentElement.removeChild( table );
return;
}
trStyle = window.getComputedStyle( tr );
// Support: Firefox 135+
// Firefox always reports computed width as if `span` was 1.
// Support: Safari 18.3+
// In Safari, computed width for columns is always 0.
// In both these browsers, using `offsetWidth` solves the issue.
// Support: IE 11+
// In IE, `<col>` computed width is `"auto"` unless `width` is set
// explicitly via CSS so measurements there remain incorrect. Because of
// the lack of a proper workaround, we accept this limitation, treating
// IE as passing the test.
reliableColDimensionsVal = isIE || Math.round( parseFloat(
window.getComputedStyle( col ).width )
) === 18;
// Support: IE 10 - 11+
// IE misreports `getComputedStyle` of table rows with width/height
// set in CSS while `offset*` properties report correct values.
// Support: Firefox 70 - 135+
// Only Firefox includes border widths
// in computed dimensions for table rows. (gh-4529)
reliableTrDimensionsVal = Math.round( parseFloat( trStyle.height ) +
parseFloat( trStyle.borderTopWidth ) +
parseFloat( trStyle.borderBottomWidth ) ) === tr.offsetHeight;
documentElement.removeChild( table );
// Nullify the table so it wouldn't be stored in the memory;
// it will also be a sign that checks were already performed.
table = null;
}
jQuery.extend( support, {
reliableTrDimensions: function() {
computeTableStyleTests();
return reliableTrDimensionsVal;
},
reliableColDimensions: function() {
computeTableStyleTests();
return reliableColDimensionsVal;
}
} );
export { support };
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/curCSS.js | src/css/curCSS.js | import { jQuery } from "../core.js";
import { isAttached } from "../core/isAttached.js";
import { getStyles } from "./var/getStyles.js";
import { rcustomProp } from "./var/rcustomProp.js";
import { rtrimCSS } from "../var/rtrimCSS.js";
export function curCSS( elem, name, computed ) {
var ret,
isCustomProp = rcustomProp.test( name );
computed = computed || getStyles( elem );
// getPropertyValue is needed for `.css('--customProperty')` (gh-3144)
if ( computed ) {
// A fallback to direct property access is needed as `computed`, being
// the output of `getComputedStyle`, contains camelCased keys and
// `getPropertyValue` requires kebab-case ones.
//
// Support: IE <=9 - 11+
// IE only supports `"float"` in `getPropertyValue`; in computed styles
// it's only available as `"cssFloat"`. We no longer modify properties
// sent to `.css()` apart from camelCasing, so we need to check both.
// Normally, this would create difference in behavior: if
// `getPropertyValue` returns an empty string, the value returned
// by `.css()` would be `undefined`. This is usually the case for
// disconnected elements. However, in IE even disconnected elements
// with no styles return `"none"` for `getPropertyValue( "float" )`
ret = computed.getPropertyValue( name ) || computed[ name ];
if ( isCustomProp && ret ) {
// Support: Firefox 105 - 135+
// Spec requires trimming whitespace for custom properties (gh-4926).
// Firefox only trims leading whitespace.
//
// Fall back to `undefined` if empty string returned.
// This collapses a missing definition with property defined
// and set to an empty string but there's no standard API
// allowing us to differentiate them without a performance penalty
// and returning `undefined` aligns with older jQuery.
//
// rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
// as whitespace while CSS does not, but this is not a problem
// because CSS preprocessing replaces them with U+000A LINE FEED
// (which *is* CSS whitespace)
// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
ret = ret.replace( rtrimCSS, "$1" ) || undefined;
}
if ( ret === "" && !isAttached( elem ) ) {
ret = jQuery.style( elem, name );
}
}
return ret !== undefined ?
// Support: IE <=9 - 11+
// IE returns zIndex value as an integer.
ret + "" :
ret;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/hiddenVisibleSelectors.js | src/css/hiddenVisibleSelectors.js | import { jQuery } from "../core.js";
import "../selector.js";
jQuery.expr.pseudos.hidden = function( elem ) {
return !jQuery.expr.pseudos.visible( elem );
};
jQuery.expr.pseudos.visible = function( elem ) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/isAutoPx.js | src/css/isAutoPx.js | var ralphaStart = /^[a-z]/,
// The regex visualized:
//
// /----------\
// | | /-------\
// | / Top \ | | |
// /--- Border ---+-| Right |-+---+- Width -+---\
// | | Bottom | |
// | \ Left / |
// | |
// | /----------\ |
// | /-------------\ | | |- END
// | | | | / Top \ | |
// | | / Margin \ | | | Right | | |
// |---------+-| |-+---+-| Bottom |-+----|
// | \ Padding / \ Left / |
// BEGIN -| |
// | /---------\ |
// | | | |
// | | / Min \ | / Width \ |
// \--------------+-| |-+---| |---/
// \ Max / \ Height /
rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;
export function isAutoPx( prop ) {
// The first test is used to ensure that:
// 1. The prop starts with a lowercase letter (as we uppercase it for the second regex).
// 2. The prop is not empty.
return ralphaStart.test( prop ) &&
rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/adjustCSS.js | src/css/adjustCSS.js | import { jQuery } from "../core.js";
import { isAutoPx } from "./isAutoPx.js";
import { rcssNum } from "../var/rcssNum.js";
export function adjustCSS( elem, prop, valueParts, tween ) {
var adjusted, scale,
maxIterations = 20,
currentValue = tween ?
function() {
return tween.cur();
} :
function() {
return jQuery.css( elem, prop, "" );
},
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( isAutoPx( prop ) ? "px" : "" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = elem.nodeType &&
( !isAutoPx( prop ) || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Support: Firefox <=54 - 66+
// Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
initial = initial / 2;
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
// Iteratively approximate from a nonzero starting point
initialInUnit = +initial || 1;
while ( maxIterations-- ) {
// Evaluate and update our best guess (doubling guesses that zero out).
// Finish if the scale equals or crosses 1 (making the old*new product non-positive).
jQuery.style( elem, prop, initialInUnit + unit );
if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
maxIterations = 0;
}
initialInUnit = initialInUnit / scale;
}
initialInUnit = initialInUnit * 2;
jQuery.style( elem, prop, initialInUnit + unit );
// Make sure we update the tween properties later on
valueParts = valueParts || [];
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
+valueParts[ 2 ];
if ( tween ) {
tween.unit = unit;
tween.start = initialInUnit;
tween.end = adjusted;
}
}
return adjusted;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/cssCamelCase.js | src/css/cssCamelCase.js | import { camelCase } from "../core/camelCase.js";
// Matches dashed string for camelizing
var rmsPrefix = /^-ms-/;
// Convert dashed to camelCase, handle vendor prefixes.
// Used by the css & effects modules.
// Support: IE <=9 - 11+
// Microsoft forgot to hump their vendor prefix (trac-9572)
export function cssCamelCase( string ) {
return camelCase( string.replace( rmsPrefix, "ms-" ) );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/isHiddenWithinTree.js | src/css/var/isHiddenWithinTree.js | import { jQuery } from "../../core.js";
// isHiddenWithinTree reports if an element has a non-"none" display style (inline and/or
// through the CSS cascade), which is useful in deciding whether or not to make it visible.
// It differs from the :hidden selector (jQuery.expr.pseudos.hidden) in two important ways:
// * A hidden ancestor does not force an element to be classified as hidden.
// * Being disconnected from the document does not force an element to be classified as hidden.
// These differences improve the behavior of .toggle() et al. when applied to elements that are
// detached or contained within hidden ancestors (gh-2404, gh-2863).
export function isHiddenWithinTree( elem, el ) {
// isHiddenWithinTree might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
// Inline style trumps all
return elem.style.display === "none" ||
elem.style.display === "" &&
jQuery.css( elem, "display" ) === "none";
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/getStyles.js | src/css/var/getStyles.js | export function getStyles( elem ) {
// Support: IE <=11+ (trac-14150)
// In IE popup's `window` is the opener window which makes `window.getComputedStyle( elem )`
// break. Using `elem.ownerDocument.defaultView` avoids the issue.
var view = elem.ownerDocument.defaultView;
// `document.implementation.createHTMLDocument( "" )` has a `null` `defaultView`
// property; check `defaultView` truthiness to fallback to window in such a case.
if ( !view ) {
view = window;
}
return view.getComputedStyle( elem );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/cssExpand.js | src/css/var/cssExpand.js | export var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/rnumnonpx.js | src/css/var/rnumnonpx.js | import { pnum } from "../../var/pnum.js";
export var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/rcustomProp.js | src/css/var/rcustomProp.js | export var rcustomProp = /^--/;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/css/var/swap.js | src/css/var/swap.js | // A method for quickly swapping in/out CSS properties to get correct calculations.
export function swap( elem, options, callback ) {
var ret, name,
old = {};
// Remember the old values, and insert the new ones
for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
ret = callback.call( elem );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
return ret;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/rcssNum.js | src/var/rcssNum.js | import { pnum } from "../var/pnum.js";
export var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/toString.js | src/var/toString.js | import { class2type } from "./class2type.js";
export var toString = class2type.toString;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/push.js | src/var/push.js | import { arr } from "./arr.js";
export var push = arr.push;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/support.js | src/var/support.js | // All support tests are defined in their respective modules.
export var support = {};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/arr.js | src/var/arr.js | export var arr = [];
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/flat.js | src/var/flat.js | import { arr } from "./arr.js";
// Support: IE 11+
// IE doesn't have Array#flat; provide a fallback.
export var flat = arr.flat ? function( array ) {
return arr.flat.call( array );
} : function( array ) {
return arr.concat.apply( [], array );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/rtrimCSS.js | src/var/rtrimCSS.js | import { whitespace } from "./whitespace.js";
export var rtrimCSS = new RegExp(
"^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
"g"
);
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/rnothtmlwhite.js | src/var/rnothtmlwhite.js | // Only count HTML whitespace
// Other whitespace should count in values
// https://infra.spec.whatwg.org/#ascii-whitespace
export var rnothtmlwhite = /[^\x20\t\r\n\f]+/g;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/sort.js | src/var/sort.js | import { arr } from "./arr.js";
export var sort = arr.sort;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/ObjectFunctionString.js | src/var/ObjectFunctionString.js | import { fnToString } from "./fnToString.js";
export var ObjectFunctionString = fnToString.call( Object );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/document.js | src/var/document.js | export var document = window.document;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/whitespace.js | src/var/whitespace.js | // https://www.w3.org/TR/css3-selectors/#whitespace
export var whitespace = "[\\x20\\t\\r\\n\\f]";
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/indexOf.js | src/var/indexOf.js | import { arr } from "./arr.js";
export var indexOf = arr.indexOf;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/hasOwn.js | src/var/hasOwn.js | import { class2type } from "./class2type.js";
export var hasOwn = class2type.hasOwnProperty;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/pop.js | src/var/pop.js | import { arr } from "./arr.js";
export var pop = arr.pop;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/class2type.js | src/var/class2type.js | // [[Class]] -> type pairs
export var class2type = {};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/getProto.js | src/var/getProto.js | export var getProto = Object.getPrototypeOf;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/documentElement.js | src/var/documentElement.js | import { document } from "./document.js";
export var documentElement = document.documentElement;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/isWindow.js | src/var/isWindow.js | export function isWindow( obj ) {
return obj != null && obj === obj.window;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/isIE.js | src/var/isIE.js | import { document } from "./document.js";
export var isIE = document.documentMode;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/rcheckableType.js | src/var/rcheckableType.js | export var rcheckableType = /^(?:checkbox|radio)$/i;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/fnToString.js | src/var/fnToString.js | import { hasOwn } from "./hasOwn.js";
export var fnToString = hasOwn.toString;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/splice.js | src/var/splice.js | import { arr } from "./arr.js";
export var splice = arr.splice;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/pnum.js | src/var/pnum.js | export var pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/var/slice.js | src/var/slice.js | import { arr } from "./arr.js";
export var slice = arr.slice;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/deprecated/ajax-event-alias.js | src/deprecated/ajax-event-alias.js | import { jQuery } from "../core.js";
import "../ajax.js";
import "../event.js";
jQuery.each( [
"ajaxStart",
"ajaxStop",
"ajaxComplete",
"ajaxError",
"ajaxSuccess",
"ajaxSend"
], function( _i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/deprecated/event.js | src/deprecated/event.js | import { jQuery } from "../core.js";
import "../event.js";
import "../event/trigger.js";
jQuery.fn.extend( {
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
},
hover: function( fnOver, fnOut ) {
return this
.on( "mouseenter", fnOver )
.on( "mouseleave", fnOut || fnOver );
}
} );
jQuery.each(
( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( _i, name ) {
// Handle event binding
jQuery.fn[ name ] = function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
};
}
);
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/traversing/findFilter.js | src/traversing/findFilter.js | import { jQuery } from "../core.js";
import { indexOf } from "../var/indexOf.js";
import { rneedsContext } from "./var/rneedsContext.js";
import "../selector.js";
// 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;
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/traversing/var/dir.js | src/traversing/var/dir.js | import { jQuery } from "../../core.js";
export 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;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/traversing/var/siblings.js | src/traversing/var/siblings.js | export function siblings( n, elem ) {
var matched = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
matched.push( n );
}
}
return matched;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/traversing/var/rneedsContext.js | src/traversing/var/rneedsContext.js | import { jQuery } from "../../core.js";
import "../../selector.js";
export var rneedsContext = jQuery.expr.match.needsContext;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/buildFragment.js | src/manipulation/buildFragment.js | import { jQuery } from "../core.js";
import { toType } from "../core/toType.js";
import { isAttached } from "../core/isAttached.js";
import { arr } from "../var/arr.js";
import { rtagName } from "./var/rtagName.js";
import { rscriptType } from "./var/rscriptType.js";
import { wrapMap } from "./wrapMap.js";
import { getAll } from "./getAll.js";
import { setGlobalEval } from "./setGlobalEval.js";
import { isArrayLike } from "../core/isArrayLike.js";
var rhtml = /<|&#?\w+;/;
export function buildFragment( elems, context, scripts, selection, ignored ) {
var elem, tmp, tag, wrap, attached, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( toType( elem ) === "object" && ( elem.nodeType || isArrayLike( elem ) ) ) {
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || arr;
// Create wrappers & descend into them.
j = wrap.length;
while ( --j > -1 ) {
tmp = tmp.appendChild( context.createElement( wrap[ j ] ) );
}
tmp.innerHTML = jQuery.htmlPrefilter( elem );
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (trac-12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( ( elem = nodes[ i++ ] ) ) {
// Skip elements already in the context collection (trac-4087)
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
if ( ignored ) {
ignored.push( elem );
}
continue;
}
attached = isAttached( elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( attached ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( ( elem = tmp[ j++ ] ) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/domManip.js | src/manipulation/domManip.js | import { jQuery } from "../core.js";
import { flat } from "../var/flat.js";
import { rscriptType } from "./var/rscriptType.js";
import { getAll } from "./getAll.js";
import { buildFragment } from "./buildFragment.js";
import { dataPriv } from "../data/var/dataPriv.js";
import { DOMEval } from "../core/DOMEval.js";
// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
return elem;
}
function restoreScript( elem ) {
if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
elem.type = elem.type.slice( 5 );
} else {
elem.removeAttribute( "type" );
}
return elem;
}
export function domManip( collection, args, callback, ignored ) {
// Flatten any nested arrays
args = flat( args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[ 0 ],
valueIsFunction = typeof value === "function";
if ( valueIsFunction ) {
return collection.each( function( index ) {
var self = collection.eq( index );
args[ 0 ] = value.call( this, index, self.html() );
domManip( self, args, callback, ignored );
} );
}
if ( l ) {
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
// Require either new content or an interest in ignored elements to invoke the callback
if ( first || ignored ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item
// instead of the first because it can end up
// being emptied incorrectly in certain situations (trac-8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Re-enable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!dataPriv.get( node, "globalEval" ) &&
jQuery.contains( doc, node ) ) {
if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl && !node.noModule ) {
jQuery._evalUrl( node.src, {
nonce: node.nonce,
crossOrigin: node.crossOrigin
}, doc );
}
} else {
DOMEval( node.textContent, node, doc );
}
}
}
}
}
}
return collection;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/_evalUrl.js | src/manipulation/_evalUrl.js | import { jQuery } from "../ajax.js";
jQuery._evalUrl = function( url, options, doc ) {
return jQuery.ajax( {
url: url,
// Make this explicit, since user can override this through ajaxSetup (trac-11264)
type: "GET",
dataType: "script",
cache: true,
async: false,
global: false,
scriptAttrs: options.crossOrigin ? { "crossOrigin": options.crossOrigin } : undefined,
// Only evaluate the response if it is successful (gh-4126)
// dataFilter is not invoked for failure responses, so using it instead
// of the default converter is kludgy but it works.
converters: {
"text script": function() {}
},
dataFilter: function( response ) {
jQuery.globalEval( response, options, doc );
}
} );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/getAll.js | src/manipulation/getAll.js | import { jQuery } from "../core.js";
import { nodeName } from "../core/nodeName.js";
import { arr } from "../var/arr.js";
export function getAll( context, tag ) {
// Support: IE <=9 - 11+
// Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
var ret;
if ( typeof context.getElementsByTagName !== "undefined" ) {
// Use slice to snapshot the live collection from gEBTN
ret = arr.slice.call( context.getElementsByTagName( tag || "*" ) );
} else if ( typeof context.querySelectorAll !== "undefined" ) {
ret = context.querySelectorAll( tag || "*" );
} else {
ret = [];
}
if ( tag === undefined || tag && nodeName( context, tag ) ) {
return jQuery.merge( [ context ], ret );
}
return ret;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/setGlobalEval.js | src/manipulation/setGlobalEval.js | import { dataPriv } from "../data/var/dataPriv.js";
// Mark scripts as having already been evaluated
export function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
dataPriv.set(
elems[ i ],
"globalEval",
!refElements || dataPriv.get( refElements[ i ], "globalEval" )
);
}
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/wrapMap.js | src/manipulation/wrapMap.js | export var wrapMap = {
// Table parts need to be wrapped with `<table>` or they're
// stripped to their contents when put in a div.
// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do, so we cannot shorten
// this by omitting <tbody> or other required elements.
thead: [ "table" ],
col: [ "colgroup", "table" ],
tr: [ "tbody", "table" ],
td: [ "tr", "tbody", "table" ]
};
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/var/rscriptType.js | src/manipulation/var/rscriptType.js | export var rscriptType = /^$|^module$|\/(?:java|ecma)script/i;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/manipulation/var/rtagName.js | src/manipulation/var/rtagName.js | // rtagName captures the name from the first start tag in a string of HTML
// https://html.spec.whatwg.org/multipage/syntax.html#tag-open-state
// https://html.spec.whatwg.org/multipage/syntax.html#tag-name-state
export var rtagName = /<([a-z][^\/\0>\x20\t\r\n\f]*)/i;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/tokenize.js | src/selector/tokenize.js | import { jQuery } from "../core.js";
import { rcomma } from "./var/rcomma.js";
import { rleadingCombinator } from "./var/rleadingCombinator.js";
import { rtrimCSS } from "../var/rtrimCSS.js";
import { createCache } from "./createCache.js";
import { selectorError } from "./selectorError.js";
import { filterMatchExpr } from "./filterMatchExpr.js";
var tokenCache = createCache();
export 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 = jQuery.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 = rleadingCombinator.exec( soFar ) ) ) {
matched = match.shift();
tokens.push( {
value: matched,
// Cast descendant combinators to space
type: match[ 0 ].replace( rtrimCSS, " " )
} );
soFar = soFar.slice( matched.length );
}
// Filters
for ( type in filterMatchExpr ) {
if ( ( match = jQuery.expr.match[ 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 );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/createCache.js | src/selector/createCache.js | import { jQuery } from "../core.js";
/**
* 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
*/
export function createCache() {
var keys = [];
function cache( key, value ) {
// Use (key + " ") to avoid collision with native prototype properties
// (see https://github.com/jquery/sizzle/issues/157)
if ( keys.push( key + " " ) > jQuery.expr.cacheLength ) {
// Only keep the most recent entries
delete cache[ keys.shift() ];
}
return ( cache[ key + " " ] = value );
}
return cache;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/selectorError.js | src/selector/selectorError.js | import { jQuery } from "../core.js";
export function selectorError( msg ) {
jQuery.error( "Syntax error, unrecognized expression: " + msg );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/unescapeSelector.js | src/selector/unescapeSelector.js | // CSS escapes
// https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
import { whitespace } from "../var/whitespace.js";
var 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 );
};
export function unescapeSelector( sel ) {
return sel.replace( runescape, funescape );
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/filterMatchExpr.js | src/selector/filterMatchExpr.js | import { whitespace } from "../var/whitespace.js";
import { identifier } from "./var/identifier.js";
import { attributes } from "./var/attributes.js";
import { pseudos } from "./var/pseudos.js";
export var filterMatchExpr = {
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" )
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/escapeSelector.js | src/selector/escapeSelector.js | import { jQuery } from "../core.js";
// 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 );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/testContext.js | src/selector/testContext.js | /**
* 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
*/
export function testContext( context ) {
return context && typeof context.getElementsByTagName !== "undefined" && context;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/uniqueSort.js | src/selector/uniqueSort.js | import { jQuery } from "../core.js";
import { document } from "../var/document.js";
import { sort } from "../var/sort.js";
import { splice } from "../var/splice.js";
import { slice } from "../var/slice.js";
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+
// IE sometimes throws 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+
// IE sometimes throws 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+
// IE sometimes throws 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-- ) {
splice.call( results, duplicates[ j ], 1 );
}
}
return results;
};
jQuery.fn.uniqueSort = function() {
return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/toSelector.js | src/selector/toSelector.js | export function toSelector( tokens ) {
var i = 0,
len = tokens.length,
selector = "";
for ( ; i < len; i++ ) {
selector += tokens[ i ].value;
}
return selector;
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/rbuggyQSA.js | src/selector/rbuggyQSA.js | import { isIE } from "../var/isIE.js";
import { whitespace } from "../var/whitespace.js";
export var rbuggyQSA = isIE && new RegExp(
// Support: IE 9 - 11+
// IE's :disabled selector does not pick up the children of disabled fieldsets
":enabled|:disabled|" +
// Support: IE 11+
// IE 11 doesn't find elements on a `[name='']` query in some cases.
// Adding a temporary attribute to the document before the selection works
// around the issue.
"\\[" + whitespace + "*name" + whitespace + "*=" +
whitespace + "*(?:''|\"\")"
);
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/preFilter.js | src/selector/preFilter.js | import { rpseudo } from "./var/rpseudo.js";
import { filterMatchExpr } from "./filterMatchExpr.js";
import { unescapeSelector } from "./unescapeSelector.js";
import { selectorError } from "./selectorError.js";
import { tokenize } from "./tokenize.js";
export var preFilter = {
ATTR: function( match ) {
match[ 1 ] = unescapeSelector( match[ 1 ] );
// Move the given value to match[3] whether quoted or unquoted
match[ 3 ] = unescapeSelector( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" );
if ( match[ 2 ] === "~=" ) {
match[ 3 ] = " " + match[ 3 ] + " ";
}
return match.slice( 0, 4 );
},
CHILD: function( match ) {
/* matches from filterMatchExpr["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 jQuery.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 ( filterMatchExpr.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 );
}
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/matches.js | src/selector/var/matches.js | import { documentElement } from "../../var/documentElement.js";
// Support: IE 9 - 11+
// IE requires a prefix.
export var matches = documentElement.matches || documentElement.msMatchesSelector;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/rpseudo.js | src/selector/var/rpseudo.js | import { pseudos } from "./pseudos.js";
export var rpseudo = new RegExp( pseudos );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/rsibling.js | src/selector/var/rsibling.js | export var rsibling = /[+~]/;
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/pseudos.js | src/selector/var/pseudos.js | import { identifier } from "./identifier.js";
import { attributes } from "./attributes.js";
export var 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)
".*" +
")\\)|)";
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/attributes.js | src/selector/var/attributes.js | import { whitespace } from "../../var/whitespace.js";
import { identifier } from "./identifier.js";
// Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors
export var 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 + "*\\]";
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/rdescend.js | src/selector/var/rdescend.js | import { whitespace } from "../../var/whitespace.js";
export var rdescend = new RegExp( whitespace + "|>" );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/rcomma.js | src/selector/var/rcomma.js | import { whitespace } from "../../var/whitespace.js";
export var rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/rleadingCombinator.js | src/selector/var/rleadingCombinator.js | import { whitespace } from "../../var/whitespace.js";
export var rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" +
whitespace + ")" + whitespace + "*" );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/selector/var/identifier.js | src/selector/var/identifier.js | import { whitespace } from "../../var/whitespace.js";
// https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
export var identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+";
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/attributes/classes.js | src/attributes/classes.js | import { jQuery } from "../core.js";
import { stripAndCollapse } from "../core/stripAndCollapse.js";
import { rnothtmlwhite } from "../var/rnothtmlwhite.js";
import "../core/init.js";
function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
function classesToArray( value ) {
if ( Array.isArray( value ) ) {
return value;
}
if ( typeof value === "string" ) {
return value.match( rnothtmlwhite ) || [];
}
return [];
}
jQuery.fn.extend( {
addClass: function( value ) {
var classNames, cur, curValue, className, i, finalValue;
if ( typeof value === "function" ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
} );
}
classNames = classesToArray( value );
if ( classNames.length ) {
return this.each( function() {
curValue = getClass( this );
cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
for ( i = 0; i < classNames.length; i++ ) {
className = classNames[ i ];
if ( cur.indexOf( " " + className + " " ) < 0 ) {
cur += className + " ";
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
this.setAttribute( "class", finalValue );
}
}
} );
}
return this;
},
removeClass: function( value ) {
var classNames, cur, curValue, className, i, finalValue;
if ( typeof value === "function" ) {
return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
} );
}
if ( !arguments.length ) {
return this.attr( "class", "" );
}
classNames = classesToArray( value );
if ( classNames.length ) {
return this.each( function() {
curValue = getClass( this );
// This expression is here for better compressibility (see addClass)
cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
if ( cur ) {
for ( i = 0; i < classNames.length; i++ ) {
className = classNames[ i ];
// Remove *all* instances
while ( cur.indexOf( " " + className + " " ) > -1 ) {
cur = cur.replace( " " + className + " ", " " );
}
}
// Only assign if different to avoid unneeded rendering.
finalValue = stripAndCollapse( cur );
if ( curValue !== finalValue ) {
this.setAttribute( "class", finalValue );
}
}
} );
}
return this;
},
toggleClass: function( value, stateVal ) {
var classNames, className, i, self;
if ( typeof value === "function" ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
stateVal
);
} );
}
if ( typeof stateVal === "boolean" ) {
return stateVal ? this.addClass( value ) : this.removeClass( value );
}
classNames = classesToArray( value );
if ( classNames.length ) {
return this.each( function() {
// Toggle individual class names
self = jQuery( this );
for ( i = 0; i < classNames.length; i++ ) {
className = classNames[ i ];
// Check each className given, space separated list
if ( self.hasClass( className ) ) {
self.removeClass( className );
} else {
self.addClass( className );
}
}
} );
}
return this;
},
hasClass: function( selector ) {
var className, elem,
i = 0;
className = " " + selector + " ";
while ( ( elem = this[ i++ ] ) ) {
if ( elem.nodeType === 1 &&
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
return true;
}
}
return false;
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/attributes/prop.js | src/attributes/prop.js | import { jQuery } from "../core.js";
import { access } from "../core/access.js";
import { isIE } from "../var/isIE.js";
var rfocusable = /^(?:input|select|textarea|button)$/i,
rclickable = /^(?:a|area)$/i;
jQuery.fn.extend( {
prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
return this.each( function() {
delete this[ jQuery.propFix[ name ] || name ];
} );
}
} );
jQuery.extend( {
prop: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set properties on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
return ( elem[ name ] = value );
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
return elem[ name ];
},
propHooks: {
tabIndex: {
get: function( elem ) {
// Support: IE <=9 - 11+
// elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// Use proper attribute retrieval (trac-12072)
var tabindex = elem.getAttribute( "tabindex" );
if ( tabindex ) {
return parseInt( tabindex, 10 );
}
if (
rfocusable.test( elem.nodeName ) ||
// href-less anchor's `tabIndex` property value is `0` and
// the `tabindex` attribute value: `null`. We want `-1`.
rclickable.test( elem.nodeName ) && elem.href
) {
return 0;
}
return -1;
}
}
},
propFix: {
"for": "htmlFor",
"class": "className"
}
} );
// Support: IE <=11+
// Accessing the selectedIndex property forces the browser to respect
// setting selected on the option. The getter ensures a default option
// is selected when in an optgroup. ESLint rule "no-unused-expressions"
// is disabled for this code since it considers such accessions noop.
if ( isIE ) {
jQuery.propHooks.selected = {
get: function( elem ) {
var parent = elem.parentNode;
if ( parent && parent.parentNode ) {
// eslint-disable-next-line no-unused-expressions
parent.parentNode.selectedIndex;
}
return null;
},
set: function( elem ) {
var parent = elem.parentNode;
if ( parent ) {
// eslint-disable-next-line no-unused-expressions
parent.selectedIndex;
if ( parent.parentNode ) {
// eslint-disable-next-line no-unused-expressions
parent.parentNode.selectedIndex;
}
}
}
};
}
jQuery.each( [
"tabIndex",
"readOnly",
"maxLength",
"cellSpacing",
"cellPadding",
"rowSpan",
"colSpan",
"useMap",
"frameBorder",
"contentEditable"
], function() {
jQuery.propFix[ this.toLowerCase() ] = this;
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/attributes/val.js | src/attributes/val.js | import { jQuery } from "../core.js";
import { isIE } from "../var/isIE.js";
import { stripAndCollapse } from "../core/stripAndCollapse.js";
import { nodeName } from "../core/nodeName.js";
import "../core/init.js";
jQuery.fn.extend( {
val: function( value ) {
var hooks, ret, valueIsFunction,
elem = this[ 0 ];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret;
}
ret = elem.value;
// Handle cases where value is null/undef or number
return ret == null ? "" : ret;
}
return;
}
valueIsFunction = typeof value === "function";
return this.each( function( i ) {
var val;
if ( this.nodeType !== 1 ) {
return;
}
if ( valueIsFunction ) {
val = value.call( this, i, jQuery( this ).val() );
} else {
val = value;
}
// Treat null/undefined as ""; convert numbers to string
if ( val == null ) {
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( Array.isArray( val ) ) {
val = jQuery.map( val, function( value ) {
return value == null ? "" : value + "";
} );
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
} );
}
} );
jQuery.extend( {
valHooks: {
select: {
get: function( elem ) {
var value, option, i,
options = elem.options,
index = elem.selectedIndex,
one = elem.type === "select-one",
values = one ? null : [],
max = one ? index + 1 : options.length;
if ( index < 0 ) {
i = max;
} else {
i = one ? index : 0;
}
// Loop through all the selected options
for ( ; i < max; i++ ) {
option = options[ i ];
if ( option.selected &&
// Don't return options that are disabled or in a disabled optgroup
!option.disabled &&
( !option.parentNode.disabled ||
!nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
value = jQuery( option ).val();
// We don't need an array for one selects
if ( one ) {
return value;
}
// Multi-Selects return an array
values.push( value );
}
}
return values;
},
set: function( elem, value ) {
var optionSet, option,
options = elem.options,
values = jQuery.makeArray( value ),
i = options.length;
while ( i-- ) {
option = options[ i ];
if ( ( option.selected =
jQuery.inArray( jQuery( option ).val(), values ) > -1
) ) {
optionSet = true;
}
}
// Force browsers to behave consistently when non-matching value is set
if ( !optionSet ) {
elem.selectedIndex = -1;
}
return values;
}
}
}
} );
if ( isIE ) {
jQuery.valHooks.option = {
get: function( elem ) {
var val = elem.getAttribute( "value" );
return val != null ?
val :
// Support: IE <=10 - 11+
// option.text throws exceptions (trac-14686, trac-14858)
// Strip and collapse whitespace
// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
stripAndCollapse( jQuery.text( elem ) );
}
};
}
// Radios and checkboxes getter/setter
jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = {
set: function( elem, value ) {
if ( Array.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
}
}
};
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/attributes/attr.js | src/attributes/attr.js | import { jQuery } from "../core.js";
import { access } from "../core/access.js";
import { nodeName } from "../core/nodeName.js";
import { rnothtmlwhite } from "../var/rnothtmlwhite.js";
import { isIE } from "../var/isIE.js";
jQuery.fn.extend( {
attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 );
},
removeAttr: function( name ) {
return this.each( function() {
jQuery.removeAttr( this, name );
} );
}
} );
jQuery.extend( {
attr: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
// Don't get/set attributes on text, comment and attribute nodes
if ( nType === 3 || nType === 8 || nType === 2 ) {
return;
}
// Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value );
}
// Attribute hooks are determined by the lowercase version
// Grab necessary hook if one is defined
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
hooks = jQuery.attrHooks[ name.toLowerCase() ];
}
if ( value !== undefined ) {
if ( value === null ||
// For compat with previous handling of boolean attributes,
// remove when `false` passed. For ARIA attributes -
// many of which recognize a `"false"` value - continue to
// set the `"false"` value as jQuery <4 did.
( value === false && name.toLowerCase().indexOf( "aria-" ) !== 0 ) ) {
jQuery.removeAttr( elem, name );
return;
}
if ( hooks && "set" in hooks &&
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
return ret;
}
elem.setAttribute( name, value );
return value;
}
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
return ret;
}
ret = elem.getAttribute( name );
// Non-existent attributes return null, we normalize to undefined
return ret == null ? undefined : ret;
},
attrHooks: {},
removeAttr: function( elem, value ) {
var name,
i = 0,
// Attribute names can contain non-HTML whitespace characters
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
attrNames = value && value.match( rnothtmlwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[ i++ ] ) ) {
elem.removeAttribute( name );
}
}
}
} );
// Support: IE <=11+
// An input loses its value after becoming a radio
if ( isIE ) {
jQuery.attrHooks.type = {
set: function( elem, value ) {
if ( value === "radio" && nodeName( elem, "input" ) ) {
var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
}
return value;
}
}
};
}
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/effects/Tween.js | src/effects/Tween.js | import { jQuery } from "../core.js";
import { isAutoPx } from "../css/isAutoPx.js";
import { finalPropName } from "../css/finalPropName.js";
import "../css.js";
function Tween( elem, options, prop, end, easing ) {
return new Tween.prototype.init( elem, options, prop, end, easing );
}
jQuery.Tween = Tween;
Tween.prototype = {
constructor: Tween,
init: function( elem, options, prop, end, easing, unit ) {
this.elem = elem;
this.prop = prop;
this.easing = easing || jQuery.easing._default;
this.options = options;
this.start = this.now = this.cur();
this.end = end;
this.unit = unit || ( isAutoPx( prop ) ? "px" : "" );
},
cur: function() {
var hooks = Tween.propHooks[ this.prop ];
return hooks && hooks.get ?
hooks.get( this ) :
Tween.propHooks._default.get( this );
},
run: function( percent ) {
var eased,
hooks = Tween.propHooks[ this.prop ];
if ( this.options.duration ) {
this.pos = eased = jQuery.easing[ this.easing ](
percent, this.options.duration * percent, 0, 1, this.options.duration
);
} else {
this.pos = eased = percent;
}
this.now = ( this.end - this.start ) * eased + this.start;
if ( this.options.step ) {
this.options.step.call( this.elem, this.now, this );
}
if ( hooks && hooks.set ) {
hooks.set( this );
} else {
Tween.propHooks._default.set( this );
}
return this;
}
};
Tween.prototype.init.prototype = Tween.prototype;
Tween.propHooks = {
_default: {
get: function( tween ) {
var result;
// Use a property on the element directly when it is not a DOM element,
// or when there is no matching style property that exists.
if ( tween.elem.nodeType !== 1 ||
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
return tween.elem[ tween.prop ];
}
// Passing an empty string as a 3rd parameter to .css will automatically
// attempt a parseFloat and fallback to a string if the parse fails.
// Simple values such as "10px" are parsed to Float;
// complex values such as "rotate(1rad)" are returned as-is.
result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result;
},
set: function( tween ) {
// Use step hook for back compat.
// Use cssHook if its there.
// Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.nodeType === 1 && (
jQuery.cssHooks[ tween.prop ] ||
tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
} else {
tween.elem[ tween.prop ] = tween.now;
}
}
}
};
jQuery.easing = {
linear: function( p ) {
return p;
},
swing: function( p ) {
return 0.5 - Math.cos( p * Math.PI ) / 2;
},
_default: "swing"
};
jQuery.fx = Tween.prototype.init;
// Back compat <1.8 extension point
jQuery.fx.step = {};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/effects/animatedSelector.js | src/effects/animatedSelector.js | import { jQuery } from "../core.js";
import "../selector.js";
import "../effects.js";
jQuery.expr.pseudos.animated = function( elem ) {
return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem;
} ).length;
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/queue/delay.js | src/queue/delay.js | import { jQuery } from "../core.js";
import "../queue.js";
import "../effects.js"; // Delay is optional because of this dependency
// Based off of the plugin by Clint Helfers, with permission.
jQuery.fn.delay = function( time, type ) {
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
type = type || "fx";
return this.queue( type, function( next, hooks ) {
var timeout = window.setTimeout( next, time );
hooks.stop = function() {
window.clearTimeout( timeout );
};
} );
};
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
jquery/jquery | https://github.com/jquery/jquery/blob/546a1eb03c345e1bafb72ae1aeb898abb5b3e51b/src/event/trigger.js | src/event/trigger.js | import { jQuery } from "../core.js";
import { document } from "../var/document.js";
import { dataPriv } from "../data/var/dataPriv.js";
import { acceptData } from "../data/var/acceptData.js";
import { hasOwn } from "../var/hasOwn.js";
import { isWindow } from "../var/isWindow.js";
import "../event.js";
var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
stopPropagationCallback = function( e ) {
e.stopPropagation();
};
jQuery.extend( jQuery.event, {
trigger: function( event, data, elem, onlyHandlers ) {
var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = lastElement = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split( "." );
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (trac-9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
lastElement = cur;
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
dataPriv.get( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
}
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( ( !special._default ||
special._default.apply( eventPath.pop(), data ) === false ) &&
acceptData( elem ) ) {
// Call a native DOM method on the target with the same name as the event.
// Don't do default actions on window, that's where global variables be (trac-6170)
if ( ontype && typeof elem[ type ] === "function" && !isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
if ( event.isPropagationStopped() ) {
lastElement.addEventListener( type, stopPropagationCallback );
}
elem[ type ]();
if ( event.isPropagationStopped() ) {
lastElement.removeEventListener( type, stopPropagationCallback );
}
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
}
return event.result;
},
// Piggyback on a donor event to simulate a different one
// Used only for `focus(in | out)` events
simulate: function( type, elem, event ) {
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true
}
);
jQuery.event.trigger( e, null, elem );
}
} );
jQuery.fn.extend( {
trigger: function( type, data ) {
return this.each( function() {
jQuery.event.trigger( type, data, this );
} );
},
triggerHandler: function( type, data ) {
var elem = this[ 0 ];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
}
} );
| javascript | MIT | 546a1eb03c345e1bafb72ae1aeb898abb5b3e51b | 2026-01-04T14:56:53.033090Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.