Bug 204195

Summary: offsetParent is wrong if the offset parent is inside some shadow DOM
Product: WebKit Reporter: Pascal Spadone <pascal.spadone>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: emilio, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: Mac   
OS: macOS 10.15   
Bug Depends on:    
Bug Blocks: 148695    
Attachments:
Description Flags
Plunker that reproduces the issue none

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.