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

Code before:
  ): Locator<NodeFor<Selector>>;

  /**
   * Creates a locator for the provided function. See {@link Locator} for
   * details and supported actions.
   *
   * @param selector -
   * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
   * to query the page for.
   * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
   * can be passed as-is and a
   * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
   * allows querying by
   * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
   * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
   * and
   * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
   * and
   * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
   * Alternatively, you can specify the selector type using a
   * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
   */
  locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>;

  /**
   * Creates a locator based on an ElementHandle. This would allow refreshing
   * the element handle if it is stale but it allows re-using other locator
   * pre-conditions.
   */
  locator<T extends Node>(handle: ElementHandle<T>): Locator<T>;
  locator<Selector extends string, Ret, T extends Node>(
    input: Selector | (() => Awaitable<Ret>) | ElementHandle<T>,
  ): Locator<NodeFor<Selector>> | Locator<Ret> | Locator<T> {
    if (typeof input === 'string') {
      return NodeLocator.create(this, input);
    } else if (typeof input === 'function') {
      return FunctionLocator.create(this, input);
    } else {
      return NodeLocator.createFromHandle(this, input);
    }
  }

  /**
   * A shortcut for {@link Locator.race} that does not require static imports.
   *
   * @internal
   */
  locatorRace<Locators extends readonly unknown[] | []>(
    locators: Locators,
  ): Locator<AwaitedLocator<Locators[number]>> {
    return Locator.race(locators);

Review comment (suggestion):
```suggestion
   * Creates a locator based on an ElementHandle. This would not allow refreshing
```

Code after:
  ): Locator<NodeFor<Selector>>;

  /**
   * Creates a locator for the provided function. See {@link Locator} for
   * details and supported actions.
   *
   * @param selector -
   * {@link https://pptr.dev/guides/page-interactions#selectors | selector}
   * to query the page for.
   * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
   * can be passed as-is and a
   * {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
   * allows querying by
   * {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
   * {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
   * and
   * {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
   * and
   * {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
   * Alternatively, you can specify the selector type using a
   * {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
   */
  locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>;

  /**
   * Creates a locator based on an ElementHandle. This would not allow
   * refreshing the element handle if it is stale but it allows re-using other
   * locator pre-conditions.
   */
  locator<T extends Node>(handle: ElementHandle<T>): Locator<T>;
  locator<Selector extends string, Ret, T extends Node>(
    input: Selector | (() => Awaitable<Ret>) | ElementHandle<T>,
  ): Locator<NodeFor<Selector>> | Locator<Ret> | Locator<T> {
    if (typeof input === 'string') {
      return NodeLocator.create(this, input);
    } else if (typeof input === 'function') {
      return FunctionLocator.create(this, input);
    } else {
      return NodeLocator.createFromHandle(this, input);
    }
  }

  /**
   * A shortcut for {@link Locator.race} that does not require static imports.
   *
   * @internal
   */
  locatorRace<Locators extends readonly unknown[] | []>(
    locators: Locators,
  ): Locator<AwaitedLocator<Locators[number]>> {
    return Locator.race(locators);