FIX: Fix detection of a parent transformed element on Firefox #74

Closed
vincentbernat wants to merge 1 commit from fix/position-fixed-firefox144 into main
vincentbernat commented 2025-10-20 18:46:40 +02:00 (Migrated from github.com)

Starting with Firefox 144, offsetParent is now null when an element has position fixed (while previously, it would return <body>). The hack previously used for Firefox is not working anymore and we have to use the same method as for Chromium.

I don't have a reference for the change. The bug on Firefox side is still open but with an activity a few months ago. There are also traces it has been fixed in some subsequent commits.

Starting with Firefox 144, offsetParent is now `null` when an element has position fixed (while previously, it would return `<body>`). The hack previously used for Firefox is not working anymore and we have to use the same method as for Chromium. I don't have a reference for the change. The [bug on Firefox side](https://bugzilla.mozilla.org/show_bug.cgi?id=434678) is still open but with an activity a few months ago. There are also traces it has been fixed in some [subsequent commits](https://github.com/mozilla-firefox/firefox/commit/21c7700929fd7c858fbed884427d6e732e0ab513).
marijnh commented 2025-10-21 10:29:24 +02:00 (Migrated from github.com)

I'm still seeing the old behavior in Firefox 144. This is the test I used.

<div style="transform: translate(50px, 50px)"><div id=fix style="position: fixed; left: 0; right: 0">--</div></div>
<script>console.log(document.querySelector("#fix").offsetParent)</script>
I'm still seeing the old behavior in Firefox 144. This is the test I used. ```html <div style="transform: translate(50px, 50px)"><div id=fix style="position: fixed; left: 0; right: 0">--</div></div> <script>console.log(document.querySelector("#fix").offsetParent)</script> ```
vincentbernat commented 2025-10-21 10:43:19 +02:00 (Migrated from github.com)

I just took a random element on this page:

10:42:31.379 temp0.style.position = "fixed"
10:42:31.410 "fixed"
10:42:40.464 temp0.offsetParent
10:42:40.488 null 
I just took a random element on this page: ``` 10:42:31.379 temp0.style.position = "fixed" 10:42:31.410 "fixed" 10:42:40.464 temp0.offsetParent 10:42:40.488 null ```
marijnh commented 2025-10-21 11:19:19 +02:00 (Migrated from github.com)

That looks like an improvement—null is actually a useful value there. And from what I can see, recent Chrome versions are also behaving like this now. Does attached patch look like it would work for you?

That looks like an improvement—`null` is actually a useful value there. And from what I can see, recent Chrome versions are also behaving like this now. Does attached patch look like it would work for you?
vincentbernat commented 2025-10-21 19:28:17 +02:00 (Migrated from github.com)

Yes, it works fine as well.

Yes, it works fine as well.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/view!74
No description provided.