UNPKG

@testing-library/user-event

Version:
38 lines (35 loc) 1.38 kB
import '../setup/index.js'; import '../utils/click/isClickableInput.js'; import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js'; import '../event/eventMap.js'; import '../event/behavior/click.js'; import '../event/behavior/cut.js'; import '../event/behavior/keydown.js'; import '../event/behavior/keypress.js'; import '../event/behavior/keyup.js'; import '../event/behavior/paste.js'; import '@testing-library/dom'; import '../utils/edit/maxLength.js'; import '../utils/edit/isEditable.js'; import '@testing-library/dom/dist/helpers.js'; import { copySelection } from '../utils/focus/copySelection.js'; import '../utils/keyDef/readNextDescriptor.js'; import '../utils/misc/level.js'; import '../options.js'; import { Config } from '../setup/config.js'; async function cut() { const doc = this[Config].document; var _activeElement; const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body; const clipboardData = copySelection(target); if (clipboardData.items.length === 0) { return; } if (this.dispatchUIEvent(target, 'cut', { clipboardData }) && this[Config].writeToClipboard) { await writeDataTransferToClipboard(target.ownerDocument, clipboardData); } return clipboardData; } export { cut };