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.26 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/utility/clear.js