Bug 204195 - offsetParent is wrong if the offset parent is inside some shadow DOM
Summary: offsetParent is wrong if the offset parent is inside some shadow DOM
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 13
Hardware: Mac macOS 10.15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 148695
  Show dependency treegraph
 
Reported: 2019-11-14 04:13 PST by Pascal Spadone
Modified: 2019-11-25 14:26 PST (History)
3 users (show)

See Also:


Attachments
Plunker that reproduces the issue (1.90 KB, application/zip)
2019-11-14 04:13 PST, Pascal Spadone
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Spadone 2019-11-14 04:13:55 PST
Created attachment 383553 [details]
Plunker that reproduces the issue

If the offset parent of an element is part of some shadow DOM, .offsetParent incorrectly returns some node higher up the tree, outside of the shadow DOM. 

The following pluncker (also attached) demonstrates the issue: https://embed.plnkr.co/nxDd9HrA0XiN72WAbZBF/ . In MacOS Safari 13.0.3 as well as iOS 13.1 Safari, the reported .offsetParent is the body instead of the expected relative-positionned div.
Comment 1 Radar WebKit Bug Importer 2019-11-17 16:39:42 PST
<rdar://problem/57268349>
Comment 2 Emilio Cobos Álvarez (:emilio) 2019-11-19 08:03:18 PST
This is expected per https://bugzilla.mozilla.org/show_bug.cgi?id=1514074 / bug 157437 / https://github.com/w3c/csswg-drafts/issues/159, afaict. Firefox behaves the same.
Comment 3 Pascal Spadone 2019-11-20 02:29:45 PST
Fair enough! Makes sense that the DOM API should avoid leaking shadow nodes. I will check the Blink bug tracker and see if it makes sense to open a bug there, then. Apologies for not googling long enough before opening this ticket!
Comment 4 Ryosuke Niwa 2019-11-25 14:25:38 PST
(In reply to Emilio Cobos Álvarez (:emilio) from comment #2)
> This is expected per https://bugzilla.mozilla.org/show_bug.cgi?id=1514074 /
> bug 157437 / https://github.com/w3c/csswg-drafts/issues/159, afaict. Firefox
> behaves the same.

Looks like Blink never implemented the new behavior. Commented on the issue to ping rakina & tkent. Hopefully they can align Blink's behavior.
Comment 5 Ryosuke Niwa 2019-11-25 14:26:06 PST
Closing as invalid because WebKit's current behavior matches the spec & Firefox.