fix(field): getter/setter for selectionStart/End instead of delegation
This commit is contained in:
parent
88f52646b8
commit
07eddb38c3
1 changed files with 31 additions and 7 deletions
|
|
@ -47,13 +47,7 @@ export class LionField extends FormControlMixin(
|
|||
return {
|
||||
...super.delegations,
|
||||
target: () => this.inputElement,
|
||||
properties: [
|
||||
...super.delegations.properties,
|
||||
'name',
|
||||
'type',
|
||||
'selectionStart',
|
||||
'selectionEnd',
|
||||
],
|
||||
properties: [...super.delegations.properties, 'name', 'type'],
|
||||
attributes: [...super.delegations.attributes, 'name', 'type'],
|
||||
};
|
||||
}
|
||||
|
|
@ -67,6 +61,36 @@ export class LionField extends FormControlMixin(
|
|||
};
|
||||
}
|
||||
|
||||
get selectionStart() {
|
||||
const native = this.inputElement;
|
||||
if (native && native.selectionStart) {
|
||||
return native.selectionStart;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
set selectionStart(value) {
|
||||
const native = this.inputElement;
|
||||
if (native && native.selectionStart) {
|
||||
native.selectionStart = value;
|
||||
}
|
||||
}
|
||||
|
||||
get selectionEnd() {
|
||||
const native = this.inputElement;
|
||||
if (native && native.selectionEnd) {
|
||||
return native.selectionEnd;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
set selectionEnd(value) {
|
||||
const native = this.inputElement;
|
||||
if (native && native.selectionEnd) {
|
||||
native.selectionEnd = value;
|
||||
}
|
||||
}
|
||||
|
||||
// We don't delegate, because we want to preserve caret position via _setValueAndPreserveCaret
|
||||
set value(value) {
|
||||
// if not yet connected to dom can't change the value
|
||||
|
|
|
|||
Loading…
Reference in a new issue