New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
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 |
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 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. |
I agree, but I wonder if a caller-specified parameter (i.e. shouldIncludeTransforms or some such) would be the easier and more flexible path? |
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 |
@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. |
- Also added some more general dims tests for inline elements for posterity Fixes jquerygh-3571
- Also added some more general dims tests for inline elements for posterity Fixes jquerygh-3571
- Also added some more general dims tests for inline elements for posterity Fixes jquerygh-3571
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? |
@mohithg The fixed version is available now: https://blog.jquery.com/2017/03/20/jquery-3-2-1-now-available/ |
@mgol Thanks. |
Important note: jQuery version 3.2.0 had a bug where the value returned by `.width()` and `.height()` was always zero for inline elements. This leads to unusual tooltip positioning. For this reason, PowerTip cannot support jQuery 3.2.0. Ref: jquery/jquery#3571 Ref: 23cc0d0
The fix didn't work for Android 4. Could re-open, but filed #3602 instead. |
@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? |
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
The text was updated successfully, but these errors were encountered: