File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,25 @@ if ( !jQuery.support.opacity ) {
240
240
} ;
241
241
}
242
242
243
+ jQuery ( function ( ) {
244
+ // This hook cannot be added until DOM ready because the support test
245
+ // for it is not run until after DOM ready
246
+ if ( ! jQuery . support . reliableMarginRight ) {
247
+ jQuery . cssHooks . marginRight = {
248
+ get : function ( elem , computed ) {
249
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
250
+ // Work around by temporarily setting element display to inline-block
251
+ var ret = "0px" ,
252
+ display = elem . style . display ;
253
+ elem . style . display = "inline-block" ;
254
+ ret = getComputedStyle ( elem , "margin-right" , "margin-right" ) ;
255
+ elem . style . display = display ;
256
+ return ret ;
257
+ }
258
+ }
259
+ }
260
+ } ) ;
261
+
243
262
if ( document . defaultView && document . defaultView . getComputedStyle ) {
244
263
getComputedStyle = function ( elem , newName , name ) {
245
264
var ret , defaultView , computedStyle ;
Original file line number Diff line number Diff line change 67
67
boxModel : null ,
68
68
inlineBlockNeedsLayout : false ,
69
69
shrinkWrapBlocks : false ,
70
- reliableHiddenOffsets : true
70
+ reliableHiddenOffsets : true ,
71
+ reliableMarginRight : true
71
72
} ;
72
73
73
74
input . checked = true ;
188
189
jQuery . support . reliableHiddenOffsets = jQuery . support . reliableHiddenOffsets && tds [ 0 ] . offsetHeight === 0 ;
189
190
div . innerHTML = "" ;
190
191
192
+ // Check if div with explicit width and no margin-right incorrectly
193
+ // gets computed margin-right based on width of container. For more
194
+ // info see bug #3333
195
+ // Fails in WebKit before Feb 2011 nightlies
196
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
197
+ if ( document . defaultView && document . defaultView . getComputedStyle ) {
198
+ div . style . width = "1px" ;
199
+ div . style . marginRight = "0" ;
200
+ jQuery . support . reliableMarginRight = ( parseInt ( document . defaultView . getComputedStyle ( div ) . marginRight , 10 ) || 0 ) === 0 ;
201
+ }
202
+
191
203
body . removeChild ( div ) . style . display = "none" ;
192
204
div = tds = null ;
193
205
} ) ;
Original file line number Diff line number Diff line change @@ -333,3 +333,15 @@ test("internal ref to elem.runtimeStyle (bug #7608)", function () {
333
333
334
334
ok ( result , "elem.runtimeStyle does not throw exception" ) ;
335
335
} ) ;
336
+
337
+ test ( "marginRight computed style (bug #3333)" , function ( ) {
338
+ expect ( 1 ) ;
339
+
340
+ var $div = jQuery ( "#foo" ) ;
341
+ $div . css ( {
342
+ width : "1px" ,
343
+ marginRight : 0
344
+ } ) ;
345
+
346
+ equals ( $div . css ( "marginRight" ) , "0px" ) ;
347
+ } ) ;
You can’t perform that action at this time.
0 commit comments