According to the CSSOM View Module standard, calling document.scrollingElement should work as follows (https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface):
The scrollingElement attribute, on getting, must run these steps:
If the Document is in quirks mode, follow these substeps:
If the HTML body element exists, and it is not potentially scrollable, return the HTML body element and abort these steps.
Return null and abort these steps.
If there is a root element, return the root element and abort these steps.
However, calling document.scrollElement on a document that is *not* in quirks mode returns the HTML body element, rather than the root element. I believe that this is incorrect.
The standard adds the following note:
> Note: For non-conforming user agents that always use the quirks mode behavior for scrollTop and scrollLeft, the scrollingElement attribute is expected to also always return the HTML body element (or null if it does not exist).
It looks like this might apply to Safari. In that case, I believe Safari should become a conforming user agent.
That looks like a duplicate of bug 182053. However, CSSOM View behavior was only enabled 3 days ago (bug 189472). I invite you to test future version of Safari Tech Preview and check whether it behaves as you expect.
You are right, it is a duplicate. I noticed that it was fixed in a recent version of Safari. Thanks!
*** This bug has been marked as a duplicate of bug 182053 ***