jQuery 1.8.2 + noncurrent jQuery UI = outerWidth and outerHeight broken

2.5k views Asked by At

This is a re-do of a question that was closed erroneously: jQuery 1.8 outer Height/Width not working

I'm hitting the same issue. outerWidth and outerHeight and now returning the jQuery object instead of numbers.

We are using jQuery UI 1.8.17, released Jan 10, 2012. It is not a super old version so I have a feeling other people will see this. We are locked into this version because of some terrible jQuery ui plugins, so upgrading is not currently an option.

If I find a solution I will answer this question.

Here's a fiddle demonstrating the problem http://jsfiddle.net/delvarworld/yxDHu/ (jQuery UI version added in "manage resources")

Update: It's because this line in jQuery UI:

return orig[ "outer" + name ].call( this, size );

is erroneously triggering this condition in jQuery 1.8.2:

var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),

because even though size is undefined, the check is for arguments.length. chainable should be false here. You can pass in undefined and it will still make arguments an object with length 1. Someone needs to read up on their JS ;)

3

There are 3 answers

1
Andy Ray On BEST ANSWER

A simple solution seems to be just passing in false

$(document.body).outerWidth(false);

Or, true if you want the margins, but if you were passing in true it looks like you would not have encountered this bug.

2
Joshua On

I suggest upgrading both your jQuery and jQuery UI packages. 1.8.1 and 1.8.2 in particular address issues related to outerWidth / outerHeight, and jQuery UI of course needs to be kept in sync.

See the changelogs on the announcements for reference:

http://blog.jquery.com/

http://blog.jqueryui.com/

3
warrickh On

Looks like it is jqueryUI issue. Seems to be fixed in 1.8.22.

With jquery UI 1.8.21: http://jsfiddle.net/yVq5H/13/

With jquery UI 1.8.22 (fixed): http://jsfiddle.net/yVq5H/14/