Repository: puppeteer/puppeteer
File: packages/puppeteer-core/src/api/locators/locators.ts (TypeScript)

Code before:
              }
            }

            if (el.isContentEditable) {
              return 'contenteditable';
            }

            return 'unknown';
          }),
        )
          .pipe(
            mergeMap(inputType => {
              switch (inputType) {
                case 'select':
                  return from(handle.select(value).then(noop));
                case 'contenteditable':
                case 'typeable-input':
                case 'other-input':
                  return from(handle.focus()).pipe(
                    mergeMap(() => {
                      return from(
                        handle.evaluate((input, newValue) => {
                          const element = input as HTMLElement;
                          const currentValue = element.isContentEditable
                            ? element.innerText
                            : (element as HTMLInputElement).value;
                          if (currentValue === newValue) {
                            return;
                          }
                          if (element.isContentEditable) {
                            element.innerText = newValue;
                          } else {
                            (element as HTMLInputElement).value = newValue;
                          }
                          element.dispatchEvent(
                            new Event('input', {bubbles: true}),
                          );
                          element.dispatchEvent(
                            new Event('change', {bubbles: true}),
                          );
                        }, value),
                      );
                    }),
                  );
                case 'unknown':
                  throw new Error(`Element cannot be filled out.`);
              }
            }),
          )
          .pipe(
            catchError(err => {

Review comment (suggestion):
I believe we still want this logic for short inputs to simulate typing and handle typing with pre-filled prefixes

Code after:
                  'textarea',
                  'text',
                  'url',
                  'tel',
                  'search',
                  'password',
                  'number',
                  'email',
                ]).has(el.type)
              ) {
                return 'typeable-input';
              } else {
                return 'other-input';
              }
            }

            if (el.isContentEditable) {
              return 'contenteditable';
            }

            return 'unknown';
          }),
        )
          .pipe(
            mergeMap(inputType => {
              const fillDirectly = (): Observable<void> => {
                return from(handle.focus()).pipe(
                  mergeMap(() => {
                    return from(
                      handle.evaluate((input, newValue) => {
                        const element = input as HTMLElement;
                        const currentValue = element.isContentEditable
                          ? element.innerText
                          : (element as HTMLInputElement).value;
                        if (currentValue === newValue) {
                          return;
                        }
                        if (element.isContentEditable) {
                          element.innerText = newValue;
                        } else {
                          (element as HTMLInputElement).value = newValue;
                        }
                        element.dispatchEvent(
                          new Event('input', {bubbles: true}),
                        );
                        element.dispatchEvent(
                          new Event('change', {bubbles: true}),
                        );
                      }, value),
                    );
                  }),