(elem: Element)
| 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 | } |
no test coverage detected