Sha256: 55ffb47768b9b077e786c44fdb4a6f96734d2e591f3489808336667a7604711c
Contents?: true
Size: 1.91 KB
Versions: 26
Compression:
Stored size: 1.91 KB
Contents
import { dispatchDOMEvent } from '../event/dispatchEvent.js'; import '../utils/click/isClickableInput.js'; import '../utils/dataTransfer/Clipboard.js'; import '../utils/edit/isEditable.js'; import '../utils/edit/maxLength.js'; import { isElementType } from '../utils/misc/isElementType.js'; import '../utils/keyDef/readNextDescriptor.js'; import '../utils/misc/level.js'; import '../options.js'; import { getInitialValue, clearInitialValue } from './UI.js'; import '@testing-library/dom'; import { prepareValueInterceptor, prepareSelectionInterceptor, prepareRangeTextInterceptor } from './interceptor.js'; const isPrepared = Symbol('Node prepared with document state workarounds'); function prepareDocument(document) { if (document[isPrepared]) { return; } document.addEventListener('focus', (e)=>{ const el = e.target; prepareElement(el); }, { capture: true, passive: true }); // Our test environment defaults to `document.body` as `activeElement`. // In other environments this might be `null` when preparing. // istanbul ignore else if (document.activeElement) { prepareElement(document.activeElement); } document.addEventListener('blur', (e)=>{ const el = e.target; const initialValue = getInitialValue(el); if (initialValue !== undefined) { if (el.value !== initialValue) { dispatchDOMEvent(el, 'change'); } clearInitialValue(el); } }, { capture: true, passive: true }); document[isPrepared] = isPrepared; } function prepareElement(el) { if (el[isPrepared]) { return; } if (isElementType(el, [ 'input', 'textarea' ])) { prepareValueInterceptor(el); prepareSelectionInterceptor(el); prepareRangeTextInterceptor(el); } el[isPrepared] = isPrepared; } export { prepareDocument };
Version data entries
26 entries across 26 versions & 1 rubygems