Skip to main content

Bug Tracker

Side navigation

#11515 closed bug (patchwelcome)

Opened March 26, 2012 09:05AM UTC

Closed March 27, 2012 11:16AM UTC

Last modified December 04, 2013 02:04PM UTC

.width() and .height() returns 0 for SVG text element in FF and IE

Reported by: Edvard.Erlansson@qlikview.com Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

The jQuery functions width() and height() returns 0 for SVG text elements in Firefox 11 and IE 9. In both Chrome 17 and 19 they work as expected.

element.getBoundingClientRect() returns the expected values in all of the browsers tested.

Here is a simple test page: http://jsfiddle.net/ckGcJ/31/

Attachments (0)
Change History (3)

Changed March 27, 2012 11:16AM UTC by sindresorhus comment:1

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

This is because Firefox and presumably IE 9 doesn't expose offsetWidth/offsetHeight on SVGTextElement, which the dimensions methods uses.

The problem with using getBoundingClientRect() is that Chrome and Firefox returns different numbers. I have no idea which one is correct. Do you?

This means there is no reliable way of getting the dimensions, that I know of.

I suggest you file a issue on the Firefox and IE bug trackers about the offsetWidth.

Closing this as patchwelcome (ref http://docs.jquery.com/Won%27t_Fix), though I don't see any way to fix this at the moment. Firefox is on quick release cycle, so that *could* be fixed pretty fast, IE9 however...

Changed May 15, 2012 06:48PM UTC by thuerrschmidt@gmail.com comment:2

Changed December 04, 2013 02:04PM UTC by anonymous comment:3

The continuation of this issue on Mozilla's side can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=874811