-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Data guidelines for Web IDL iterable, setlike and maplike declarations #6367
Comments
This seems somewhat related to the mixins problem (#472). Like mixins, I think we ought to show the complete API, not the abstraction. IDL is a nice notation for specifying APIs, but it's the actual names an API exposes that web developers want to know about. If some iterable implements an That said, the name If we were to do this, we'd need to add the data guideline and open an issue to bring existing features into compliance. |
I agree it's similar to mixins in the sense that a single thing in Web IDL can expand to multiple things for web developers. Listing all of these things separately ensures we're not losing information, but https://developer.mozilla.org/en-US/docs/Web/API/StylePropertyMapReadOnly#Browser_compatibility really is quite noisy, it's hard to spot which things aren't there for iteration. Also notable is that you can't easily tell what kinds of values you'd iterate. I don't have a concrete proposal here, but is there some kind of grouping of entries and/or collapsing of the presentation that would make this more usable to readers? |
Yeah, it would be good to group the data. One option might be to use that interface as a feature itself, in a structure like this:
This approach presents some complications. We don't have a lot of abstract features like Another approach might be to prefix such names (e.g., Maybe there are other options—I'm not sure. |
Right! To clarify, I meant that we don't have many of the abstract features in BCD. Abstract features are definitely widespread, especially if we count mixins and CSS types, and the like. The list of applicable cases is really helpful. Thank you! Mapping to IDL in the schema more explicitly is an interesting idea too. Hmm. Gotta think on this some more. (If anyone else is consuming BCD and lurking on this issue, I'd like to hear your take on these suggestions!) |
I think in the case of iterables, we can define an abstract feature MDN docs will have to mention that a class is iterable and also define what it means in more details. This isn't the job of the compat table. Also, I think the compat story of all iterable features (for..of, entries, values, @@iterator, ...) will be the same, so the break down into the specific features is not needed and only means more data to review/maintain. If a browser doesn't implement a sub aspect of the iterable concept, we can mark the abstract BCD feature So far I don't think data consumers have requested that we list all methods of a class specifically and if we're consistent with an abstract feature |
I tried to find a counterexample to this, where something implied by Such cases might exist, but judging by this search it's not going to be something we run into a lot. Dealing with exceptions using |
Proposal for a data guideline: IterablesIn WebIDL, APIs can be declared iterable resulting in For example, the {
"api": {
"NodeList": {
"__compat": {},
"iterable": {
"__compat": {
"description": "Iterable (<code>@@iterator</code>)",
"support": {}
}
}
}
}
} Does this make sense? |
This seems reasonable to me. I think we might want to expand the description a little (perhaps mentioning A bigger question: would we want one entry for each for iterable, async iterable, setlike, and maplike? Or would we want to have one guideline with a table breaking down what we expect to be exposed for each? |
That makes sense for iterable! I suspect things will get trickier if we throw maplike and setlike into the mix, since the things they generate overlap. Any suggestions for how to deal with those at the same time? :) |
I think before preceding, you should ask @chrisdavidmills to weigh in on how this would be rendered on MDN pages. If I want to know if something supports |
This does sound a bit esoteric for inclusion in BCD tables to me, but I'll wait for @Elchi3 to chime in on this when he is back in work next week. It is nice to include for completion, but should we have such values just listed in with all the other BCD entries? |
Oh okay, that sounds complex and the compat story for the individual features is then depended on what was implemented first?
Not yet, I think looking at some real world examples would help to come up with ideas.
As discussed above, the alternative is to add all sub features of these concepts to BCD and as MDN pages, but that seems like a lot of work and I'm not sure it is worth it to have pages for |
I had a similar thought.
I'd rather think of this as a concession to a problem without an easy or obvious answer. Platform features should be described without recourse to implementation details whenever possible. On pages where it appears, I would suggest that it have a description that lists what it resolves to in addition to an explanation page. What I'm proposing is no different from having the same description in a property page as on the property list on the interface page. (I had a look at Chrome's IDL just now. It's only about a dozen pages.) By the way, where did |
I whole-heartily agree to these principles and I try to stick to them when possible, as you say.
This is from the ECMAScript symbol. ECMAScript also has builtin iterables. When APIs have them, IDL annotates them with If web devs want to make own iterators for objects, they use Symbol.iterator. I'm not sure how people generally refer to these symbols. I thought I think the BCD
|
WebIDL also defines another keyword, There is also the Related info on MDN Web Docs meta-guide: |
@teoli2003 the reason that you'll see both |
A consistent representation for iterables (and async iterables) would also help TypeScript's DOM types. We want to add the appropriate methods (like At the moment, we use the support data of the |
@MattiasBuelens For async iterables I suppose the feature name should be |
@foolip Yes, AFAIK there are only two async iterables in the platform at the moment: At the time of writing, there are no browsers that support async iterating over a Async iterating over a (Off-topic: the MDN docs for |
@MattiasBuelens I've sent foolip/mdn-bcd-collector#2349 to generate the correct tests. With that, we should be able to add that |
FYI, I added an entry to note that
Note, I much prefer the form of the original description in the first post by @foolip - something like:
Why? Those symbols are opaque spec language. Meaningless to me, even after reading through the MDN JavaScript docs several times. Feels like we're making life harder for developers to no value. |
@Elchi3 Was your comment in #6367 (comment) agreed as the data guideline? I ran into this again in #18964.
Both the docs and BCD expand this out with subfeatures for: entries(), forEach(), item(), keys(), values(). FWIW I think ...
|
What about adding two spec URL links:
|
Good lateral thinking. That would be better here. But I still need to know the agreed pattern for the data guideline. |
Further thinking, the suggested data guideline was to add How do we reach a consensus? |
The |
The async_iterable case is being discussed in #19094. I have come around to the idea that we should document the actual methods/properties added by the symbol in IDL - because our existing data guideline is add features for all methods/properties of the interface whether or not there is a compatibility issue! So the only discussion then is how you indicate support for |
Web IDL has some higher-level declarations that result in multiple things being exposed on an interface, and it would be great to have some data guidelines for how to represent these.
They are:
iterable<value_type>
anditerable<key_type, value_type>
result in@@iterator
,entries
,keys
,values
andforEach
being exposedasync iterable<value_type>
andasync iterable<key_type, value_type>
result in@@asyncIterator
and some other things being exposed.maplike<key_type, value_type>
results in@@iterator
,forEach
,size
,entries
,keys
,values
,get
,has
,clear
,delete
andset
being exposedsetlike<type>
results in@@iterator
,forEach
,size
,entries
,keys
,values
,has
,clear
,delete
andset
being exposedApologies for inevitable mistakes in the above list.
There's already some inconsistency in how such things are represented in BCD. Here, as a "Support of
for...of
" entry:browser-compat-data/api/FormData.json
Lines 102 to 104 in 1ca3bd9
And here, as the
@@iterator
symbol and other entries:browser-compat-data/api/StylePropertyMapReadOnly.json
Lines 434 to 436 in 1ca3bd9
What should we do?
Opinion: As a reader of the StylePropertyMapReadOnly compat table it's not super useful to know that
@@iterator
is individually supported, it's more useful to know whetherfor (const [prop, val] of stylePropertyMap) { ... }
will work. Knowing thatentries
could be more useful, however. Perhaps there should be a grouping of entries to reduce clutter?The text was updated successfully, but these errors were encountered: