Blame view
app/bower_components/jquery/src/core.js
11.1 KB
87c93a029
|
1 2 3 4 5 6 7 8 |
/* global Symbol */ // Defining this global in .eslintrc.json would create a danger of using the global // unguarded in another place, it seems safer to define global only for this module define( [ "./var/arr", "./var/document", "./var/getProto", |
f986e111b
|
9 10 11 12 13 14 15 |
"./var/slice", "./var/concat", "./var/push", "./var/indexOf", "./var/class2type", "./var/toString", "./var/hasOwn", |
87c93a029
|
16 17 18 19 20 21 22 23 24 |
"./var/fnToString", "./var/ObjectFunctionString", "./var/support", "./core/DOMEval" ], function( arr, document, getProto, slice, concat, push, indexOf, class2type, toString, hasOwn, fnToString, ObjectFunctionString, support, DOMEval ) { "use strict"; |
f986e111b
|
25 26 |
var |
87c93a029
|
27 |
version = "3.1.1", |
f986e111b
|
28 29 30 |
// Define a local copy of jQuery jQuery = function( selector, context ) { |
87c93a029
|
31 |
|
f986e111b
|
32 33 34 35 |
// The jQuery object is actually just the init constructor 'enhanced' // Need init if jQuery is called (just allow error to be thrown if not included) return new jQuery.fn.init( selector, context ); }, |
87c93a029
|
36 |
// Support: Android <=4.0 only |
f986e111b
|
37 38 39 40 41 |
// Make sure we trim BOM and NBSP rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, // Matches dashed string for camelizing rmsPrefix = /^-ms-/, |
87c93a029
|
42 |
rdashAlpha = /-([a-z])/g, |
f986e111b
|
43 44 45 46 47 48 49 |
// Used by jQuery.camelCase as callback to replace() fcamelCase = function( all, letter ) { return letter.toUpperCase(); }; jQuery.fn = jQuery.prototype = { |
87c93a029
|
50 |
|
f986e111b
|
51 52 53 54 |
// The current version of jQuery being used jquery: version, constructor: jQuery, |
f986e111b
|
55 56 57 58 59 60 61 62 63 64 |
// The default length of a jQuery object is 0 length: 0, toArray: function() { return slice.call( this ); }, // Get the Nth element in the matched element set OR // Get the whole matched element set as a clean array get: function( num ) { |
f986e111b
|
65 |
|
87c93a029
|
66 67 68 69 |
// Return all the elements in a clean array if ( num == null ) { return slice.call( this ); } |
f986e111b
|
70 |
|
87c93a029
|
71 72 |
// Return just the one element from the set return num < 0 ? this[ num + this.length ] : this[ num ]; |
f986e111b
|
73 74 75 76 77 78 79 80 81 82 83 |
}, // Take an array of elements and push it onto the stack // (returning the new matched element set) pushStack: function( elems ) { // Build a new jQuery matched element set var ret = jQuery.merge( this.constructor(), elems ); // Add the old object onto the stack (as a reference) ret.prevObject = this; |
f986e111b
|
84 85 86 87 88 89 |
// Return the newly-formed element set return ret; }, // Execute a callback for every element in the matched set. |
87c93a029
|
90 91 |
each: function( callback ) { return jQuery.each( this, callback ); |
f986e111b
|
92 93 94 |
}, map: function( callback ) { |
87c93a029
|
95 |
return this.pushStack( jQuery.map( this, function( elem, i ) { |
f986e111b
|
96 |
return callback.call( elem, i, elem ); |
87c93a029
|
97 |
} ) ); |
f986e111b
|
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
}, slice: function() { return this.pushStack( slice.apply( this, arguments ) ); }, first: function() { return this.eq( 0 ); }, last: function() { return this.eq( -1 ); }, eq: function( i ) { var len = this.length, j = +i + ( i < 0 ? len : 0 ); |
87c93a029
|
115 |
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); |
f986e111b
|
116 117 118 |
}, end: function() { |
87c93a029
|
119 |
return this.prevObject || this.constructor(); |
f986e111b
|
120 121 122 123 124 |
}, // For internal use only. // Behaves like an Array's method, not like a jQuery method. push: push, |
87c93a029
|
125 126 |
sort: arr.sort, splice: arr.splice |
f986e111b
|
127 128 129 |
}; jQuery.extend = jQuery.fn.extend = function() { |
87c93a029
|
130 131 |
var options, name, src, copy, copyIsArray, clone, target = arguments[ 0 ] || {}, |
f986e111b
|
132 133 134 135 136 137 138 |
i = 1, length = arguments.length, deep = false; // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target; |
87c93a029
|
139 |
// Skip the boolean and the target |
f986e111b
|
140 141 142 143 144 |
target = arguments[ i ] || {}; i++; } // Handle case when target is a string or something (possible in deep copy) |
87c93a029
|
145 |
if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { |
f986e111b
|
146 147 |
target = {}; } |
87c93a029
|
148 |
// Extend jQuery itself if only one argument is passed |
f986e111b
|
149 150 151 152 153 154 |
if ( i === length ) { target = this; i--; } for ( ; i < length; i++ ) { |
87c93a029
|
155 |
|
f986e111b
|
156 |
// Only deal with non-null/undefined values |
87c93a029
|
157 |
if ( ( options = arguments[ i ] ) != null ) { |
f986e111b
|
158 159 160 161 162 163 164 165 166 167 168 |
// Extend the base object for ( name in options ) { src = target[ name ]; copy = options[ name ]; // Prevent never-ending loop if ( target === copy ) { continue; } // Recurse if we're merging plain objects or arrays |
87c93a029
|
169 170 |
if ( deep && copy && ( jQuery.isPlainObject( copy ) || ( copyIsArray = jQuery.isArray( copy ) ) ) ) { |
f986e111b
|
171 172 |
if ( copyIsArray ) { copyIsArray = false; |
87c93a029
|
173 |
clone = src && jQuery.isArray( src ) ? src : []; |
f986e111b
|
174 175 |
} else { |
87c93a029
|
176 |
clone = src && jQuery.isPlainObject( src ) ? src : {}; |
f986e111b
|
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
} // Never move original objects, clone them target[ name ] = jQuery.extend( deep, clone, copy ); // Don't bring in undefined values } else if ( copy !== undefined ) { target[ name ] = copy; } } } } // Return the modified object return target; }; |
87c93a029
|
193 |
jQuery.extend( { |
f986e111b
|
194 195 196 197 198 199 200 201 202 203 204 |
// Unique for each copy of jQuery on the page expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), // Assume jQuery is ready without the ready module isReady: true, error: function( msg ) { throw new Error( msg ); }, noop: function() {}, |
f986e111b
|
205 |
isFunction: function( obj ) { |
87c93a029
|
206 |
return jQuery.type( obj ) === "function"; |
f986e111b
|
207 |
}, |
87c93a029
|
208 |
isArray: Array.isArray, |
f986e111b
|
209 210 |
isWindow: function( obj ) { |
87c93a029
|
211 |
return obj != null && obj === obj.window; |
f986e111b
|
212 213 214 |
}, isNumeric: function( obj ) { |
f986e111b
|
215 |
|
87c93a029
|
216 217 218 219 220 221 222 223 224 225 |
// As of jQuery 3.0, isNumeric is limited to // strings and numbers (primitives or objects) // that can be coerced to finite numbers (gh-2662) var type = jQuery.type( obj ); return ( type === "number" || type === "string" ) && // parseFloat NaNs numeric-cast false positives ("") // ...but misinterprets leading-number strings, particularly hex literals ("0x...") // subtraction forces infinities to NaN !isNaN( obj - parseFloat( obj ) ); |
f986e111b
|
226 227 228 |
}, isPlainObject: function( obj ) { |
87c93a029
|
229 |
var proto, Ctor; |
f986e111b
|
230 |
|
87c93a029
|
231 232 233 |
// Detect obvious negatives // Use toString instead of jQuery.type to catch host objects if ( !obj || toString.call( obj ) !== "[object Object]" ) { |
f986e111b
|
234 235 |
return false; } |
87c93a029
|
236 |
proto = getProto( obj ); |
f986e111b
|
237 |
|
87c93a029
|
238 239 240 |
// Objects with no prototype (e.g., `Object.create( null )`) are plain if ( !proto ) { return true; |
f986e111b
|
241 |
} |
87c93a029
|
242 243 244 245 246 247 248 249 250 251 |
// Objects with prototype are plain iff they were constructed by a global Object function Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; }, isEmptyObject: function( obj ) { /* eslint-disable no-unused-vars */ // See https://github.com/eslint/eslint/issues/6125 var name; |
f986e111b
|
252 |
|
87c93a029
|
253 254 255 256 |
for ( name in obj ) { return false; } return true; |
f986e111b
|
257 258 259 260 261 262 |
}, type: function( obj ) { if ( obj == null ) { return obj + ""; } |
87c93a029
|
263 264 |
// Support: Android <=2.3 only (functionish RegExp) |
f986e111b
|
265 |
return typeof obj === "object" || typeof obj === "function" ? |
87c93a029
|
266 |
class2type[ toString.call( obj ) ] || "object" : |
f986e111b
|
267 268 269 270 |
typeof obj; }, // Evaluates a script in a global context |
87c93a029
|
271 272 |
globalEval: function( code ) { DOMEval( code ); |
f986e111b
|
273 274 275 |
}, // Convert dashed to camelCase; used by the css and data modules |
87c93a029
|
276 |
// Support: IE <=9 - 11, Edge 12 - 13 |
f986e111b
|
277 278 279 280 281 282 283 284 |
// Microsoft forgot to hump their vendor prefix (#9572) camelCase: function( string ) { return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); }, nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, |
87c93a029
|
285 286 |
each: function( obj, callback ) { var length, i = 0; |
f986e111b
|
287 |
|
87c93a029
|
288 289 290 291 292 |
if ( isArrayLike( obj ) ) { length = obj.length; for ( ; i < length; i++ ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { break; |
f986e111b
|
293 294 |
} } |
f986e111b
|
295 |
} else { |
87c93a029
|
296 297 298 |
for ( i in obj ) { if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { break; |
f986e111b
|
299 300 301 302 303 304 |
} } } return obj; }, |
87c93a029
|
305 |
// Support: Android <=4.0 only |
f986e111b
|
306 307 308 309 310 311 312 313 314 315 316 |
trim: function( text ) { return text == null ? "" : ( text + "" ).replace( rtrim, "" ); }, // results is for internal usage only makeArray: function( arr, results ) { var ret = results || []; if ( arr != null ) { |
87c93a029
|
317 |
if ( isArrayLike( Object( arr ) ) ) { |
f986e111b
|
318 319 320 321 322 323 324 325 326 327 328 329 330 |
jQuery.merge( ret, typeof arr === "string" ? [ arr ] : arr ); } else { push.call( ret, arr ); } } return ret; }, inArray: function( elem, arr, i ) { |
87c93a029
|
331 |
return arr == null ? -1 : indexOf.call( arr, elem, i ); |
f986e111b
|
332 |
}, |
87c93a029
|
333 334 |
// Support: Android <=4.0 only, PhantomJS 1 only // push.apply(_, arraylike) throws on ancient WebKit |
f986e111b
|
335 336 337 338 |
merge: function( first, second ) { var len = +second.length, j = 0, i = first.length; |
87c93a029
|
339 340 |
for ( ; j < len; j++ ) { first[ i++ ] = second[ j ]; |
f986e111b
|
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
} first.length = i; return first; }, grep: function( elems, callback, invert ) { var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert; // Go through the array, only saving the items // that pass the validator function for ( ; i < length; i++ ) { callbackInverse = !callback( elems[ i ], i ); if ( callbackInverse !== callbackExpect ) { matches.push( elems[ i ] ); } } return matches; }, // arg is for internal usage only map: function( elems, callback, arg ) { |
87c93a029
|
369 |
var length, value, |
f986e111b
|
370 |
i = 0, |
f986e111b
|
371 372 373 |
ret = []; // Go through the array, translating each of the items to their new values |
87c93a029
|
374 375 |
if ( isArrayLike( elems ) ) { length = elems.length; |
f986e111b
|
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
for ( ; i < length; i++ ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } // Go through every key on the object, } else { for ( i in elems ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } } // Flatten any nested arrays return concat.apply( [], ret ); }, // A global GUID counter for objects guid: 1, // Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { |
87c93a029
|
405 |
var tmp, args, proxy; |
f986e111b
|
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
if ( typeof context === "string" ) { tmp = fn[ context ]; context = fn; fn = tmp; } // Quick check to determine if target is callable, in the spec // this throws a TypeError, but we will just return undefined. if ( !jQuery.isFunction( fn ) ) { return undefined; } // Simulated bind args = slice.call( arguments, 2 ); proxy = function() { return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); }; // Set the guid of unique handler to the same of original handler, so it can be removed proxy.guid = fn.guid = fn.guid || jQuery.guid++; return proxy; }, |
87c93a029
|
430 |
now: Date.now, |
f986e111b
|
431 432 433 434 |
// jQuery.support is not used in Core but other projects attach their // properties to it so it needs to exist. support: support |
87c93a029
|
435 436 437 438 439 |
} ); if ( typeof Symbol === "function" ) { jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; } |
f986e111b
|
440 441 |
// Populate the class2type map |
87c93a029
|
442 443 |
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), function( i, name ) { |
f986e111b
|
444 |
class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
87c93a029
|
445 |
} ); |
f986e111b
|
446 |
|
87c93a029
|
447 |
function isArrayLike( obj ) { |
f986e111b
|
448 |
|
87c93a029
|
449 |
// Support: real iOS 8.2 only (not reproducible in simulator) |
f986e111b
|
450 451 452 |
// `in` check used to prevent JIT error (gh-2145) // hasOwn isn't used here due to false negatives // regarding Nodelist length in IE |
87c93a029
|
453 |
var length = !!obj && "length" in obj && obj.length, |
f986e111b
|
454 455 456 457 458 |
type = jQuery.type( obj ); if ( type === "function" || jQuery.isWindow( obj ) ) { return false; } |
f986e111b
|
459 460 461 462 463 |
return type === "array" || length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj; } return jQuery; |
87c93a029
|
464 |
} ); |