Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Regression: width() & height() return 0 for all inline elements #3571
Comments
|
Ugh, it's hard to believe we didn't have a single unit test for that... I've created a milestone for 3.2.1, this seems serious enough that we'd want a quick patch release before 3.3.0. |
mgol
added this to the 3.2.1 milestone
Mar 16, 2017
mgol
added
Blocker
Bug
CSS
labels
Mar 16, 2017
|
Caused by #3561. |
|
Not having style specified via stylesheet or inline is not enough to trigger the issue; the element has to have a computed The underlying issue is that |
|
From the spec
The Whether |
mgol
referenced this issue
Mar 17, 2017
Closed
Dimensions: ignore transforms when retrieving width/height #3561
mgol
changed the title from
Regression: width() only works when explicitly set
to
Regression: width() & height() return 0 for all inline elements
Mar 17, 2017
|
I'm not sure what we can do to fix this issue and still keep #3193 (i.e. not take transforms into account while computing width/height) & #1724 (support for subpixel values for width/height) fixed. This issue proves Choose your poison. :/ |
mgol
referenced this issue
Mar 17, 2017
Closed
different result of width() and height() since jQuery 3.0 #3193
|
@mgol Yeah, the problem is that the semantic purpose behind
These will have the same effective width, unless inline-block or block is applied to the span. So it is true that inline elements don't have a width other than 'auto'. On the other side, there is the use case of "visual size", which semantically maps to The problem is that until transforms came along, there wasn't really any way the visual size could be different from the size behind the scenes. The missing concept here is "internally drawn size". As for transforms, I'm not convinced that it's obvious that that they shouldn't be taken into account. I can imagine plenty of use cases where users may've used |
|
@Krinkle you're right As for what we can do in 3.2.1, anything we do to fix this issue will break something a previous version promised to fix; at this point I think we should just revert Timmy's PR as that will break the thing that we fixed most recently so few people will be relying on that at this point. The real solution will have to wait for 4.0. |
craigkovatch
commented
Mar 17, 2017
I agree, but I wonder if a caller-specified parameter (i.e. shouldIncludeTransforms or some such) would be the easier and more flexible path? |
HolgerJeromin
commented
Mar 17, 2017
The whole api is designed as read: .width() and write: .width(newValue) |
|
@craigkovatch @HolgerJeromin Right, but even if we added another method (or signature or whatever) to support adding transforms, there's still this issue of how to support getting width with no transforms correctly. I wonder if falling back to |
craigkovatch
commented
Mar 17, 2017
•
|
@timmywil I agree. Better to be missing a fraction of a pixel than be unexpectedly transformed by some scaling factor. Perhaps it would be good to reach out to W3C/Webkit/Mozilla and ask for a proper API. jQuery isn't the only library that will want to have a correct answer to this question. |
timmywil
referenced this issue
Mar 17, 2017
Closed
Test for dimensions intermittently aborts early in Chrome #3570
added a commit
to timmywil/jquery
that referenced
this issue
Mar 18, 2017
timmywil
referenced this issue
Mar 18, 2017
Closed
Dimensions: fall back to offsetWidth/Height for inline elems #3577
timmywil
added
the
Has Pull Request
label
Mar 18, 2017
added a commit
to timmywil/jquery
that referenced
this issue
Mar 18, 2017
added a commit
to timmywil/jquery
that referenced
this issue
Mar 18, 2017
mohithg
commented
Mar 19, 2017
•
|
My app relies on width() and height() on inline-elements and updating to 3.2 broke my app too. When is patch going to release? |
added a commit
to timmywil/jquery
that referenced
this issue
Mar 20, 2017
timmywil
closed this
in
473d2ea
Mar 20, 2017
Krinkle
referenced this issue
Mar 20, 2017
Closed
jquery-migrate "effects: jQuery.easing" test failing #3583
|
@mohithg The fixed version is available now: https://blog.jquery.com/2017/03/20/jquery-3-2-1-now-available/ |
mohithg
commented
Mar 21, 2017
|
@mgol Thanks. |
added a commit
to stevenbenner/jquery-powertip
that referenced
this issue
Mar 27, 2017
Krinkle
referenced this issue
Apr 1, 2017
Closed
Regression: Inline width returns 0 on Android 4 #3602
|
The fix didn't work for Android 4. Could re-open, but filed #3602 instead. |
Krinkle
referenced this issue
Apr 5, 2017
Closed
3.1.x -> 3.2.x contains breaking change (`outerWidth` behavior) #3611
Camzilla
commented
Dec 15, 2017
|
@mgol surprisingly ran into this problem today when replacing a table with flex. Items in my rows have "flex: 0 0 value%" and are showing up as '0' width for .height() .innerHeight() and also .outerHeight(). I got jQuery 3.2.1 in my project, is flex accounted for? |
|
@Camzilla This seems unrelated to this issue. Could you open a new one with a test case? |
Krinkle commentedMar 16, 2017
•
Edited 1 time
-
Krinkle
Mar 16, 2017
Description
Select any element on the page that doesn't have an explicit width set via a stylesheet or inline attribute and call
.width().In jQuery 1.x, 3.0.x and 3.1.1 this returns the computed width.
As of jQuery 3.2.0 it returns
0. This is breaking various downstream test suites for Wikimedia and is blocking our upgrade for now.Link to test case
http://codepen.io/Krinkle/pen/RpjgpR