Skip to content

Commit f519539

Browse files
committed
No ticket: Compress core and data modules
(cherry picked from commit b31bd4c) Conflicts: src/core.js src/data.js
1 parent 33c80f3 commit f519539

File tree

2 files changed

+48
-48
lines changed

2 files changed

+48
-48
lines changed

src/core.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ jQuery.fn = jQuery.prototype = {
5858
// Get the Nth element in the matched element set OR
5959
// Get the whole matched element set as a clean array
6060
get: function( num ) {
61-
return num == null ?
61+
return num != null ?
6262

6363
// Return a 'clean' array
64-
this.toArray() :
64+
( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6565

6666
// Return just the object
67-
( num < 0 ? this[ this.length + num ] : this[ num ] );
67+
slice.call( this );
6868
},
6969

7070
// Take an array of elements and push it onto the stack
@@ -89,6 +89,12 @@ jQuery.fn = jQuery.prototype = {
8989
return jQuery.each( this, callback, args );
9090
},
9191

92+
map: function( callback ) {
93+
return this.pushStack( jQuery.map(this, function( elem, i ) {
94+
return callback.call( elem, i, elem );
95+
}));
96+
},
97+
9298
slice: function() {
9399
return this.pushStack( slice.apply( this, arguments ) );
94100
},
@@ -107,12 +113,6 @@ jQuery.fn = jQuery.prototype = {
107113
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
108114
},
109115

110-
map: function( callback ) {
111-
return this.pushStack( jQuery.map(this, function( elem, i ) {
112-
return callback.call( elem, i, elem );
113-
}));
114-
},
115-
116116
end: function() {
117117
return this.prevObject || this.constructor(null);
118118
},
@@ -134,9 +134,10 @@ jQuery.extend = jQuery.fn.extend = function() {
134134
// Handle a deep copy situation
135135
if ( typeof target === "boolean" ) {
136136
deep = target;
137-
target = arguments[1] || {};
137+
138138
// skip the boolean and the target
139-
i = 2;
139+
target = arguments[ i ] || {};
140+
i++;
140141
}
141142

142143
// Handle case when target is a string or something (possible in deep copy)
@@ -145,9 +146,9 @@ jQuery.extend = jQuery.fn.extend = function() {
145146
}
146147

147148
// extend jQuery itself if only one argument is passed
148-
if ( length === i ) {
149+
if ( i === length ) {
149150
target = this;
150-
--i;
151+
i--;
151152
}
152153

153154
for ( ; i < length; i++ ) {
@@ -195,6 +196,12 @@ jQuery.extend({
195196
// Assume jQuery is ready without the ready module
196197
isReady: true,
197198

199+
error: function( msg ) {
200+
throw new Error( msg );
201+
},
202+
203+
noop: function() {},
204+
198205
noConflict: function( deep ) {
199206
if ( window.$ === jQuery ) {
200207
window.$ = _$;
@@ -227,16 +234,6 @@ jQuery.extend({
227234
return obj - parseFloat( obj ) >= 0;
228235
},
229236

230-
type: function( obj ) {
231-
if ( obj == null ) {
232-
return String( obj );
233-
}
234-
// Support: Android < 4.0, iOS < 6 (functionish RegExp)
235-
return typeof obj === "object" || typeof obj === "function" ?
236-
class2type[ toString.call(obj) ] || "object" :
237-
typeof obj;
238-
},
239-
240237
isPlainObject: function( obj ) {
241238
// Not plain objects:
242239
// - Any object or value whose internal [[Class]] property is not "[object Object]"
@@ -272,12 +269,16 @@ jQuery.extend({
272269
return true;
273270
},
274271

275-
error: function( msg ) {
276-
throw new Error( msg );
272+
type: function( obj ) {
273+
if ( obj == null ) {
274+
return obj + "";
275+
}
276+
// Support: Android < 4.0, iOS < 6 (functionish RegExp)
277+
return typeof obj === "object" || typeof obj === "function" ?
278+
class2type[ toString.call(obj) ] || "object" :
279+
typeof obj;
277280
},
278281

279-
noop: function() {},
280-
281282
// Evaluates a script in a global context
282283
globalEval: function( code ) {
283284
var script,
@@ -401,23 +402,23 @@ jQuery.extend({
401402
return first;
402403
},
403404

404-
grep: function( elems, callback, inv ) {
405-
var retVal,
406-
ret = [],
405+
grep: function( elems, callback, invert ) {
406+
var callbackInverse,
407+
matches = [],
407408
i = 0,
408-
length = elems.length;
409-
inv = !!inv;
409+
length = elems.length,
410+
callbackExpect = !invert;
410411

411412
// Go through the array, only saving the items
412413
// that pass the validator function
413414
for ( ; i < length; i++ ) {
414-
retVal = !!callback( elems[ i ], i );
415-
if ( inv !== retVal ) {
416-
ret.push( elems[ i ] );
415+
callbackInverse = !callback( elems[ i ], i );
416+
if ( callbackInverse !== callbackExpect ) {
417+
matches.push( elems[ i ] );
417418
}
418419
}
419420

420-
return ret;
421+
return matches;
421422
},
422423

423424
// arg is for internal usage only
@@ -434,7 +435,7 @@ jQuery.extend({
434435
value = callback( elems[ i ], i, arg );
435436

436437
if ( value != null ) {
437-
ret[ ret.length ] = value;
438+
ret.push( value );
438439
}
439440
}
440441

@@ -444,7 +445,7 @@ jQuery.extend({
444445
value = callback( elems[ i ], i, arg );
445446

446447
if ( value != null ) {
447-
ret[ ret.length ] = value;
448+
ret.push( value );
448449
}
449450
}
450451
}
@@ -501,17 +502,16 @@ function isArraylike( obj ) {
501502
var length = obj.length,
502503
type = jQuery.type( obj );
503504

504-
if ( jQuery.isWindow( obj ) ) {
505+
if ( type === "function" || jQuery.isWindow( obj ) ) {
505506
return false;
506507
}
507508

508509
if ( obj.nodeType === 1 && length ) {
509510
return true;
510511
}
511512

512-
return type === "array" || type !== "function" &&
513-
( length === 0 ||
514-
typeof length === "number" && length > 0 && ( length - 1 ) in obj );
513+
return type === "array" || length === 0 ||
514+
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
515515
}
516516

517517
return jQuery;

src/data.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ define([
1717
5. Avoid exposing implementation details on user objects (eg. expando properties)
1818
6. Provide a clear path for implementation upgrade to WeakMap in 2014
1919
*/
20-
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
20+
var rbrace = /(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
2121
rmultiDash = /([A-Z])/g;
2222

2323
function dataAttr( elem, key, data ) {
@@ -75,19 +75,19 @@ jQuery.extend({
7575

7676
jQuery.fn.extend({
7777
data: function( key, value ) {
78-
var attrs, name,
78+
var i, name,
79+
data = null,
7980
elem = this[ 0 ],
80-
i = 0,
81-
data = null;
81+
attrs = elem && elem.attributes;
8282

8383
// Gets all values
8484
if ( key === undefined ) {
8585
if ( this.length ) {
8686
data = data_user.get( elem );
8787

8888
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
89-
attrs = elem.attributes;
90-
for ( ; i < attrs.length; i++ ) {
89+
i = attrs.length;
90+
while ( i-- ) {
9191
name = attrs[ i ].name;
9292

9393
if ( name.indexOf( "data-" ) === 0 ) {

0 commit comments

Comments
 (0)