Elizabeth Mitchell c390291687 chore: format files with prettier
PiperOrigin-RevId: 576601342
2023-10-25 11:59:00 -07:00

21 lines
623 B
TypeScript

/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Returns `true` if the given element is in a right-to-left direction.
*
* @param el Element to determine direction from
* @param shouldCheck Optional. If `false`, return `false` without checking
* direction. Determining the direction of `el` is somewhat expensive, so
* this parameter can be used as a conditional guard. Defaults to `true`.
*/
export function isRtl(el: HTMLElement, shouldCheck = true) {
return (
shouldCheck &&
getComputedStyle(el).getPropertyValue('direction').trim() === 'rtl'
);
}