Delegates text selection methods and properties to an inner input-type element


Purpose: Help components built around an inner input element provide .

This mixin makes it easy for you to support the complete set standard DOM APIs for selecting text by delegating those methods to an inner input-type element.

This mixin works near the start of the Elix render pipeline:

events → methods → setState → render DOM → post-render

Expects the component to provide:

  • [internal.inputDelegate] getter that returns an input-compatible element in the component's shadow tree.

Provides the component with:

  • select, selectionEnd, selectionStart, setRangeText, setSelectionRange methods that forward to the delegated input.


import DelegateInputSelectionMixin from "elix/src/base/DelegateInputSelectionMixin.js";
import html from "elix/src/core/html.js";
import internal from "elix/src/base/internal.js";
import ReactiveElement from "elix/src/core/ReactiveElement.js";

class MyElement extends DelegateInputSelectionMixin(ReactiveElement) {
  // Identify the input element that will receive standard selection API calls.
  get [internal.inputDelegate]() {
    return this[internal.ids].input;

  get [internal.template]() {
    return html`
      <input id="input" />


Used by classes AutoCompleteComboBox, ComboBox, DateComboBox, FilterComboBox, ListComboBox, ListWithSearch, NumberSpinBox, PlainAutoCompleteComboBox, PlainComboBox, PlainDateComboBox, PlainFilterComboBox, PlainListComboBox, PlainListWithSearch, PlainNumberSpinBox, PlainSpinBox, and SpinBox.

select() method

Selects all the text.

See the standard select documentation for details.

selectionEnd property

The end index of the selected text.

See the standard input element documentation for details.

selectionStart property

The beginning index of the selected text.

See the standard input element documentation for details.

setRangeText() method

Replaces a range of text.

See the standard setRangeText documentation for details.

setSelectionRange() method

Sets the start and end positions of the current text selection.

See the standard setSelectionRange documentation for details.