瀏覽代碼

Add directionality fallback

Refer to the element's direction when run in non-browser contexts.
master
TheoryOfNekomata 1 年之前
父節點
當前提交
8e94d6057a
共有 1 個文件被更改,包括 8 次插入7 次删除
  1. +8
    -7
      src/index.ts

+ 8
- 7
src/index.ts 查看文件

@@ -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…
取消
儲存