Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResizeObserver not present on the Window interface #1683

Open
guillaumebrunerie opened this issue Feb 3, 2024 · 1 comment
Open

ResizeObserver not present on the Window interface #1683

guillaumebrunerie opened this issue Feb 3, 2024 · 1 comment

Comments

@guillaumebrunerie
Copy link

The ResizeObserver class is only available as a global declaration and not on the Window interface. I think it should also be available on the Window interface for at least two reasons:

  • The specification (https://drafts.csswg.org/resize-observer/#idl-index) says [Exposed=(Window)], which I’m guessing means that it is supposed to be on the Window interface (I’m actually surprised, isn’t the specification supposed to be automatically translated to Typescript declarations?)
  • For applications with several windows, it behaves differently depending on the window from which it is taken (see https://codepen.io/Latcarf/pen/RwdyLXr?editors=0010). So it would make a lot of sense to be able to do the following, which currently doesn’t typecheck as popup is of type Window.
const popup = window.open(...)!;
new popup.ResizeObserver(...);
@turansky
Copy link

turansky commented Feb 12, 2024

says [Exposed=(Window)]

Window in this case is environment name, like DedicatedWorker or SecureContext (no such interfaces)

Also:

  1. Global ResizeObserver is fine
  2. There is no support for nested interfaces/types in TS
  3. It could't be implemented without duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants