Browse Source

Add directionality fallback

Refer to the element's direction when run in non-browser contexts.
master
TheoryOfNekomata 1 year ago
parent
commit
8e94d6057a
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      src/index.ts

+ 8
- 7
src/index.ts View File

@@ -666,16 +666,17 @@ const getInputTextualFieldValue = (
inputEl: HTMLInputTextualElement,
options = {} as GetInputTextualFieldValueOptions,
) => {
if (
options.includeDirectionality
&& typeof window !== 'undefined'
&& typeof window.getComputedStyle === 'function'
&& typeof (inputEl.dirName as unknown) === 'string'
) {
if (options.includeDirectionality) {
return new TextualValueString(
inputEl.value,
inputEl.dirName,
window.getComputedStyle(inputEl).direction || 'ltr',
(
typeof window !== 'undefined'
&& typeof window.getComputedStyle === 'function'
&& typeof (inputEl.dirName as unknown) === 'string'
? window.getComputedStyle(inputEl).direction || 'ltr'
: inputEl.dir
),
);
}



Loading…
Cancel
Save