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

Commit d79bf35

Browse files
markelogdmethvin
authored andcommitted
Fix #13355. Tweak Uglify options and var order for gzip. Close gh-1151.
Change uglify-js options for compressor Change variables initialization sequence for some declarations
1 parent e392e55 commit d79bf35

File tree

12 files changed

+63
-57
lines changed

12 files changed

+63
-57
lines changed

Gruntfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ module.exports = function( grunt ) {
101101
options: {
102102
banner: "/*! jQuery v<%= pkg.version %> | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */",
103103
sourceMap: "dist/jquery.min.map",
104+
compress: {
105+
hoist_funs: false,
106+
join_vars: false,
107+
loops: false,
108+
unused: false
109+
},
104110
beautify: {
105111
ascii_only: true
106112
}

src/ajax.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var
22
// Document location
33
ajaxLocParts,
44
ajaxLocation,
5-
65
ajax_nonce = jQuery.now(),
76

87
ajax_rquery = /\?/,
@@ -115,7 +114,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
115114
// that takes "flat" options (not to be deep extended)
116115
// Fixes #9887
117116
function ajaxExtend( target, src ) {
118-
var key, deep,
117+
var deep, key,
119118
flatOptions = jQuery.ajaxSettings.flatOptions || {};
120119

121120
for ( key in src ) {
@@ -135,7 +134,7 @@ jQuery.fn.load = function( url, params, callback ) {
135134
return _load.apply( this, arguments );
136135
}
137136

138-
var selector, type, response,
137+
var selector, response, type,
139138
self = this,
140139
off = url.indexOf(" ");
141140

@@ -316,20 +315,23 @@ jQuery.extend({
316315
// Force options to be an object
317316
options = options || {};
318317

319-
var transport,
318+
var // Cross-domain detection vars
319+
parts,
320+
// Loop variable
321+
i,
320322
// URL without anti-cache param
321323
cacheURL,
322-
// Response headers
324+
// Response headers as string
323325
responseHeadersString,
324-
responseHeaders,
325326
// timeout handle
326327
timeoutTimer,
327-
// Cross-domain detection vars
328-
parts,
328+
329329
// To know if global events are to be dispatched
330330
fireGlobals,
331-
// Loop variable
332-
i,
331+
332+
transport,
333+
// Response headers
334+
responseHeaders,
333335
// Create the final options object
334336
s = jQuery.ajaxSetup( {}, options ),
335337
// Callbacks context
@@ -704,8 +706,7 @@ jQuery.extend({
704706
* - returns the corresponding response
705707
*/
706708
function ajaxHandleResponses( s, jqXHR, responses ) {
707-
708-
var ct, type, finalDataType, firstDataType,
709+
var firstDataType, ct, finalDataType, type,
709710
contents = s.contents,
710711
dataTypes = s.dataTypes,
711712
responseFields = s.responseFields;
@@ -766,8 +767,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
766767

767768
// Chain conversions given the request and the original response
768769
function ajaxConvert( s, response ) {
769-
770-
var conv, conv2, current, tmp,
770+
var conv2, current, conv, tmp,
771771
converters = {},
772772
i = 0,
773773
// Work with a copy of dataTypes in case we need to modify it for conversion

src/ajax/xhr.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ if ( xhrSupported ) {
101101

102102
// Listener
103103
callback = function( _, isAbort ) {
104-
105-
var status,
106-
statusText,
107-
responseHeaders,
108-
responses;
104+
var status, responseHeaders, statusText, responses;
109105

110106
// Firefox throws exceptions when accessing properties
111107
// of an xhr when a network error occurred

src/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ jQuery.extend({
290290
},
291291

292292
attr: function( elem, name, value ) {
293-
var ret, hooks, notxml,
293+
var hooks, notxml, ret,
294294
nType = elem.nodeType;
295295

296296
// don't get/set attributes on text, comment and attribute nodes

src/callbacks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jQuery.Callbacks = function( options ) {
4646
memory,
4747
// Flag to know if list was already fired
4848
fired,
49-
// First callback to fire (used internally by add and fireWith)
50-
firingStart,
51-
// Index of currently firing callback (modified by remove if needed)
52-
firingIndex,
5349
// End of the loop when firing
5450
firingLength,
51+
// Index of currently firing callback (modified by remove if needed)
52+
firingIndex,
53+
// First callback to fire (used internally by add and fireWith)
54+
firingStart,
5555
// Actual callback list
5656
list = [],
5757
// Stack of fire calls for repeatable lists

src/core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
var
2-
// A central reference to the root jQuery(document)
3-
rootjQuery,
4-
52
// The deferred used on DOM ready
63
readyList,
74

5+
// A central reference to the root jQuery(document)
6+
rootjQuery,
7+
88
// Support: IE<9
99
// For `typeof node.method` instead of `node.method !== undefined`
1010
core_strundefined = typeof undefined,
@@ -93,7 +93,7 @@ jQuery.fn = jQuery.prototype = {
9393

9494
constructor: jQuery,
9595
init: function( selector, context, rootjQuery ) {
96-
var elem, match;
96+
var match, elem;
9797

9898
// HANDLE: $(""), $(null), $(undefined), $(false)
9999
if ( !selector ) {
@@ -288,7 +288,7 @@ jQuery.fn = jQuery.prototype = {
288288
jQuery.fn.init.prototype = jQuery.fn;
289289

290290
jQuery.extend = jQuery.fn.extend = function() {
291-
var copy, options, src, copyIsArray, name, clone,
291+
var src, copyIsArray, copy, name, options, clone,
292292
target = arguments[0] || {},
293293
i = 1,
294294
length = arguments.length,

src/css.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var curCSS, getStyles, iframe,
1+
var iframe, getStyles, curCSS,
22
ralpha = /alpha\([^)]*\)/i,
33
ropacity = /opacity\s*=\s*([^)]*)/,
44
rposition = /^(top|right|bottom|left)$/,
@@ -98,7 +98,7 @@ function showHide( elements, show ) {
9898
jQuery.fn.extend({
9999
css: function( name, value ) {
100100
return jQuery.access( this, function( elem, name, value ) {
101-
var styles, len,
101+
var len, styles,
102102
map = {},
103103
i = 0;
104104

@@ -239,7 +239,7 @@ jQuery.extend({
239239
},
240240

241241
css: function( elem, name, extra, styles ) {
242-
var val, num, hooks,
242+
var num, val, hooks,
243243
origName = jQuery.camelCase( name );
244244

245245
// Make sure that we're working with the right name

src/data.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
22
rmultiDash = /([A-Z])/g;
33

4-
function internalData( elem, name, data, pvt ) {
4+
function internalData( elem, name, data, pvt /* Internal Use Only */ ){
55
if ( !jQuery.acceptData( elem ) ) {
66
return;
77
}
@@ -100,8 +100,7 @@ function internalRemoveData( elem, name, pvt ) {
100100
return;
101101
}
102102

103-
var thisCache, i, l,
104-
103+
var i, l, thisCache,
105104
isNode = elem.nodeType,
106105

107106
// See jQuery.data for more information
@@ -216,7 +215,7 @@ jQuery.extend({
216215
_data: function( elem, name, data ) {
217216
return internalData( elem, name, data, true );
218217
},
219-
218+
220219
_removeData: function( elem, name ) {
221220
return internalRemoveData( elem, name, true );
222221
},

src/effects.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function Animation( elem, properties, options ) {
175175
}
176176

177177
function propFilter( props, specialEasing ) {
178-
var index, name, easing, value, hooks;
178+
var value, name, index, easing, hooks;
179179

180180
// camelCase, specialEasing and expand cssHook pass
181181
for ( index in props ) {
@@ -243,7 +243,9 @@ jQuery.Animation = jQuery.extend( Animation, {
243243

244244
function defaultPrefilter( elem, props, opts ) {
245245
/*jshint validthis:true */
246-
var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
246+
var prop, index, length,
247+
value, dataShow, toggle,
248+
tween, hooks, oldfire,
247249
anim = this,
248250
style = elem.style,
249251
orig = {},

src/event.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ jQuery.event = {
2121
global: {},
2222

2323
add: function( elem, types, handler, data, selector ) {
24-
25-
var handleObjIn, tmp, eventHandle,
26-
t, handleObj, special,
27-
events, handlers, type, namespaces, origType,
24+
var tmp, events, t, handleObjIn,
25+
special, eventHandle, handleObj,
26+
handlers, type, namespaces, origType,
2827
elemData = jQuery._data( elem );
2928

3029
// Don't attach events to noData or text/comment nodes (but allow plain objects)
@@ -132,10 +131,10 @@ jQuery.event = {
132131

133132
// Detach an event or set of events from an element
134133
remove: function( elem, types, handler, selector, mappedTypes ) {
135-
136-
var events, handleObj, tmp,
137-
j, t, origCount,
138-
special, handlers, type, namespaces, origType,
134+
var j, handleObj, tmp,
135+
origCount, t, events,
136+
special, handlers, type,
137+
namespaces, origType,
139138
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
140139

141140
if ( !elemData || !(events = elemData.events) ) {
@@ -205,8 +204,8 @@ jQuery.event = {
205204
},
206205

207206
trigger: function( event, data, elem, onlyHandlers ) {
208-
209-
var i, handle, ontype, bubbleType, tmp, special, cur,
207+
var handle, ontype, cur,
208+
bubbleType, special, tmp, i,
210209
eventPath = [ elem || document ],
211210
type = event.type || event,
212211
namespaces = event.namespace ? event.namespace.split(".") : [];
@@ -343,7 +342,7 @@ jQuery.event = {
343342
// Make a writable jQuery.Event from the native event object
344343
event = jQuery.event.fix( event );
345344

346-
var ret, j, handleObj, matched, i,
345+
var i, ret, handleObj, matched, j,
347346
handlerQueue = [],
348347
args = core_slice.call( arguments ),
349348
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
@@ -398,7 +397,7 @@ jQuery.event = {
398397
},
399398

400399
handlers: function( event, handlers ) {
401-
var i, matches, sel, handleObj,
400+
var sel, handleObj, matches, i,
402401
handlerQueue = [],
403402
delegateCount = handlers.delegateCount,
404403
cur = event.target;
@@ -511,7 +510,7 @@ jQuery.event = {
511510
mouseHooks: {
512511
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
513512
filter: function( event, original ) {
514-
var eventDoc, doc, body,
513+
var body, eventDoc, doc,
515514
button = original.button,
516515
fromElement = original.fromElement;
517516

0 commit comments

Comments
 (0)