Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Dir #19

Open
HamzaAmar opened this issue May 4, 2023 · 1 comment
Open

Nested Dir #19

HamzaAmar opened this issue May 4, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@HamzaAmar
Copy link

const isRtl = window.getComputedStyle(document.documentElement).direction === 'rtl'

I think is better to make isRtl a function that accepts an element parameter, you can get the computed style of that particular element instead of assuming that the root element is always the relevant one but if the element is omitted we can use document.documentElement as a fallback.

Here's an example implementation of isRtl() as a function that accepts an element parameter and returns true if the element's computed direction style is "rtl" (right-to-left), and false otherwise

function isRtl(element = document.documentElement) {
  const computedStyle = window.getComputedStyle(element);
  const direction = computedStyle.getPropertyValue('direction');
  return direction === 'rtl';
}
@argyleink argyleink added the enhancement New feature or request label May 4, 2023
@argyleink
Copy link
Owner

great idea 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants