Skip to content

Commit 401a351

Browse files
committed
Event: provide verbose info for focus(in | out) & rename support props
Ref c074006 Ref gh-2312
1 parent 8d88cd5 commit 401a351

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

src/event.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ jQuery.each({
828828
});
829829

830830
// IE submit delegation
831-
if ( !support.submitBubbles ) {
831+
if ( !support.submit ) {
832832

833833
jQuery.event.special.submit = {
834834
setup: function() {
@@ -845,11 +845,11 @@ if ( !support.submitBubbles ) {
845845
elem.form :
846846
undefined;
847847

848-
if ( form && !jQuery._data( form, "submitBubbles" ) ) {
848+
if ( form && !jQuery._data( form, "submit" ) ) {
849849
jQuery.event.add( form, "submit._submit", function( event ) {
850850
event._submitBubble = true;
851851
});
852-
jQuery._data( form, "submitBubbles", true );
852+
jQuery._data( form, "submit", true );
853853
}
854854
});
855855
// return undefined since we don't need an event listener
@@ -878,7 +878,7 @@ if ( !support.submitBubbles ) {
878878
}
879879

880880
// IE change delegation and checkbox/radio fix
881-
if ( !support.changeBubbles ) {
881+
if ( !support.change ) {
882882

883883
jQuery.event.special.change = {
884884

@@ -908,13 +908,13 @@ if ( !support.changeBubbles ) {
908908
jQuery.event.add( this, "beforeactivate._change", function( e ) {
909909
var elem = e.target;
910910

911-
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
911+
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
912912
jQuery.event.add( elem, "change._change", function( event ) {
913913
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
914914
jQuery.event.simulate( "change", this.parentNode, event, true );
915915
}
916916
});
917-
jQuery._data( elem, "changeBubbles", true );
917+
jQuery._data( elem, "change", true );
918918
}
919919
});
920920
},
@@ -938,14 +938,21 @@ if ( !support.changeBubbles ) {
938938
};
939939
}
940940

941-
// Create "bubbling" focus and blur events
942-
if ( !support.focusinBubbles ) {
941+
// Support: Firefox
942+
// Firefox doesn't have focus(in | out) events
943+
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
944+
//
945+
// Support: Chrome, Safari
946+
// focus(in | out) events fire after focus & blur events,
947+
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
948+
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
949+
if ( !support.focusin ) {
943950
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
944951

945952
// Attach a single capturing handler on the document while someone wants focusin/focusout
946953
var handler = function( event ) {
947-
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
948-
};
954+
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
955+
};
949956

950957
jQuery.event.special[ fix ] = {
951958
setup: function() {

src/event/support.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ define([
66
var i, eventName,
77
div = document.createElement( "div" );
88

9-
// Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
9+
// Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
1010
for ( i in { submit: true, change: true, focusin: true }) {
1111
eventName = "on" + i;
1212

13-
if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
13+
if ( !(support[ i ] = eventName in window) ) {
1414
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
1515
div.setAttribute( eventName, "t" );
16-
support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
16+
support[ i ] = div.attributes[ eventName ].expando === false;
1717
}
1818
}
1919

test/unit/support.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
7575
"ajax": true,
7676
"attributes": true,
7777
"boxSizingReliable": true,
78-
"changeBubbles": true,
78+
"change": true,
7979
"checkClone": true,
8080
"checkOn": true,
8181
"clearCloneStyle": true,
8282
"cors": true,
8383
"createHTMLDocument": true,
8484
"cssFloat": true,
8585
"deleteExpando": true,
86-
"focusinBubbles": false,
86+
"focusin": false,
8787
"html5Clone": true,
8888
"htmlSerialize": true,
8989
"input": true,
@@ -100,22 +100,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
100100
"reliableHiddenOffsets": true,
101101
"reliableMarginRight": true,
102102
"style": true,
103-
"submitBubbles": true
103+
"submit": true
104104
};
105105
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
106106
expected = {
107107
"ajax": true,
108108
"attributes": true,
109109
"boxSizingReliable": false,
110-
"changeBubbles": true,
110+
"change": true,
111111
"checkClone": true,
112112
"checkOn": true,
113113
"clearCloneStyle": false,
114114
"cors": true,
115115
"createHTMLDocument": true,
116116
"cssFloat": true,
117117
"deleteExpando": true,
118-
"focusinBubbles": true,
118+
"focusin": true,
119119
"html5Clone": true,
120120
"htmlSerialize": true,
121121
"input": true,
@@ -132,22 +132,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
132132
"reliableHiddenOffsets": true,
133133
"reliableMarginRight": true,
134134
"style": true,
135-
"submitBubbles": true
135+
"submit": true
136136
};
137137
} else if ( /msie 9\.0/i.test( userAgent ) ) {
138138
expected = {
139139
"ajax": true,
140140
"attributes": true,
141141
"boxSizingReliable": false,
142-
"changeBubbles": true,
142+
"change": true,
143143
"checkClone": true,
144144
"checkOn": true,
145145
"clearCloneStyle": false,
146146
"cors": false,
147147
"createHTMLDocument": true,
148148
"cssFloat": true,
149149
"deleteExpando": true,
150-
"focusinBubbles": true,
150+
"focusin": true,
151151
"html5Clone": true,
152152
"htmlSerialize": true,
153153
"input": true,
@@ -164,22 +164,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
164164
"reliableHiddenOffsets": true,
165165
"reliableMarginRight": true,
166166
"style": true,
167-
"submitBubbles": true
167+
"submit": true
168168
};
169169
} else if ( /msie 8\.0/i.test( userAgent ) ) {
170170
expected = {
171171
"ajax": true,
172172
"attributes": false,
173173
"boxSizingReliable": false,
174-
"changeBubbles": false,
174+
"change": false,
175175
"checkClone": true,
176176
"checkOn": true,
177177
"clearCloneStyle": true,
178178
"cors": false,
179179
"createHTMLDocument": false,
180180
"cssFloat": false,
181181
"deleteExpando": false,
182-
"focusinBubbles": true,
182+
"focusin": true,
183183
"html5Clone": false,
184184
"htmlSerialize": false,
185185
"input": false,
@@ -196,22 +196,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
196196
"reliableHiddenOffsets": false,
197197
"reliableMarginRight": true,
198198
"style": false,
199-
"submitBubbles": false
199+
"submit": false
200200
};
201201
} else if ( /8.0(\.\d+|) safari/i.test( userAgent ) ) {
202202
expected = {
203203
"ajax": true,
204204
"attributes": true,
205205
"boxSizingReliable": true,
206-
"changeBubbles": true,
206+
"change": true,
207207
"checkClone": true,
208208
"checkOn": true,
209209
"clearCloneStyle": true,
210210
"cors": true,
211211
"createHTMLDocument": false,
212212
"cssFloat": true,
213213
"deleteExpando": true,
214-
"focusinBubbles": false,
214+
"focusin": false,
215215
"html5Clone": true,
216216
"htmlSerialize": true,
217217
"input": true,
@@ -228,22 +228,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
228228
"reliableHiddenOffsets": true,
229229
"reliableMarginRight": true,
230230
"style": true,
231-
"submitBubbles": true
231+
"submit": true
232232
};
233233
} else if ( /(6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
234234
expected = {
235235
"ajax": true,
236236
"attributes": true,
237237
"boxSizingReliable": true,
238-
"changeBubbles": true,
238+
"change": true,
239239
"checkClone": true,
240240
"checkOn": true,
241241
"clearCloneStyle": true,
242242
"cors": true,
243243
"createHTMLDocument": true,
244244
"cssFloat": true,
245245
"deleteExpando": true,
246-
"focusinBubbles": false,
246+
"focusin": false,
247247
"html5Clone": true,
248248
"htmlSerialize": true,
249249
"input": true,
@@ -260,22 +260,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
260260
"reliableHiddenOffsets": true,
261261
"reliableMarginRight": true,
262262
"style": true,
263-
"submitBubbles": true
263+
"submit": true
264264
};
265265
} else if ( /firefox/i.test( userAgent ) ) {
266266
expected = {
267267
"ajax": true,
268268
"attributes": true,
269269
"boxSizingReliable": true,
270-
"changeBubbles": true,
270+
"change": true,
271271
"checkClone": true,
272272
"checkOn": true,
273273
"clearCloneStyle": true,
274274
"cors": true,
275275
"createHTMLDocument": true,
276276
"cssFloat": true,
277277
"deleteExpando": true,
278-
"focusinBubbles": false,
278+
"focusin": false,
279279
"html5Clone": true,
280280
"htmlSerialize": true,
281281
"input": true,
@@ -292,22 +292,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
292292
"reliableHiddenOffsets": true,
293293
"reliableMarginRight": true,
294294
"style": true,
295-
"submitBubbles": true
295+
"submit": true
296296
};
297297
} else if ( /iphone os 8/i.test( userAgent ) ) {
298298
expected = {
299299
"ajax": true,
300300
"attributes": true,
301301
"boxSizingReliable": true,
302-
"changeBubbles": true,
302+
"change": true,
303303
"checkClone": true,
304304
"checkOn": true,
305305
"clearCloneStyle": true,
306306
"cors": true,
307307
"createHTMLDocument": false,
308308
"cssFloat": true,
309309
"deleteExpando": true,
310-
"focusinBubbles": false,
310+
"focusin": false,
311311
"html5Clone": true,
312312
"htmlSerialize": true,
313313
"input": true,
@@ -324,22 +324,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
324324
"reliableHiddenOffsets": true,
325325
"reliableMarginRight": true,
326326
"style": true,
327-
"submitBubbles": true
327+
"submit": true
328328
};
329329
} else if ( /iphone os (6|7)/i.test( userAgent ) ) {
330330
expected = {
331331
"ajax": true,
332332
"attributes": true,
333333
"boxSizingReliable": true,
334-
"changeBubbles": true,
334+
"change": true,
335335
"checkClone": true,
336336
"checkOn": true,
337337
"clearCloneStyle": true,
338338
"cors": true,
339339
"createHTMLDocument": true,
340340
"cssFloat": true,
341341
"deleteExpando": true,
342-
"focusinBubbles": false,
342+
"focusin": false,
343343
"html5Clone": true,
344344
"htmlSerialize": true,
345345
"input": true,
@@ -356,22 +356,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
356356
"reliableHiddenOffsets": true,
357357
"reliableMarginRight": true,
358358
"style": true,
359-
"submitBubbles": true
359+
"submit": true
360360
};
361361
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
362362
expected = {
363363
"ajax": true,
364364
"attributes": true,
365365
"boxSizingReliable": true,
366-
"changeBubbles": true,
366+
"change": true,
367367
"checkClone": false,
368368
"checkOn": false,
369369
"clearCloneStyle": true,
370370
"cors": true,
371371
"createHTMLDocument": true,
372372
"cssFloat": true,
373373
"deleteExpando": true,
374-
"focusinBubbles": false,
374+
"focusin": false,
375375
"html5Clone": true,
376376
"htmlSerialize": true,
377377
"input": true,
@@ -388,22 +388,22 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
388388
"reliableHiddenOffsets": true,
389389
"reliableMarginRight": true,
390390
"style": true,
391-
"submitBubbles": true
391+
"submit": true
392392
};
393393
} else if ( /android 2\.3/i.test( userAgent ) ) {
394394
expected = {
395395
"ajax": true,
396396
"attributes": true,
397397
"boxSizingReliable": true,
398-
"changeBubbles": true,
398+
"change": true,
399399
"checkClone": true,
400400
"checkOn": false,
401401
"clearCloneStyle": false,
402402
"cors": true,
403403
"createHTMLDocument": true,
404404
"cssFloat": true,
405405
"deleteExpando": true,
406-
"focusinBubbles": false,
406+
"focusin": false,
407407
"html5Clone": true,
408408
"htmlSerialize": true,
409409
"input": true,
@@ -420,7 +420,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
420420
"reliableHiddenOffsets": true,
421421
"reliableMarginRight": false,
422422
"style": true,
423-
"submitBubbles": true
423+
"submit": true
424424
};
425425
}
426426

0 commit comments

Comments
 (0)