Skip to main content

Bug Tracker

Side navigation

#11086 closed bug (invalid)

Opened December 21, 2011 02:01AM UTC

Closed December 21, 2011 10:19AM UTC

.outerWidth() returns an incorrect value when used on a jQuery UI button element with a label that contains a space.

Reported by: selosindis@gmail.com Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
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.

Attachments (0)
Change History (2)

Changed December 21, 2011 02:13AM UTC by anonymous comment:1

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/

Changed December 21, 2011 10:19AM UTC by sindresorhus comment:2

component: unfileddimensions
priority: undecidedlow
resolution: → invalid
status: newclosed

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.