mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 09:34:02 +00:00
Co-authored-by: Mikael Finstad <finstaden@gmail.com> Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com> Co-authored-by: Murderlon <merlijn@soverin.net> Co-authored-by: Artur Paikin <artur@arturpaikin.com>
19 lines
783 B
TypeScript
19 lines
783 B
TypeScript
/**
|
|
* Get the declared text direction for an element.
|
|
*/
|
|
|
|
function getTextDirection(element?: HTMLElement): string | undefined {
|
|
// There is another way to determine text direction using getComputedStyle(), as done here:
|
|
// https://github.com/pencil-js/text-direction/blob/2a235ce95089b3185acec3b51313cbba921b3811/text-direction.js
|
|
//
|
|
// We do not use that approach because we are interested specifically in the _declared_ text direction.
|
|
// If no text direction is declared, we have to provide our own explicit text direction so our
|
|
// bidirectional CSS style sheets work.
|
|
while (element && !element.dir) {
|
|
// eslint-disable-next-line no-param-reassign
|
|
element = element.parentNode as HTMLElement
|
|
}
|
|
return element?.dir
|
|
}
|
|
|
|
export default getTextDirection
|