( recalculate: boolean = false, ownerDocument: Document = document )
| 13 | // and then verify that the subsequent "scroll" event matches the negative offset. |
| 14 | // If it does not match, then we can assume a non-standard RTL scroll implementation. |
| 15 | export function getRTLOffsetType( |
| 16 | recalculate: boolean = false, |
| 17 | ownerDocument: Document = document |
| 18 | ): RTLOffsetType { |
| 19 | let cachedRTLResult = cache.get(ownerDocument); |
| 20 | if (cachedRTLResult === undefined || recalculate) { |
| 21 | const outerDiv = ownerDocument.createElement("div"); |
| 22 | const outerStyle = outerDiv.style; |
| 23 | outerStyle.width = "50px"; |
| 24 | outerStyle.height = "50px"; |
| 25 | outerStyle.overflow = "scroll"; |
| 26 | outerStyle.direction = "rtl"; |
| 27 | |
| 28 | const innerDiv = ownerDocument.createElement("div"); |
| 29 | const innerStyle = innerDiv.style; |
| 30 | innerStyle.width = "100px"; |
| 31 | innerStyle.height = "100px"; |
| 32 | |
| 33 | outerDiv.appendChild(innerDiv); |
| 34 | |
| 35 | ownerDocument.body.appendChild(outerDiv); |
| 36 | |
| 37 | if (outerDiv.scrollLeft > 0) { |
| 38 | cachedRTLResult = "positive-descending"; |
| 39 | } else { |
| 40 | outerDiv.scrollLeft = 1; |
| 41 | if (outerDiv.scrollLeft === 0) { |
| 42 | cachedRTLResult = "negative"; |
| 43 | } else { |
| 44 | cachedRTLResult = "positive-ascending"; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | ownerDocument.body.removeChild(outerDiv); |
| 49 | |
| 50 | cache.set(ownerDocument, cachedRTLResult); |
| 51 | } |
| 52 | |
| 53 | return cachedRTLResult; |
| 54 | } |
no outgoing calls
no test coverage detected