puppeteer/docs
Joe Gomain Hoyes bef1061c06
feat(puppeteer-core): Infer element type from complex selector (#9253)
**What kind of change does this PR introduce?**

Better type inference.

**Did you add tests for your changes?**

~Not yet.~ Yes.

**If relevant, did you update the documentation?**

Not yet.

**Summary**

<!-- Explain the **motivation** for making this change. What existing
problem does the pull request solve? -->
<!-- Try to link to an open issue for more information. -->
Currently methods that return an element handle, i.e. `.$`,
`.waitForSelector` attempt to infer the node element type from the
selector string. However, this only works when the selector is an exact
match of the element tag, i.e. a selector `"a"` would be inferred as
`HTMLAnchorElement` . And not when the selector is complex, i.e.
selectors `"a#some-id"`, `div > a`, `a:nth-child(2)` would all fallback
on `Element`.

This is due to simply looking up the the selector in
`HTMLElementTagNameMap` and `SVGElementTagNameMap` without any attempt
to parse the selector string.

This PR is an attempt to do so.

**Does this PR introduce a breaking change?**

<!-- If this PR introduces a breaking change, please describe the impact
and a migration path for existing applications. -->
This could break existing incorrect assertions using the `as` keyword.

**Other information**

~This PR introduces a dependency on the `type-fest` package.~

This PR is far from complete (no tests, no docs). Put out early for
feedback and discussion.

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
2022-11-23 10:59:23 +01:00
..
api feat(puppeteer-core): Infer element type from complex selector (#9253) 2022-11-23 10:59:23 +01:00
assets chore: rename image assets 2020-06-02 15:24:25 +02:00
guides docs: remove unsupported debugging method (#9182) 2022-10-28 11:04:05 +02:00
chromium-support.md chore: release main (#9184) 2022-11-02 10:54:37 +01:00
contributing.md chore: update contributing (#9202) 2022-11-03 11:08:36 +01:00
faq.md docs: improve docs (#9179) 2022-10-28 08:49:28 +02:00
index.md docs: improve docs (#9179) 2022-10-28 08:49:28 +02:00
troubleshooting.md docs: improve docs (#9179) 2022-10-28 08:49:28 +02:00