TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

[Web API type definition issue] `Element.requestFullscreen` should be optional

Open hyunbinseo opened this issue 1 month ago • 8 comments

Summary

typeof document.documentElement.requestFullscreen is undefined in iOS Safari

Expected vs. Actual Behavior

typeof document.documentElement.requestFullscreen

Expected: not defined in iOS 26.0.1 Safari (and probably in the webview) Actual: always a function

Playground Link

No response

Browser Support

  • [x] This API is supported in at least two major browser engines (not two Chromium-based browsers).

Have Tried The Latest Releases

  • [x] This issue applies to the latest release of TypeScript.
  • [x] This issue applies to the latest release of @types/web.

Additional Context

Suggested change will enforce optional chaining for safer runtime code.

document.documentElement.requestFullscreen?.()

hyunbinseo avatar Oct 29 '25 15:10 hyunbinseo

It's only undefined because Safari doesn't implement it yet: https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen

We don't generally make everything potentially undefined because one browser is lagging behind. If two engines have the feature, then we include the type.

jakebailey avatar Oct 29 '25 15:10 jakebailey

I do understand that iOS Safari is the only one lagging behind, but is Apple even willing to implement it?

I would love to know a way to config it as optional — I wasn't doing QA with iPhones, and I've had to fix mistakes in bulk with a string search.

hyunbinseo avatar Oct 29 '25 16:10 hyunbinseo

What version of iOS Safari are we talking about? Per the WebKit IDL it should be available everywhere. 🤔

saschanaz avatar Nov 05 '25 01:11 saschanaz

@saschanaz all versions of iOS Safari including the latest 26.

Personal test results:

[email protected]: undefined [email protected]: function

Image

https://caniuse.com/fullscreen

Only available on iPad, not on iPhone. Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.

https://github.com/mdn/browser-compat-data/blob/88673dfeb94aa588d96baf90dbc8742538d78d12/api/Element.json#L4805-L4813

hyunbinseo avatar Nov 05 '25 04:11 hyunbinseo

The source of truth is the WebKit source code, everything else is an observed result. 🤔

saschanaz avatar Nov 05 '25 06:11 saschanaz

I guess iOS doesn't have webkitRequestFullScreen either?

saschanaz avatar Nov 05 '25 06:11 saschanaz

fwiw, you can use https://mdn-bcd-collector.gooborg.com/ (the same thing that MDN uses to gather the data)

saschanaz avatar Nov 05 '25 06:11 saschanaz

These are the tests I've ran. Is there a webkit prefixed version that I am supposed to run?

api.Element.requestFullscreen
api.Element.requestFullscreen.returns_promise
Image

hyunbinseo avatar Nov 08 '25 05:11 hyunbinseo