Bug 212372
| Summary: | Element.offsetParent of fixed position element under transformed element should not be null | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Federico Zivolo <federico.zivolo> |
| Component: | DOM | Assignee: | fantasai <fantasai.bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | ahmad.saleem792, annevk, ap, bfulgham, browserbugs2, davide.cavarretta, fantasai.bugs, mrobinson, rniwa, simon.fraser, webkit-bug-importer, zalan |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 13 | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=161788 | ||
| Bug Depends on: | |||
| Bug Blocks: | 289743 | ||
Federico Zivolo
Reported by federico.zivolo@gmail.com in https://bugs.chromium.org/p/chromium/issues/detail?id=20574#c67.
For the following test case:
<!DOCTYPE html>
<div id="transformed" style="transform: translateX(2px); height: 50px;">
<div id="fixed" style="position: fixed">FIXED</div>
</div>
<div id="output" style="height: 3000px"></div>
<script>
output.textContent = fixed.offsetParent ? fixed.offsetParent.id : "null";
</script>
Chrome: null
Firefox: transformed
Firefox's behavior is more reasonable because "transformed" is the container of "fixed".
This issue is somewhat related to https://bugs.webkit.org/show_bug.cgi?id=37839
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/63739636>
Gérard Talbot (no longer involved)
"
The offsetParent attribute must return the result of running these steps:
If any of the following holds true return null and terminate this algorithm:
(...)
The element’s computed value of the position property is fixed.
"
https://www.w3.org/TR/cssom-view/#dom-htmlelement-offsetparent
Simon Fraser (smfr)
(In reply to Gérard Talbot from comment #2)
> "
> The offsetParent attribute must return the result of running these steps:
>
> If any of the following holds true return null and terminate this
> algorithm:
>
> (...)
>
> The element’s computed value of the position property is fixed.
> "
>
> https://www.w3.org/TR/cssom-view/#dom-htmlelement-offsetparent
But that probably hasn't been updated since we made certain CSS properties trigger containing block for fixed position (like transforms and filters).
The real question here is whether the 'offsetParent' algorithm should follow containing blocks.
Related: bug 161788
Ahmad Saleem
I am still able to reproduce this in Safari 15.6 on macOS 12.5 using test case from Comment 0 changed into below JSFiddle:
Link - https://jsfiddle.net/ewhjmx3a/show
In case of Safari 15.6 and Chrome Canary 106, the output is "FIXED" & "null" on test case while for Firefox Nightly 104, it is "FIXED" & "transformed" aligned with Comment 0.
I am not clear on web-spec but I think it should be something which needs to be clarified and all browsers should be on consensus. Just wanted to share updated results. Thanks!
fantasai
This has been clarified in the spec at https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
fantasai
Pull request: https://github.com/WebKit/WebKit/pull/50834
EWS
Committed 300097@main (6cd7aec93667): <https://commits.webkit.org/300097@main>
Reviewed commits have been landed. Closing PR #50834 and removing active labels.
EWS
Committed 297297.443@safari-7622-branch (ec961398d781): <https://commits.webkit.org/297297.443@safari-7622-branch>
Reviewed commits have been landed. Closing PR #3673 and removing active labels.