Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#11515 closed bug (patchwelcome)

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

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


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/

Change History (3)

comment:1 Changed 11 years ago by sindresorhus

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...

comment:3 Changed 9 years ago by anonymous

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

Note: See TracTickets for help on using tickets.