-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Fixes #14545. In-body STYLE element returns nonzero dimensions #1445
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
Conversation
// See http://bugs.jquery.com/ticket/14545 | ||
if (elemNodeName === "script" || elemNodeName === "style") { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces → tabs
This needs unit tests. Also, I'd personally prefer to see any code change in the height/width getter itself (e.g., to skip swap for reserved elements) instead of |
This looks good to me now. @gibson042 ? |
// In HTML5, it is now valid to have style tags outside the head tag. | ||
// See http://bugs.jquery.com/ticket/14545 | ||
var elemNodeName = elem.nodeName.toLowerCase(); | ||
if (elemNodeName === "script" || elemNodeName === "style") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For nodeName
comparisons we generally use jQuery.nodeName
method, since it devised specially for this kind of cases. And it should not give big performance overhead.
Also if
requires spaces, same goes for function calls in assertions you added.
I'm not strongly oppose to this, but why exactly we want to do this? For any hidden element it would return it width/height but not for Plus we didn't have these problems before, although Only thing that change is that html5 spec has eased constraints for |
I'm inclined to agree with @markelog... if
|
But it turns out that we missed that block for |
You guys made your case, I'm good with leaving this as a docs issue. Sprinkling |
I am the original submitter, and I'm sorry for not following up until now. While I don't disagree with leaving this as a docs issue (and an easy worked-around with CSS |
Seems that |
Just FYI: that approach to finding available space has more nuances than manually excluding |
@dmethvin I wouldn't say that. Just because browsers can't figure out how to implement it, doesn't mean it's being phased out, as it is not being considered for deprecation by the W3C, AFAIK. Also, for the sake of tidying up, this is a half-duplicate of http://bugs.jquery.com/ticket/10159 and the documentation fix for .width() and .height() has a typo: |
At least Google currently thinks this feature is not worth the effort with Web Components coming so it might disappear from the standard one day. |
Reported by bggardner
This also occurs with script elements
See http://bugs.jquery.com/ticket/14545