Bug 212372 - Element.offsetParent of fixed position element under transformed element should not be null
Summary: Element.offsetParent of fixed position element under transformed element shou...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 13
Hardware: All All
: P2 Normal
Assignee: Martin Robinson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-05-26 06:18 PDT by Federico Zivolo
Modified: 2023-10-07 15:51 PDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Federico Zivolo 2020-05-26 06:18:29 PDT
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
Comment 1 Radar WebKit Bug Importer 2020-05-28 17:33:12 PDT
<rdar://problem/63739636>
Comment 2 Gérard Talbot 2022-02-28 07:21:49 PST
"
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
Comment 3 Simon Fraser (smfr) 2022-02-28 15:55:11 PST
(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
Comment 4 Ahmad Saleem 2022-07-27 03:51:24 PDT
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!