Ticket #11086 (closed bug: invalid)
.outerWidth() returns an incorrect value when used on a jQuery UI button element with a label that contains a space.
| Reported by: | selosindis@… | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | dimensions | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This issue involves both jQuery Core and jQuery UI, yet I'm not sure which is causing the problem.
I'm using the latest version of Chrome.
I'm trying to build a button container that is sized perfectly to match the contained buttons. To do this, I'm using .outerWidth(), which works perfectly most of the time. However, as soon as I add a button with a label containing a space, .outerWidth() reports an incorrect value. Replacing a space with the html entity ( ) also works properly.
Example 1
var $button = $("<button />");
$button.html("Foo").button().outerWidth(); Works, returns 128.
Example 2
var $button = $("<button />");
$button.html("Foo Bar").button().outerWidth(); Fails, returns 81, is actually 128.
Example 3
var $button = $("<button />");
$button.html("Foo Bar").button().outerWidth(); Works, Returns 128.
Change History
comment:2 Changed 17 months ago by sindresorhus
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from new to closed
- Component changed from unfiled to dimensions
There's probably some other factors in your code causing a problem. Closing this for now. Feel free to reopen this if you can reproduce it in a simplified jsfiddle testcase.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I just realized that, in my above examples, I failed to show $button being appended to the document (and they were not in jsFiddle). However, the issue is not presenting itself in jsFiddle, so perhaps there is an additional factor that I have overlooked.
http://jsfiddle.net/F7p8L/2/