Opened 9 years ago
Closed 9 years ago
#14545 closed bug (wontfix)
In-body style element returns nonzero dimensions
Reported by: | bggardner | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | css | Version: | 1.10.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In HTML5, it is now valid to have style tags outside the head tag. jQuery returns nonzero dimensions (height(), width(), innerHeight(), etc.) for a style element inside of the HTML body tag. In the head tag, the correct (zero) dimensions are returned. JavaScript's clientHeight and clientWidth properties are zero, as expected. Only by setting the style tag's style attribute to "height: 0; width: 0" (or doing so in a stylesheet) will jQuery return zero for the dimension functions.
I have seen this in all jQuery versions available at jsfiddle, using Chrome and Firefox, both on Windows 7 and Ubuntu 13.10.
Example: http://jsfiddle.net/wz4vW/4/
Change History (6)
comment:1 Changed 9 years ago by
Component: | unfiled → css |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:3 Changed 9 years ago by
Pull request at GitHub: https://github.com/jquery/jquery/pull/1445
comment:5 Changed 9 years ago by
Not sure how the reporter noticed it, but I can imagine a scenario like this:
$('#some-id > *').each( ... if ($(this).height() > someValue) { ...
comment:6 Changed 9 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
See the discussion in https://github.com/jquery/jquery/pull/1445, there's a docs ticket.
This is valid. We're using swap here to ensure elements are not hidden when retrieving dimensions, but we can skip it for style elements.