Sha256: 78366cbb582d5acb062b0a701e874ee52f5bb16f227808fd9ae3dbfa834de453

Contents?: true

Size: 1.33 KB

Versions: 26

Compression:

Stored size: 1.33 KB

Contents

import '../../utils/click/isClickableInput.js';
import '../../utils/dataTransfer/Clipboard.js';
import { isContentEditable } from '../../utils/edit/isContentEditable.js';
import '../../utils/edit/isEditable.js';
import '../../utils/edit/maxLength.js';
import { hasOwnSelection } from '../../utils/focus/selection.js';
import '../../utils/keyDef/readNextDescriptor.js';
import '../../utils/misc/level.js';
import '../../options.js';
import { setSelection } from './setSelection.js';

/**
 * Backward-compatible selection.
 *
 * Handles input elements and contenteditable if it only contains a single text node.
 */ function setSelectionRange(element, anchorOffset, focusOffset) {
    var _element_firstChild;
    if (hasOwnSelection(element)) {
        return setSelection({
            focusNode: element,
            anchorOffset,
            focusOffset
        });
    }
    /* istanbul ignore else */ if (isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
        return setSelection({
            focusNode: element.firstChild,
            anchorOffset,
            focusOffset
        });
    }
    /* istanbul ignore next */ throw new Error('Not implemented. The result of this interaction is unreliable.');
}

export { setSelectionRange };

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/event/selection/setSelectionRange.js
clapton-0.0.5 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/setSelectionRange.js
clapton-0.0.4 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/setSelectionRange.js
clapton-0.0.3 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/setSelectionRange.js
clapton-0.0.2 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/setSelectionRange.js
clapton-0.0.1 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/setSelectionRange.js