MCPcopy Create free account
hub / github.com/ampproject/amphtml / getScrollingElement

Function getScrollingElement

ads/inabox/position-observer.js:148–165  ·  view source on GitHub ↗

* @param {!Window} win * @return {!Element}

(win)

Source from the content-addressed store, hash-verified

146 * @return {!Element}
147 */
148function getScrollingElement(win) {
149 const doc = win.document;
150 if (doc./*OK*/ scrollingElement) {
151 return doc./*OK*/ scrollingElement;
152 }
153 if (
154 doc.body &&
155 // Due to https://bugs.webkit.org/show_bug.cgi?id=106133, WebKit
156 // browsers have to use `body` and NOT `documentElement` for
157 // scrolling purposes. This has mostly being resolved via
158 // `scrollingElement` property, but this branch is still necessary
159 // for backward compatibility purposes.
160 isWebKit(win.navigator.userAgent)
161 ) {
162 return doc.body;
163 }
164 return doc.documentElement;
165}
166
167/**
168 * Whether the current browser is based on the WebKit engine.

Callers 1

constructorMethod · 0.70

Calls 1

isWebKitFunction · 0.70

Tested by

no test coverage detected