-
Notifications
You must be signed in to change notification settings - Fork 2k
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
How to represent 'mixins'? #472
Comments
I propose to hide mixins from the BCD. We put the method and the compat data directly in the interfaces that implements the mixins. This has 1 drawback, MDN needs to do some magic to show a summary table on a mixin page as it needs to know which interfaces implement the given mixin. It has this information in the {{InterfaceData}} macro (see https://github.com/mdn/kumascript/blob/master/macros/InterfaceData.json ). We likely will need a new macro for these pages. |
This is an important issue for Window and the *GlobalScope interfaces. (As well as a few others like AudioContext and AudioWorklet) |
I think I agree to hide mixins. But what does this mean in practice? Taking the example of https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob Not using mixins: This would be two different compat data entries (in different files). This looks closer to what web developers see.
Using mixins: As there is different compat data for different contexts, you would probably end up with sub features. This has the benefit that all data for "atob" is together in one tree or one file.
On MDN: The rendered table on https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob should somehow display the compat info for both contexts. We'll need to see how we could do this when not using mixins. (it seems easier with what we can do now if we would use mixins in the compat data, too). Aside: Imo the MDN page is not very good. It mostly only gives a code example in the window context. I think we need to get better there. Generally "WindowOrWorkerGlobalScope" is invisible to web developers and rather cryptic (on MDN and in BCD). All we want to say somehow is that this is for windows and workers... |
About the aside: yes, I agree with this. This comes from the fact that it wasn't a mixin, then it became one and we did the change without rewriting the page. Note that we have cases where a method was in a mixin, then outside a mixin (mixin removed); or in a mixin, then in another, then back on the interface while the mixin was kept for this method and used for 2 other interfaces (!). On MDN: if we use mixin, we likely need to create a specific macro that looks at {{InterfaceData}} to know which interface use the mixin, to find the correct compat info for the compat table. |
Ok, I think the plan could be:
@Elchi3, what do you think? |
Sounds good to me, thanks for working on this. Good to see data migrated into the proper repository. |
I wish I'd seen this conversation sooner, since I disagree. I think we need a way to have a unified place for the mixin information in the data store so we don't have to update this stuff in multiple places like we do if we include the implemented mixin methods and properties within each individual interface. Then a bit of pipe dream thinking: On MDN, we then create the pages for the mixin but we don't show them directly (that is, they're not linked on overview pages, and they might even be noindex). Instead, they get automatically injected or transcluded within the hierarchy of pages under each interface, with the appropriate names subbed in. This would require some macro and/or platform work, though. But from a user data maintenance standpoint, it would be much better, and from a UX standpoint on MDN, it would be amazing. |
In fact, a mixin is not necessarily implemented at the same time in each interface. So it means that we can not have a unique BCD value for a mixin: it needs to be at the interface level. As a mixin is not user-facing, we also have renaming and removal of mixins happening all the time in the specs. It is an editorial thing at the spec level. There is no way, and no concrete use, to keep track of these renamings or removals as it has 0 consequences, and is invisible, for web developers. And having dealt (more or less successfully) with the URL interface, it can be a nightmare for writers: lots of work for no actual benefits for the reader. Let's avoid this problem. So I feel strongly in favour of the rule: no mixin listed separately in BCD. |
My only remaining question or concern on this, then, is what if anything we want to do about making sure people can understand why these things are missing if they look at the WebIDL for an interface that's based in part on a mixin. |
I would like to point out that it can be confusing not to specify where a sub-feature comes from. For example, I recently edited the HashChangeEvent article. Before, it had listed If we would not mix and list mixin separately, we could add If we do mix, we should maybe make it clear in the description where the feature comes from, e.g.: the sub-feature |
When poking around in https://github.com/foolip/mdn-bcd-updater, I've found that the use of mixins in the BCD model results in some strange situation. As @teoli2003 points out things may not be implemented at the same time on the different interfaces that include a mixin and it didn't take long before I stumbled on a real such case: Prefixed variants of this API have existed for a very long time on Document, but the unprefixed ones will be available on Document and ShadowRoot. This can't be easily represented as it is. The issue of base classes came up in #3368 (comment) and this is information that could be extracted from Web IDL. Similarly, information about mixins could be extracted. I'd be happy to write some scripts for it if that would help move this discussion along. |
For reference, usings scrips in https://github.com/foolip/mdn-bcd-updater and That's with mixins and partial interfaces applied on the IDL side. Much of the lists are explained by BCD using mixins for some things and some things not. With some script tweaking I made IDL with mixins but no BCD and that list is a bit shorter, but it has stuff like NavigatorID.vendor because that particular mixin has been flattened into Navigator in BCD. One could mostly work around the problems, but I think this will be an impediment to improving the data quality. I see some similarities to #3463, in that one could try to represent the mixins in the data model and do something in the presentation similar to what one could for members of parent interfaces. @Elchi3 who has to make a decision on this? Whatever is decided, how would one roll out a change that either deletes a lot of mixins or adds a lot of mixins? |
MDN is inconsistent and BCD followed these inconsistencies to not block on data migration. Sometimes we document mixins that specs invented or sometimes people used the mixins the browser vendors invented for convenience. All this changes at different times in specs and browsers as new conveniences are needed.
My understanding is that for web developers they are an implementation detail (almost always I think). That said, I'm leaning towards not having them exposed to web developers here or on MDN, but I would like to do some research to make a better call. Ideally, we want a tool that accepts WebIDL and spits out MDN URLs and BCD paths to create with rules coded in there. So, if we decide one rule (of many rules likely) is that mixis are bad and we flatten them, the tool takes that into account and presents a structure for MDN and BCD from a given WebIDL snippet. Only this way we create reliable structures and not random structures a contributor to MDN web docs decided to use and BCD then inherits from.
This is on point, so I agree we need to solve this.
The MDN content team lead by @chrisdavidmills as I think I would like to follow what MDN decides. BCD and MDN docs both want to expose useful information about web apis to web developers, so I don't want to make a call for BCD alone. Making the changes is likely a lot of work, but if we have a reliable ruleset agreed on (this is the hard part), we can see how to address this and audit BCD and MDN against these rules and then piece by piece get things sorted. (BCD is easier as it is in git and as we have tooling to lint etc). |
@Elchi3 not representing mixins in the BCD model at all sounds good to me and I'd be happy to work in that direction. These are the 69 mixins that exist in specs (from reffy-reports) today:AbstractWorker Of those it looks like 21 of those are in BCD:
Assuming that pages like NonDocumentTypeChildNode will have to be updated either not include compat tables at all or point to Element + CharacterData, here's a transition plan I think could work:
|
WindowOrWorkerGlobalScope is a good example where attention to notes will be needed. One note says "fetch() now defined on WindowOrWorkerGlobalScope mixin" which probably means That's also a bit of special case in that it would split window or worker-exposed APIs across Window and the multiple *WorkerGlobalScope interfaces. It probably makes more sense for web developers to visit https://developer.mozilla.org/en-US/docs/Web/API/fetch (now redirects) and see the support in various contexts in a single table. |
@Elchi3 any thoughts on how you'd like to deal with the list in #472 (comment)? |
So, here are my thoughts on this:
The
I do feel that we should add to mixins listed in the With this information in hand, we can easily update our compatibility table generator to include the data for the mixins as appropriate, such as by including all of the contents of each of them in the table generated for the Then we have to look at where we put the documents themselves. For the sake of cohesiveness, I think they should be maintained separately, perhaps just like they are now. Using automatic inclusion of the content into TOCs and indices should do a good job of integrating the content into the inheriting interfaces. If it's a problem that we the lack the ability to use breadcrumbs to back up into the parent, or the fact that the mixin would not know how to refer to itself based on the parent that the user clicked into it from, there ought to be a technical solution to it. For instance, we could have the macros that build these lists add a parameter to the links that lets the target page know which interface it's being looked at as part of. Then we'd just need a way to have a variable of sorts on the page that would sub in that information when presenting the contents. Something like that. Not all of this is easy, but it's not tremendously difficult either, and I think we can greatly improve usability for both readers and contributors. We have made vague attempts at this in the past, and I have my in-progress |
@a2sheppy maintaining a list parent interfaces and mixins should be quite straightforward as it can be derived directly from the Web IDL in reffy-reports. I tweaked a script to generate it here: The Navigator section looks a lot like you suggested. However, as you say, readers probably don't care about mixins. It seems to me there are some challenges in maintaining compat data for mixins and then flattening that into the real interfaces in the support tables that people see/use. How should one deal with the cases where the support status on the real interfaces aren't the same? As I mentioned in #472 (comment) this does happen, most of the members in https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot#Browser_compatibility are like this. It will also be the case for many APIs in https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope#Browser_compatibility which predate worker support in browsers. |
@saschanaz what do you think the rule (or lint) for the support statement on M should be? I see two options, with different drawbacks:
|
In TSJS perspective I prefer the first option, as it will use the mixin if there is any real implementation. It could be painful for large mixins like GlobalEventHandlers but I guess it should generally be fine as AFAIK many mixins only have one single concrete implementor interface. |
In #7179 (comment) we discovered that there are mismatches between BCD and MDN, where BCD has an api.HTMLElement.style entry which links to https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style, and that page in turn includes the data from api.HTMLElement.style. Since https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style redirects I gather it was renamed at some point. This sort of thing is bound to come up more when trying to sort everything out. |
Now I think I'm more for removing mixins. That way:
I still can write code for my use case to track mixin items in BCD, so nothing will be lost. |
I just came across something I hadn't seen before and which will also need cleaning up. CharacterData.json has an api.CharacterData.ChildNode entry with the description "Implements the |
ChildNode is a mixin, not an interface as described, and mixins are completely invisible to web developers; they're a spec author convenience. This is a bit of cleanup that makes sense regardless of the outcome of mdn#472 more broadly.
Alright, so there's some interface history with some SVG interfaces that can make this a little bit more complicated. While I was updating data for some mixins, I discovered that a few of the mixins in SVG were initially their own interfaces in SVG 1.1, but then converted to mixins in SVG 2.0. What should we do in this case? |
I filed #7752 for the SVG interfaces which were turned into mixins. I think we should treat the ones which are now mixins like all other mixins, however that ends up being. |
(Sidebar re "Contributors won't be confused": I'm more concerned with whether readers and data consumer are confused. I've always believed it's my job as a documentation person to resolve confusion for myself so that readers, hopefully, never will be. |
I wonder the support table should ultimately support inheritances, in that case the algorithm is needed anyway. |
ChildNode is a mixin, not an interface as described, and mixins are completely invisible to web developers; they're a spec author convenience. This is a bit of cleanup that makes sense regardless of the outcome of #472 more broadly.
I've made a concrete proposal of how to proceed in #8929 |
I've answered how to represent mixins in #9016 A mixin data guideline was released in BCD 3.1.0. 🎉 I'll fix existing data in #8929. Closing here. |
Mixins are bits of API that are defined once and implemented by several interfaces.
E.g. (fictive)
This is used in spec to describe once methods/properties that are implemented by several interfaces.
Mixins are invisible to the users, and different interfaces can implement these methods at different moment, completely and incompletely, and with different bugs or limitations. Mixins are transparent to the user.
Mixins can go away or be added in the spec, without having an impact on the developer using them.
MDN shows mixins only to avoid duplication (or triplication) of articles [and the nightmare of keeping them coherent]. Mixins are blended in the interface they appear like a regular property or method in the sidebar and in the list in the main text.
How to represent them?
The text was updated successfully, but these errors were encountered: