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

Consider a more modern interface for CompanionWindows #4

Open
domenic opened this issue Sep 19, 2024 · 0 comments
Open

Consider a more modern interface for CompanionWindows #4

domenic opened this issue Sep 19, 2024 · 0 comments

Comments

@domenic
Copy link

domenic commented Sep 19, 2024

[SecureContext, Exposed=Window]
interface CompanionWindows {
  iterable<CompanionWindow>;
  readonly attribute unsigned long length;
  getter CompanionWindow item(unsigned long index);
  CompanionWindow namedItem(DOMString name);

  Promise<CompanionWindow> open(USVString url, CompanionWindowOpenOptions options = {});
};

This item() / namedItem() style is very old-school API design. Modern APIs generally use something like ObservableArray for indexed access, or maplike<> for named access.

I admit we don't seem to have any modern pattern for both named and indexed access. But is that really important? In particular, I'd be surprised if indexed access was important for many use cases. (And it can be emulated, by maplike.values().drop(i).next().value, if it's really needed. At least once iterator helpers lands.)

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

1 participant