-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Reconsider the width/height css hooks CSS swap behavior #5628
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
Comments
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 13, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
1 task
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 13, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
PR: #5630 |
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 13, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 18, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. 2. Fix measurements of `<col span="2">` elements in Firefox. 3. Avoid swapping CSS before dimensions computation in all browsers. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Don't try to show elements hidden via `display: none` before measuring their width or height. The styles we used to apply included `position: absolute` which could influence the styles anyway, so this was never reliable. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Fix measurements of `<col span="2">` elements in Firefox. 2. Fix measurements of all implicitly sized `<col>` elements in Safari. Firefox always reports computed width as if `span` was 1. In Safari, computed width for columns is always 0. Work around both issues by using `offsetWidth`. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
1 task
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Fix measurements of `<col span="2">` elements in Firefox. 2. Fix measurements of all implicitly sized `<col>` elements in Safari. Firefox always reports computed width as if `span` was 1. In Safari, computed width for columns is always 0. Work around both issues by using `offsetWidth`. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628
mgol
added a commit
to mgol/jquery
that referenced
this issue
Feb 24, 2025
Changes: 1. Fix measurements of `<col span="2">` elements in Firefox. 2. Fix measurements of all implicitly sized `<col>` elements in Safari. Firefox always reports computed width as if `span` was 1. In Safari, computed width for columns is always 0. Work around both issues by using `offsetWidth`. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes jquerygh-5628 CSS: Support dimensions for implicitly sized hidden elements again
1 task
mgol
added a commit
that referenced
this issue
Feb 24, 2025
Changes: 1. Fix measurements of `<col span="2">` elements in Firefox. 2. Fix measurements of all implicitly sized `<col>` elements in Safari. Firefox always reports computed width as if `span` was 1. In Safari, computed width for columns is always 0. Work around both issues by using `offsetWidth`. In IE/Edge, `<col>` computed width is `"auto"` unless `width` is set explicitly via CSS so measurements there remain incorrect. Because of the lack of a proper workaround, we accept this limitation. Fixes gh-5628 Closes gh-5634 Ref gh-5630
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Summary
We have
width
&height
CSS hooks. Theget
one:jquery/src/css.js
Lines 316 to 335 in 667321e
checks for
display
to benone
or to start withtable-
with some exceptions and then it applies some temporary styles:jquery/src/css.js
Line 27 in 667321e
before measuring the size.
The
display: none
caseNow, removing this swap doesn't make any test fail in Firefox or Chrome and only one, related to table columns, in Safari. We don't test the
display: none
case. I've been wondering if that one makes any sense. Even just applyingposition: absolute
may affect the element styles beyond what we'd see if we just gave it a temporarydisplay: block
. There's no way to always properly measure hidden elements. Can we get rid of this one in 4.0?Table columns
As for table columns, the support comment states:
Modern versions of Safari or Chrome do not match what the comment says. I noticed different cross-browser issues, though. For a column with
span="2"
(denoted asc
) that is sized implicitly by the size of its cells, I got the following values in an example table:c.offsetWidth
c.getBoundingClientRect().width
getComputedStyle(c).width
Some conclusions:
getBoundingClientRect
.offsetWidth
- the comment stated that one was 0 as well.getComputedStyle(c).width
only reports the size of the first column over which thecol
element spans.col
element has an explicitwidth
set via CSS then IE starts reporting it instead of"auto"
. However, ourcssShow
styles have no effect on reported values.Proposal
It seems in Chrome we could report
getComputedStyle(c).width
as we'd normally do, but Safari & Firefox needoffsetWidth
for different reasons; perhaps we need a new support test. ThegetBoundingClientRect
examples were provided just for comparison but we cannot use them as they're affected by transforms.Either way, swapping styles doesn't seem necessary. I'm not sure if we can do anything for IE here either, but we're not doing it at the moment.
Incidentally, this is our last usage of the
swap
util, previously exposed asjQuery.swap
.Link to test case
https://output.jsbin.com/pebovey
The text was updated successfully, but these errors were encountered: