MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / getOverflowState

Function getOverflowState

javascript/atoms/typescript/is-displayed.ts:244–366  ·  view source on GitHub ↗
(elem: Element)

Source from the content-addressed store, hash-verified

242 }
243
244 function getOverflowState(elem: Element): OverflowState {
245 var region = getClientRegion(elem);
246 var ownerDoc = elem.ownerDocument;
247 var htmlElem = ownerDoc.documentElement;
248 var bodyElem = ownerDoc.body;
249 var htmlOverflowStyle = getEffectiveStyle(htmlElem, 'overflow') || 'visible';
250 var treatAsFixedPosition = false;
251
252 function canBeOverflowed(container: Element, position: string | null): boolean {
253 if (container === htmlElem) {
254 return true;
255 }
256
257 var display = getEffectiveStyle(container, 'display') || '';
258 if (display.indexOf('inline') === 0 || display === 'contents') {
259 return false;
260 }
261
262 if (position === 'absolute' && getEffectiveStyle(container, 'position') === 'static') {
263 return false;
264 }
265
266 return true;
267 }
268
269 function getOverflowParent(current: Element): Element | null {
270 var position = getEffectiveStyle(current, 'position');
271 if (position === 'fixed') {
272 treatAsFixedPosition = true;
273 return current === htmlElem ? null : htmlElem;
274 }
275
276 var parent = getParentElement(current);
277 while (parent && !canBeOverflowed(parent, position)) {
278 parent = getParentElement(parent);
279 }
280 return parent;
281 }
282
283 function getOverflowStyles(current: Element): OverflowStyles {
284 var overflowElem = current;
285 if (htmlOverflowStyle === 'visible') {
286 if (current === htmlElem && bodyElem) {
287 overflowElem = bodyElem;
288 } else if (current === bodyElem) {
289 return { x: 'visible', y: 'visible' };
290 }
291 }
292
293 var overflow = {
294 x: getEffectiveStyle(overflowElem, 'overflow-x') || 'visible',
295 y: getEffectiveStyle(overflowElem, 'overflow-y') || 'visible',
296 };
297
298 if (current === htmlElem) {
299 overflow.x = overflow.x === 'visible' ? 'auto' : overflow.x;
300 overflow.y = overflow.y === 'visible' ? 'auto' : overflow.y;
301 }

Callers 1

hiddenByOverflowFunction · 0.85

Calls 6

getClientRegionFunction · 0.85
getEffectiveStyleFunction · 0.85
getOverflowParentFunction · 0.70
getOverflowStylesFunction · 0.70
getClientRectFunction · 0.70
getScrollFunction · 0.70

Tested by

no test coverage detected