Sha256: b68ac45a9f523738cdc997a2013b5ca7b7658fd842cf8dc74c07c16db6db4ab5

Contents?: true

Size: 1.31 KB

Versions: 26

Compression:

Stored size: 1.31 KB

Contents

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/click/isClickableInput.js';
import '../utils/dataTransfer/Clipboard.js';
import { isEditable } from '../utils/edit/isEditable.js';
import '../utils/edit/maxLength.js';
import { isDisabled } from '../utils/misc/isDisabled.js';
import '../utils/keyDef/readNextDescriptor.js';
import '../utils/misc/level.js';
import '../options.js';
import { focusElement } from '../event/focus.js';
import { input } from '../event/input.js';
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';

async function clear(element) {
    if (!isEditable(element) || isDisabled(element)) {
        throw new Error('clear()` is only supported on editable elements.');
    }
    focusElement(element);
    if (element.ownerDocument.activeElement !== element) {
        throw new Error('The element to be cleared could not be focused.');
    }
    selectAll(element);
    if (!isAllSelected(element)) {
        throw new Error('The element content to be cleared could not be selected.');
    }
    input(this, element, '', 'deleteContentBackward');
}

export { clear };

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.6 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.5 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.4 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.3 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.2 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.1 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js