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

Missing definition for getElementsByTagName('time') for 'Element' #8450

Open
agrawal-d opened this issue Jul 31, 2020 · 2 comments
Open

Missing definition for getElementsByTagName('time') for 'Element' #8450

agrawal-d opened this issue Jul 31, 2020 · 2 comments
Labels
Library definitions Issues or pull requests about core library definitions

Comments

@agrawal-d
Copy link

Missing/Incorrect APIs

The library definition in dom.js for getElementsByTagName('time') for Element is currently missing, so Flow falls back to getElementsByClassName(names: string): HTMLCollection<HTMLElement>;.

It would be good to have a specific definition of time elements:

getElementsByTagName(name: 'time'):HTMLCollection<HTMLTimeElement>;

Relevant documentation

  1. https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
  2. https://developer.mozilla.org/en/docs/Web/HTML/Element/time
@agrawal-d agrawal-d added the Library definitions Issues or pull requests about core library definitions label Jul 31, 2020
@gnprice
Copy link
Contributor

gnprice commented Aug 4, 2020

Note this contrasts with Document, which does have the corresponding definition. From dom.js, here's a snippet of the Document definition:

  getElementsByTagName(name: 'textarea'): HTMLCollection<HTMLTextAreaElement>;
  getElementsByTagName(name: 'time'): HTMLCollection<HTMLTimeElement>;
  getElementsByTagName(name: 'title'): HTMLCollection<HTMLTitleElement>;
  getElementsByTagName(name: 'track'): HTMLCollection<HTMLTrackElement>;
  getElementsByTagName(name: 'video'): HTMLCollection<HTMLVideoElement>;

but here's the corresponding snippet from Element:

  getElementsByTagName(name: 'textarea'): HTMLCollection<HTMLTextAreaElement>;
  getElementsByTagName(name: 'video'): HTMLCollection<HTMLVideoElement>;

As those snippets suggest, track is also missing on Element. (And title is there but the order is different.) Here's a quick scan of definitions that are present on just one of the two, just for getElementsByTagName:

$ grep 'getElementsByTagName\b' lib/dom.js | sort | uniq -u
  getElementsByTagName(name: 'area'): HTMLCollection<HTMLAreaElement>;
  getElementsByTagName(name: 'blockquote'): HTMLCollection<HTMLQuoteElement>;
  getElementsByTagName(name: 'body'): HTMLCollection<HTMLBodyElement>;
  getElementsByTagName(name: 'datalist'): HTMLCollection<HTMLDataElement>;
  getElementsByTagName(name: 'datalist'): HTMLCollection<HTMLDataListElement>;
  getElementsByTagName(name: 'embed'): HTMLCollection<HTMLEmbedElement>;
  getElementsByTagName(name: 'html'): HTMLCollection<HTMLHtmlElement>;
  getElementsByTagName(name: 'map'): HTMLCollection<HTMLMapElement>;
  getElementsByTagName(name: 'q'): HTMLCollection<HTMLQuoteElement>;
  getElementsByTagName(name: 'time'): HTMLCollection<HTMLTimeElement>;
  getElementsByTagName(name: 'track'): HTMLCollection<HTMLTrackElement>;

I suspect all of those should be present on both. (And datalist should probably have a consistent type.) There may be other parts of the Document and Element definitions which would also benefit from a sync-up, too.

@Brianzchen
Copy link
Contributor

Instead of repeating them, is there an easy way to define a base type that can be spread onto a class declaration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library definitions Issues or pull requests about core library definitions
Projects
None yet
Development

No branches or pull requests

3 participants