Bug Tracker

Opened 11 years ago

Closed 11 years ago

#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: [email protected] 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&nbsp;Bar").button().outerWidth(); Works, Returns 128.

Change History (2)

comment:1 Changed 11 years ago by anonymous

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/

comment:2 Changed 11 years ago by sindresorhus

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.

Note: See TracTickets for help on using tickets.