#10413 closed bug (fixed)
width, innerWidth, innerHeight, outerWidth, outerHeight are inaccurate for a "box-sizing: border-box" child of hidden parent
Reported by: | mikesherov | Owned by: | mikesherov |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | css | Version: | 1.6.4 |
Keywords: | 1.8-discuss | Cc: | |
Blocked by: | Blocking: | #7986 |
Description (last modified by )
This is very similar to #9441, except this is specifically when a child (that has the box-sizing:border-box style) of a hidden div is queried.
Basically, the fallback (that uses the css width/height instead of the javascript offsetWidth/Height to calculate dimensions) is applied, and assumes that the css width doesn't contain padding and border. However, when box-sizing is border-box, the css width is the same as offsetWidth/Height, in that it accounts for padding and border.
The fix is simple, apply the same logic that is applied to offsetWidth/Height to the fallback version if boxSizing is border box.
Change History (23)
comment:1 Changed 11 years ago by
Component: | unfiled → css |
---|---|
Owner: | set to mikesherov |
Priority: | undecided → low |
Status: | new → pending |
comment:4 Changed 11 years ago by
Status: | pending → new |
---|
Yea, I kind of agree.
It would be a lot less code if there was already generic vendor prefix detection built into jQuery I could leverage. As far as I can tell, it's not there yet. However, that's not for me to decide when/if jQuery chooses to do that. It's a bit ironic it isn't there yet as one of the things that made me first choose jQuery was its ability to normalize cross-browser behavior.
Maybe I'll redo this bug if/when vendor prefix detection is there for me to leverage.
comment:5 Changed 11 years ago by
Status: | new → open |
---|
Yeah but a lot of people also started using jQuery because it was small ... we've got several conflicting goals at work here. If you have some idea how the reusable vendor-prefixing code might look (and how to keep it small) we'd be interested in hearing about it. We'll be starting the call for 1.8 features soon.
comment:6 Changed 11 years ago by
@dmethvin, don't get me wrong. Not complaining, just reflecting. I understand the whole feature creep argument, especially with a public API. Once you commit to supporting something, it's really hard to cut it later or change your mind (jquery 1.6 and Boolean attributes come to mind). Also, I agree with your code bloat argument.
The box-model stuff is a pain, but for me it's a good pain... increased flexibility in the box model means less calls for jQuery to support something like ability to set outerWidth() values.
api.jquery.com/jQuery.csshooks has a good start for vendor prefixing. Thanks for tipping me off to the feature nomination. I'll be voting for vendor prefix support in 1.8!
comment:7 Changed 11 years ago by
@dmethvin, I went ahead and updated my pull request to include generic vendor prefixing. I tried my best to keep the functionality as small as possible. https://github.com/jquery/jquery/pull/528
comment:8 Changed 11 years ago by
Keywords: | 1.8-discuss added |
---|---|
Status: | open → assigned |
comment:9 Changed 11 years ago by
Blocking: | 7986 added |
---|
comment:12 Changed 11 years ago by
Description: | modified (diff) |
---|
Why is the PR closed? Will it be reopened?
comment:15 Changed 11 years ago by
Description: | modified (diff) |
---|
+1, Good thing I voted up on #10679 then.
comment:16 Changed 11 years ago by
-1, I don't think we should be concerned with box-sizing in dimensions. padding/border/margin are still determined manually as always.
comment:17 Changed 11 years ago by
timmywil, it's reporting the WRONG values as per the documentation. .width says it always returns content width regardless of box-sizing. This bug is about that not being true if it's a box-sizing:border-box child.
comment:18 Changed 11 years ago by
OK, if it's the wrong value, it is a bug worth fixing. I see the point about animation as well, but .width() should continue to retrieve width regardless of box-sizing.
comment:20 Changed 11 years ago by
Milestone: | None → 1.8 |
---|
comment:22 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:23 Changed 11 years ago by
Fix #10413, #10679. Fix box-sizing:border-box and add css vendor prefix support.
Changeset: 5376a809c0d2bee4b7872847c2821e458dfdcc3b
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.