1
1
jQuery . support = ( function ( ) {
2
2
3
- var support ,
4
- all ,
5
- a ,
6
- select ,
7
- opt ,
8
- input ,
9
- fragment ,
10
- eventName ,
11
- i ,
12
- isSupported ,
13
- clickFn ,
3
+ var support , all , a , select , opt , input , fragment , eventName , isSupported , i ,
14
4
div = document . createElement ( "div" ) ;
15
5
16
6
// Setup
@@ -80,9 +70,6 @@ jQuery.support = (function() {
80
70
boxModel : document . compatMode === "CSS1Compat" ,
81
71
82
72
// Will be defined later
83
- submitBubbles : true ,
84
- changeBubbles : true ,
85
- focusinBubbles : false ,
86
73
deleteExpando : true ,
87
74
noCloneEvent : true ,
88
75
inlineBlockNeedsLayout : false ,
@@ -101,24 +88,13 @@ jQuery.support = (function() {
101
88
select . disabled = true ;
102
89
support . optDisabled = ! opt . disabled ;
103
90
104
- // Test to see if it's possible to delete an expando from an element
105
- // Fails in Internet Explorer
91
+ // Support: IE<9
106
92
try {
107
93
delete div . test ;
108
94
} catch ( e ) {
109
95
support . deleteExpando = false ;
110
96
}
111
97
112
- if ( ! div . addEventListener && div . attachEvent && div . fireEvent ) {
113
- div . attachEvent ( "onclick" , clickFn = function ( ) {
114
- // Cloning a node shouldn't copy over any
115
- // bound event handlers (IE does this)
116
- support . noCloneEvent = false ;
117
- } ) ;
118
- div . cloneNode ( true ) . fireEvent ( "onclick" ) ;
119
- div . detachEvent ( "onclick" , clickFn ) ;
120
- }
121
-
122
98
// Check if we can trust getAttribute("value")
123
99
input = document . createElement ( "input" ) ;
124
100
input . setAttribute ( "value" , "" ) ;
@@ -130,49 +106,42 @@ jQuery.support = (function() {
130
106
support . radioValue = input . value === "t" ;
131
107
132
108
// #11217 - WebKit loses check when the name is after the checked attribute
133
- input . setAttribute ( "checked" , "checked " ) ;
109
+ input . setAttribute ( "checked" , "t " ) ;
134
110
input . setAttribute ( "name" , "t" ) ;
135
111
136
- div . appendChild ( input ) ;
137
112
fragment = document . createDocumentFragment ( ) ;
138
- fragment . appendChild ( div . lastChild ) ;
139
-
140
- // WebKit doesn't clone checked state correctly in fragments
141
- support . checkClone = fragment . cloneNode ( true ) . cloneNode ( true ) . lastChild . checked ;
113
+ fragment . appendChild ( input ) ;
142
114
143
115
// Check if a disconnected checkbox will retain its checked
144
116
// value of true after appended to the DOM (IE6/7)
145
117
support . appendChecked = input . checked ;
146
118
147
- fragment . removeChild ( input ) ;
148
- fragment . appendChild ( div ) ;
119
+ // WebKit doesn't clone checked state correctly in fragments
120
+ support . checkClone = fragment . cloneNode ( true ) . cloneNode ( true ) . lastChild . checked ;
149
121
150
- // Technique from Juriy Zaytsev
151
- // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
152
- // We only care about the case where non-standard event systems
153
- // are used, namely in IE. Short-circuiting here helps us to
154
- // avoid an eval call (in setAttribute) which can cause CSP
155
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
122
+ // Support: IE<9
123
+ // Opera does not clone events (and typeof div.attachEvent === undefined).
124
+ // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
156
125
if ( div . attachEvent ) {
157
- for ( i in {
158
- submit : true ,
159
- change : true ,
160
- focusin : true
161
- } ) {
162
- eventName = "on" + i ;
163
- isSupported = ( eventName in div ) ;
164
- if ( ! isSupported ) {
165
- div . setAttribute ( eventName , "return;" ) ;
166
- isSupported = ( typeof div [ eventName ] === "function" ) ;
167
- }
168
- support [ i + "Bubbles" ] = isSupported ;
169
- }
126
+ div . attachEvent ( "onclick" , function ( ) {
127
+ support . noCloneEvent = false ;
128
+ } ) ;
129
+
130
+ div . cloneNode ( true ) . click ( ) ;
131
+ }
132
+
133
+ // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
134
+ // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
135
+ for ( i in { submit : true , change : true , focusin : true } ) {
136
+ div . setAttribute ( eventName = "on" + i , "t" ) ;
137
+
138
+ support [ i + "Bubbles" ] = eventName in window || div . attributes [ eventName ] . expando === false ;
170
139
}
171
140
172
141
// Run tests that need a body at doc ready
173
142
jQuery ( function ( ) {
174
- var container , div , tds , marginDiv ,
175
- divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden; box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;" ,
143
+ var container , marginDiv , tds ,
144
+ divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;" ,
176
145
body = document . getElementsByTagName ( "body" ) [ 0 ] ;
177
146
178
147
if ( ! body ) {
@@ -181,20 +150,17 @@ jQuery.support = (function() {
181
150
}
182
151
183
152
container = document . createElement ( "div" ) ;
184
- container . style . cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px" ;
185
- body . insertBefore ( container , body . firstChild ) ;
153
+ container . style . cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px" ;
186
154
187
- // Construct the test element
188
- div = document . createElement ( "div" ) ;
189
- container . appendChild ( div ) ;
155
+ body . appendChild ( container ) . appendChild ( div ) ;
190
156
157
+ // Support: IE8
191
158
// Check if table cells still have offsetWidth/Height when they are set
192
159
// to display:none and there are still other visible table cells in a
193
160
// table row; if so, offsetWidth/Height are not reliable for use when
194
161
// determining if an element has been hidden directly using
195
162
// display:none (it is still safe to use offsets if a parent element is
196
163
// hidden; don safety goggles and see bug #4512 for more information).
197
- // (only IE 8 fails this test)
198
164
div . innerHTML = "<table><tr><td></td><td>t</td></tr></table>" ;
199
165
tds = div . getElementsByTagName ( "td" ) ;
200
166
tds [ 0 ] . style . cssText = "padding:0;margin:0;border:0;display:none" ;
@@ -203,8 +169,8 @@ jQuery.support = (function() {
203
169
tds [ 0 ] . style . display = "" ;
204
170
tds [ 1 ] . style . display = "none" ;
205
171
172
+ // Support: IE8
206
173
// Check if empty table cells still have offsetWidth/Height
207
- // (IE <= 8 fail this test)
208
174
support . reliableHiddenOffsets = isSupported && ( tds [ 0 ] . offsetHeight === 0 ) ;
209
175
210
176
// Check box-sizing and margin behavior
@@ -213,39 +179,36 @@ jQuery.support = (function() {
213
179
support . boxSizing = ( div . offsetWidth === 4 ) ;
214
180
support . doesNotIncludeMarginInBodyOffset = ( body . offsetTop !== 1 ) ;
215
181
216
- // NOTE: To any future maintainer, we've window.getComputedStyle
217
- // because jsdom on node.js will break without it.
182
+ // Use window.getComputedStyle because jsdom on node.js will break without it.
218
183
if ( window . getComputedStyle ) {
219
184
support . pixelPosition = ( window . getComputedStyle ( div , null ) || { } ) . top !== "1%" ;
220
185
support . boxSizingReliable = ( window . getComputedStyle ( div , null ) || { width : "4px" } ) . width === "4px" ;
221
186
222
187
// Check if div with explicit width and no margin-right incorrectly
223
- // gets computed margin-right based on width of container. For more
224
- // info see bug #3333
188
+ // gets computed margin-right based on width of container. (#3333)
225
189
// Fails in WebKit before Feb 2011 nightlies
226
190
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
227
- marginDiv = document . createElement ( "div" ) ;
191
+ marginDiv = div . appendChild ( document . createElement ( "div" ) ) ;
228
192
marginDiv . style . cssText = div . style . cssText = divReset ;
229
193
marginDiv . style . marginRight = marginDiv . style . width = "0" ;
230
194
div . style . width = "1px" ;
231
- div . appendChild ( marginDiv ) ;
195
+
232
196
support . reliableMarginRight =
233
197
! parseFloat ( ( window . getComputedStyle ( marginDiv , null ) || { } ) . marginRight ) ;
234
198
}
235
199
236
200
if ( typeof div . style . zoom !== "undefined" ) {
201
+ // Support: IE<8
237
202
// Check if natively block-level elements act like inline-block
238
203
// elements when setting their display to 'inline' and giving
239
204
// them layout
240
- // (IE < 8 does this)
241
205
div . innerHTML = "" ;
242
206
div . style . cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1" ;
243
207
support . inlineBlockNeedsLayout = ( div . offsetWidth === 3 ) ;
244
208
209
+ // Support: IE6
245
210
// Check if elements with layout shrink-wrap their children
246
- // (IE 6 does this)
247
211
div . style . display = "block" ;
248
- div . style . overflow = "visible" ;
249
212
div . innerHTML = "<div></div>" ;
250
213
div . firstChild . style . width = "5px" ;
251
214
support . shrinkWrapBlocks = ( div . offsetWidth !== 3 ) ;
@@ -255,14 +218,15 @@ jQuery.support = (function() {
255
218
body . style . zoom = 1 ;
256
219
}
257
220
258
- // Null elements to avoid leaks in IE
259
221
body . removeChild ( container ) ;
222
+
223
+ // Null elements to avoid leaks in IE
260
224
container = div = tds = marginDiv = null ;
261
225
} ) ;
262
226
263
227
// Null elements to avoid leaks in IE
264
- fragment . removeChild ( div ) ;
265
- all = a = select = opt = input = fragment = div = null ;
228
+ all = select = fragment = opt = a = input = null ;
266
229
267
230
return support ;
268
231
} ) ( ) ;
232
+
0 commit comments