Skip to content

Commit 378441c

Browse files
fix(rdom): further fix __updateValueAttrib()
- also skip cursor pos update for readonly elements - fix textarea handling
1 parent cc5a86d commit 378441c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/rdom/src/dom.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ const __setAttrib = (el: Element, id: string, val: any, attribs: any) => {
409409

410410
/** @internal */
411411
const __updateValueAttrib = (el: HTMLInputElement, value: any) => {
412-
// let ev;
413-
switch (el.type) {
412+
const type = el instanceof HTMLTextAreaElement ? "text" : el.type;
413+
switch (type) {
414414
case "text":
415415
case "textarea":
416416
case "password":
@@ -422,7 +422,8 @@ const __updateValueAttrib = (el: HTMLInputElement, value: any) => {
422422
const start = el.selectionStart;
423423
const end = el.selectionEnd;
424424
el.value = value;
425-
!el.disabled && el.setSelectionRange(start, end);
425+
!(el.disabled || el.readOnly) &&
426+
el.setSelectionRange(start, end);
426427
break;
427428
}
428429
default:

0 commit comments

Comments
 (0)