🌐 AI搜索 & 代理 主页
Skip to content

Commit 1e750a0

Browse files
committed
Use the native Array indexOf method if it exists, for jQuery.inArray.
1 parent 96dd06e commit 1e750a0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ var jQuery = function( selector, context ) {
4040
// Save a reference to some core methods
4141
toString = Object.prototype.toString,
4242
push = Array.prototype.push,
43-
slice = Array.prototype.slice;
43+
slice = Array.prototype.slice,
44+
indexOf = Array.prototype.indexOf;
4445

4546
jQuery.fn = jQuery.prototype = {
4647
init: function( selector, context ) {
@@ -522,6 +523,12 @@ jQuery.extend({
522523
}
523524
});
524525

526+
if ( indexOf ) {
527+
jQuery.inArray = function( elem, array ) {
528+
return indexOf.call( array, elem );
529+
};
530+
}
531+
525532
// All jQuery objects should point back to these
526533
rootjQuery = jQuery(document);
527534

0 commit comments

Comments
 (0)