Parcourir la source

Add directionality fallback

Refer to the element's direction when run in non-browser contexts.
master
TheoryOfNekomata il y a 1 an
Parent
révision
8e94d6057a
1 fichiers modifiés avec 8 ajouts et 7 suppressions
  1. +8
    -7
      src/index.ts

+ 8
- 7
src/index.ts Voir le fichier

@@ -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
),
);
}



Chargement…
Annuler
Enregistrer