#387: Badging API
Discussions
Comment by @torgo Jun 24, 2019 (See Github)
What is the current implementation status outside of Chromium? The spec only links to a Chromium implementation...
Comment by @torgo Jun 24, 2019 (See Github)
@hober brought up a good point in last week's TAG call that there is a kind of badging that happens in tabs in the background in some webapps that accumulate notification. Is this reflected in any current discussion?
Comment by @fallaciousreasoning Jun 25, 2019 (See Github)
What is the current implementation status outside of Chromium? The spec only links to a Chromium implementation...
There is not currently any implementation outside of Chromium. Is this a requirement for a TAG review? FWIW: Firefox: Worth prototyping Edge: Positive (they also have a similar proprietary API). Safari: No signals Chromium: Origin trial
@hober brought up a good point in last week's TAG call that there is a kind of badging that happens in tabs in the background in some webapps that accumulate notification. Is this reflected in any current discussion?
Do you mean the favicon/<title>
tricks to show some kind of status in the tabstrip? This is discussed a bit in Issue #1.
Or do you mean something more like Android Badging, where a badge is shown if the app has any unread notifications? This is discussed a bit here. There are other arguments for keeping the two separate in the Overview section of the explainer.
Discussed
Jul 3, 2019 (See Github)
Tess: Alice & I met on this. Alice posted our feedback on the issue 3 hours ago. feedback on the issue 3 hours ago.
Alice: ...some more worked through code examples. .. notes in comment... didn't answer is it possible to have different instances one one app... proliferation of libraries... In the navigator issue - issue 14 - I brought it up again...
Tess: Part of what confuses me about that is they are putting off using this from a service worker until the future, but in the wild the common "per-app" case they seem to want to address right now is the add-to-home-screen scenario, where you may reasonably expect there to be a service worker (and it may want to update the bage number when the app isn't active).
Dan: is the feedback being taken on board?
Alice: the navigator feedback yes. I will talk to them about other feedback.
Comment by @alice Jul 3, 2019 (See Github)
I had a chat with @hober and we agreed on several points about this design:
- The explainer has some good detail, but could also do with:
- Some more fleshed out use cases - there are some good general cases, but it would be nice to see more specific examples beyond "unread count".
- Some more worked through code examples - there are some very minimal code examples showing the (minimal) API, but when would that code run?
- A "Considered alternatives" section - this gives us a better idea of what the design process was to create this API
- In particular, was a declarative solution considered?
- We weren't clear on why this proposal only addressed OS-level application badges and not the common pattern of decorating the favicon and/or title to display the same information in a browser tab label.
- Issue #1 does discuss this, but we weren't clear on when the distinction between per-app and per-instance would apply (isn't an installed PWA just a single instance of an app?).
- In particular, we weren't satisfied by the "make a JS library" advice - we are suffering from a proliferation of JS libraries and it seems like virtually every PWA would want to cover both cases since, after all, by definition a PWA must work both in a browsing context and a standalone context.
- In a mobile app scenario, code may not be guaranteed to run unless the user is actively using the app. How does this API fit in to a mobile PWA use case?
- Given that this is ostensibly "per-app", it seems like having the
Badge
object hanging offWindow
might be misleading - it might be better suited toNavigator
orNotifications
.
Discussed
Jul 10, 2019 (See Github)
Tess: I don't think we heard back...
Alice: I had a chat with them about the feedback. they have a PR in their repo to update the explainer. They hagd one change which was to make badge into a namespace. I went through the feedback with them. They had some convincing answers to feedback and they are working those into the explainer - it's in PR state right now. Jay says to wait a week
Comment by @fallaciousreasoning Jul 16, 2019 (See Github)
We're working on integrating this into the explainer, but in the meantime to address some of your specific concerns:
In particular, was a declarative solution considered?
Yes. However, as badges may be shared across multiple documents, it was decided that this could be kind of confusing (e.g. there is a <link rel="shortcut icon badge" href="/favicon.ico" badge="99">
in the head of a document, but it is being badged with 7
because another page was loaded afterwards). There is some discussion of this here and here.
We weren't clear on why this proposal only addressed OS-level application badges and not the common pattern of decorating the favicon and/or title to display the same information in a browser tab label.
@mgiuca, @marcoscaceres and I came up with the following direction forward for having an integrated solution for tabs/app badging.
- All badges have a scope.
- Pages are badged with the most specific badge matching their scope.
- By default
Badge.set(...)
will be scoped to the current origin. - The scope for a badge can be explicitly specified
Badge.set(..., { scope: '/scope/to/badge/' })
. - For installed apps, the badge with the most specific scope which encompasses the app's navigation scope is applied to the the app's OS specific context.
This idea is being discussed (in more detail, and with examples) here. Does this seem like a good approach to you?
In a mobile app scenario, code may not be guaranteed to run unless the user is actively using the app. How does this API fit in to a mobile PWA use case?
In future, we intend the API to be available from the service worker (e.g. when a push notification occurs). However, there are still some details around privacy and security that need to be fleshed out. There is an (admittedly brief) section in the FAQ.
Given that this is ostensibly "per-app", it seems like having the Badge object hanging off Window might be misleading - it might be better suited to Navigator or Notifications.
As above, the API is now more general and not specific to apps. Also, there was a poll and developers seem to prefer APIs being accessible off window.
Discussed
Jul 17, 2019 (See Github)
Tess: We got a big response late last night addressing several of the points we made; haven't yet had a chance to digest the reply enough to respond. It was also in reply to Alice's comments; would love to hear her thoughts.
Dan: Bump it a week?
Comment by @hober Jul 19, 2019 (See Github)
@fallaciousreasoning could you expand on the privacy and security implications of making this API available in service workers?
Comment by @fallaciousreasoning Jul 22, 2019 (See Github)
Sure :) Our main concern at the moment is how to indicate to the user that the service worker is running. With push notifications (and presumably we would want this to be triggerable via some kind of push) we can enforce that a notification is shown, to let the user know the app is doing something in the background.
This is harder with Badging. We can enforce that the notification calls Badge.set(...)
or Badge.clear(...)
but this isn't enough to ensure that there is some user-visible change (and if there is, the change might be subtle enough that the user doesn't notice). For example, the service worker could continually set the badge to 5 (or clear
) and it would not be obvious to the user that it was doing anything at all.
We've got a few approaches we're considering here, including a special type of push for setting the badge which specifies the badge but doesn't let you run javascript (this is what iOS does) but we're not sure how we want to jump here.
Comment by @mgiuca Jul 22, 2019 (See Github)
@fallaciousreasoning and I looked into the spec on this and it seems that the "user-visible change" requirement is underspecified and potentially specific to Chrome. Do other browsers require this too?
Service Workers §7.2 defines this as:
The
userVisibleOnly
member, when set totrue
, indicates that the push subscription will only be used for push messages whose effect is made visible to the user, for example by displaying a Web Notification. [NOTIFICATIONS]
That's all it says. It doesn't give any normative requirements about how the UA should behave when userVisibleOnly
is true
(Chrome apparently forcibly displays a notification if you don't). And Chrome fails the subscription if you don't set userVisibleOnly
to true
(which isn't mentioned in the spec). This is explained here and here.
Do other UAs a) force userVisibleOnly
, and/or b) take some (unspecified) action when userVisibleOnly
is true
?
We can try to work around the problem of push messages requiring a "user-visible action" but it's hard to justify it from a spec perspective if this is a Chrome-only provision.
Discussed
Jul 24, 2019 (See Github)
Alice: suggest we bump...
Dan: agree
Alice: 1 wee
Discussed
Jul 31, 2019 (See Github)
Alice: Checking if they've updated their explainer.
Alice: One of the main sticking points was the difference between badging for a page and badging for an origin. I asked them to give some examples of each. They explicitly want this to be badging for an origin, since it's about badging an installed web application.
Alice: They had a PR...
Alice: reads from something -- (1) and (2) but not (3) https://github.com/WICG/badging/blob/master/explainer.md#What-to-Badge
Alice: If you have a github issue, you'd be able to badge whether or not the PR has been approved since that state is specific to a URL. If you have comments that have come in, the per-document case.
David: ???
Alice: distinction between any tab at that URL, versus the state of that particular tab even if multiple tabs at the same URL
Alice: That doesn't rule out badging a tab, but I understand they don't intend to flesh out the tab case anytime soon.
Alice: ? about scope. Maybe something for me, Tess, and David to discuss as well.
Peter: next week?
Alice: sure
Comment by @hober Aug 8, 2019 (See Github)
Hi @fallaciousreasoning @raymeskhoury, I have a question about progressive enhancement & feature detection.
Suppose I'm a Twitter engineer. Twitter currently munges document.title
to badge an unread count. I'd like to adopt Badge.set()
when it's available, and I'd prefer to only fall back to my legacy document.title
munging when Badge.set()
won't work for me. How would such an author know when to fall back to the legacy code path?
My read of the proposal is that this isn't currently possible. That is, feature-detecting the presence of window.Badge
or the Badge.set()
method doesn't tell me, the website author, if calling Badge.set()
will result in some kind of user-visible UI change.
Comment by @marcoscaceres Aug 8, 2019 (See Github)
As I’ve been working closely on this spec I hope it’s ok that I jump in.
@hober, not sure I follow. Setting document.title is also not observable nor guaranteed to result in a user-visible UI change. Same with setting a favicon (see Safari, for instance). I’m wondering how this is different?
I guess the fallback path would be as you suggested: 1. check for the API. 2. If not there, fallback to using title.
The above assumes that the developer can badge a browser tab, not just an installed web app. For an installed web app, a developer could check if they are “installed” by querying the CSS display-mode media feature, which is applied by the web app manifest... it’s not a perfect solution, but could do the trick.
In any case, if the Badge API is present, it implies a badge will be shown either in the dock (if app is installed) or in a browser tab (regular browser instance).
Comment by @alice Aug 8, 2019 (See Github)
In any case, if the Badge API is present, it implies a badge will be shown either in the dock (if app is installed) or in a browser tab (regular browser instance).
Ah - I think I must have misunderstood in this case. I was under the impression that implementors needn't implement support for all badging surfaces at once.
Comment by @marcoscaceres Aug 9, 2019 (See Github)
@alice, you definitely are not wrong: consider the case that @hober brought up regarding document title. Every browser supports title, but not all browsers display it. For instance, Safari in iOS on the iPhone only displays a page’s title when the user views open “tabs” in a stack view. On desktop browsers, sometimes users have so many tabs open that the browser can only show one or two letters, making the title useless as a badge fallback.
With Badge, each browser vendor will need to figure out how to best present the badge (and perhaps in constrained visual environments, or because of user preference, it may make sense to not show it at all).
Comment by @fallaciousreasoning Aug 9, 2019 (See Github)
I think @marcoscaceres has expressed this better than I could've :)
I'd just like to add that if the UA has decided not to display the badge somewhere it's probably good not to let sites know that, so they can't hack around it.
Comment by @alice Aug 9, 2019 (See Github)
I feel there has been some miscommunication here:
https://github.com/w3ctag/design-reviews/issues/387#issuecomment-519634016
if the Badge API is present, it implies a badge will be shown either in the dock (if app is installed) or in a browser tab (regular browser instance).
If implementors needn't implement support for all badging surfaces at once, then it the presence of the API necessarily does not imply a badge will be shown in a browser tab.
consider the case that @hober brought up regarding document title.
@hober was suggesting that if the tab is not successfully badged via the badging API, the author might wish to fall back to existing hacks including document title (usually as well as directly setting an alternative favicon), which are known to work under certain circumstances where the badging API may be used as an alternative if it is implemented there.
Comment by @fallaciousreasoning Aug 9, 2019 (See Github)
Whoops yes, should've been a can't
. Edited.
Comment by @alice Aug 9, 2019 (See Github)
if the UA has decided not to display the badge somewhere it's probably good not to let sites know that, so they can't hack around it.
So this implies that UAs should implement support simultaneously for badging all the UI surfaces they intend to support, then?
And if, say, Chrome doesn't implement support for badging tabs, then authors should ... do what exactly?
Comment by @marcoscaceres Aug 9, 2019 (See Github)
So this implies that UAs should implement support simultaneously for badging all the UI surfaces they intend to support, then?
Not necessarily, and you raised a good point: The API (not the UI) could ship everywhere, but calling set() is a no-op.
Alternatively, and perhaps more helpfully, when .set() is called it could throw a “NotSupportedError”.
That would satisfy the fallback case, while obscuring if the badge was visually presented.
And if, say, Chrome doesn't implement support for badging tabs, then authors should ... do what exactly?
As above. Badge is a progressive enhancement after all. That’s not to say that developers (ab)using title and favicons for unsanctioned badging is a bad thing, but it’s definitely not ideal for them, users, or the browser.
Comment by @mgiuca Aug 9, 2019 (See Github)
Hi @fallaciousreasoning @raymeskhoury, I have a question about progressive enhancement & feature detection.
Suppose I'm a Twitter engineer. Twitter currently munges
document.title
to badge an unread count. I'd like to adoptBadge.set()
when it's available, and I'd prefer to only fall back to my legacydocument.title
munging whenBadge.set()
won't work for me. How would such an author know when to fall back to the legacy code path?My read of the proposal is that this isn't currently possible. That is, feature-detecting the presence of
window.Badge
or theBadge.set()
method doesn't tell me, the website author, if callingBadge.set()
will result in some kind of user-visible UI change.
This is a pretty important point. We probably need not only feature detection but some way to know whether the badge will be applied to the current tab or not (for example, Chrome might only badge the app icon but not apply it to the tab, so the feature would be present but not show anything in the tab strip.
Web-spec-theoretically we shouldn't expose the details of the UI to the developer (like we could say "it's none of their business whether it shows in the tab strip or not; you just give us the data and the UA will display it as they see fit"). But practically, because there are already ways to do this, the developer needs to know whether the Badge API will be seen in the tab, so they can turn off the fallback mechanisms. They're not going to want to use the Badge API if there's a chance of showing a duplicate badge with the title or favicon.
So we could do Badge.canSet()
but I think we need a more advanced "will this be shown alongside the favicon and/or title?" feature detector.
Discussed
Aug 14, 2019 (See Github)
Alice: Breakout last week. This has gotten into an interestesting state. Marcos has been (reasonably) insisting on having some Tab badging. If something is a PWA it must work in a load-from-URL-in-a-tab context as well. It would be great if you didn't have to know which context you're in and badge tab with classic favicon/title munging. That's quite sensible. This kind of goes outside scope of what API authors originally intended. They've been trying to figure that out. And trying to figure out the difference between what is a "installed web app" and what's a page in a tab, and what the differences in the API surfaces in those cases. So they went in a direction of being able to set a badge on a Scope (a URL). Matt has been working on explainer to clarify a lot of these things. Matt was working on it originally, then others for bit, now Matt is back. To accomodate this in the API you can set the badge for a particular scope. This allows different tabs on the same origin to have different badges, for a start.
Alice: Tess raised the question... I brought up that Chrome may not immeditaley implement the UI side of this. Tess raised the question of progressive enhancement. No way to know, if you set the badge on a scope, whether that's worked.
Dan: Leave that up to a polyfill?
Alice: You could use the genuine badging API, and it may not set the tab badge. It may only set the PWA badge. If support for badging tabs not yet implemented.
Alice: API doesn't rule it out, but may not ship it all at once.
Dan: But API editors have listened to marcos's feedback.
Alice: yes
Dan: As someone with interest in PWA story, I tend to agree with that reasoning. Shouldn't be a depnedency on installation. Has there been discussion of dependency on manifest?
Alice: We discussed that a bit in breakout -- think it was a misunderstanding. I don't believe it does depend on a manifest.
Dan: It strikes me that mention of scoping it at a certain URL -- manifest also defines that scope.
Dan: PWA in manifest - could say, should sit in a tab, not full screen. Appears to be a little redundant to have another way of setting scope, when you already have manifests that set scope.
Alice: Badge is associated with a scope, not setting a scope.
David: also service workers have a scope
Alice: Note in the explianer -- scope may need to be in its own spec since referenced by service workers, app manifests, and badging.
Dan: What is a scope? Slightly more than an origin?
Alice: Seems to be a URL.
Alice: In the explainer: https://github.com/WICG/badging/blob/master/explainer.md#badging-for-multiple-apps-on-the-same-origin-as-in-the-case-of-multiple-github-pages-pwas
Dan: I wonder if we should add something about scope to the design principles.
Alice: I wonder.
Dan: Sounds like going in a positive direction.
Alice: Yes, I think it is. Helps that I've been able to have multiple in-person conversations with Matt and others.
Alice: To finish up the fallback thing -- Matt put the last comment on, and suggested that it needs some indication as a developer of whether Badge.set()
worked, so you can do a fallback action. Not sure if that's in the explainer yet.
Dan: Does TAG need to continue to engage, or are we done?
Alice: Are we happy with set
for a scope?
Tess: I think so.
Alice: So basically LGTM with a way to check that the badging API has worked.
Tess: I'm glad Matt agrees about ?? to effectively use this API.
Dan: So I think we should leave that feedback on our issue-- what Alice just said. And thank and close the issue from our side.
Alice to do that.
Discussed
Aug 21, 2019 (See Github)
Alice: i spent time working with Matt on this one. Looks like they are going to split it out into document badging vs. scope badging - scope badging will be more useful for the app use case and document badging will be more useful for the tab use case.
https://github.com/WICG/badging/issues/49#issuecomment-521882946
... I was fairly convinced that this was the right thing to do - they ended up here based on Tess's comment on feature detection. Scope level would be: everything with the same URL would have the same badge status, whereas you could imagine different documents having different badge statuses. e.g. github comments. Then once you have the 2 different types of badging. You can get scope like behaviour using the document API - 2 windows open to the same gmail inbox they will both get the same info fromt he server about the nunber of unread emails...
Hadley: wouldn't gmail be scoped anyway? Issues in github - makes sense
Alice: you could have 2 tabs opened to the same github issue but ...
Alice: they have work in progress to split.
Dan: what if I am writing a simple application and I just want to set a badge and I don't care if it's a document or a scope?
Alice: the fact that there are these 2 close concepts means .. if as a developer you want both then you need to set both. if you're writing something that can be installed (a manifest) then you will need to set the scope-level
Hadley: 2 different scopes ...
Alice: it's about whether the info you're conveying via the bedge makes esnes for the scope - an origin sort of - vs the document.
Hadley: granularity.
Alice: you could have both. you could have 2 windows open to the same gmail inbox.
Alice: they are going to write it up... Otherwise they will get back to us. [pending external feedback]
[bunped to f2f
Comment by @hober Sep 10, 2019 (See Github)
Note to TAG colleagues: the explainer’s been extensively updated since we last looked at this—everyone interested should take another look at it.
Comment by @marcoscaceres Sep 10, 2019 (See Github)
Just noting that I personally have concerns about the complexity of {"scope"}. I think it makes (browser) implementation quite complicated, and feel authors could use many of the existing Web APIs to achieve the same thing (e.g., broadcast channel)... however, I'd accept and support the recommendations of the TAG with respect to "scope".
Comment by @mgiuca Sep 13, 2019 (See Github)
@marcoscaceres perhaps best discussed on a new issue, but could you give detail about how broadcast channel would be applicable to the use case that we've now narrowed down "scope" to provide? ("scope" is no longer about specifying which documents show a badge, it is specifically to badge URL handles, such as apps, bookmarks and shortcuts, that may be displayed by the UA or OS when there is no document active).
Comment by @mgiuca Sep 16, 2019 (See Github)
We are discussing this on WICG/badging#51. Is there a TAG consensus on this (roughly, on the changes outlined in A Case For Separation which are expanded on with the new new explainer rewrite in that PR?
Also, which work mode would TAG prefer:
- Us landing changes directly into the explainer even though they don't have consensus, so that the explainer can be discussed as a proposal in itself, or
- Us posting PRs and reaching consensus on there before updating the explainer (the current work mode)?
Comment by @marcoscaceres Oct 9, 2019 (See Github)
Post TPAC, I think we should update the spec as we've reached consensus on how to proceed - then update the Explainer based on that. We've gotten really excellent feedback from the TAG (with a huge thanks to @alice, who chime into various bugs, and to @hober, who helped us reshape the API into something really nice during TPAC itself!) - so I wonder if we can consider this design review as complete? @mgiuca wdyt?
Comment by @mgiuca Oct 10, 2019 (See Github)
Yes. I'm working on rewriting the explainer (again) and spec. We can close this for now and perhaps I'll re-open when both are updated.
Comment by @mgiuca Jan 10, 2020 (See Github)
Hello, I forgot to update this thread awhile back.
I rewrote much of the explainer to describe the split API, with scope removed, as proposed at TPAC (WICG/badging#55): https://github.com/WICG/badging/blob/master/explainer.md
Comment by @chrishtr Jan 16, 2020 (See Github)
@hober @mgiuca Should we re-open this TAG review then?
Comment by @alice Jan 20, 2020 (See Github)
Reopening this in light of new explainer.
Discussed
Jan 27, 2020 (See Github)
Alice: Tess, let's hang on the line to chat about this if we have time
Tess: ok
Discussed
Jan 27, 2020 (See Github)
Discussion of new explainer.
Alice: two different types of badge... Two separate APIs - I believe it's necessary...
Alice: good to see feature detection right in the explainer... That seems to address the feature detection side of things.
Dan: I was concerned about the need for 2 APIs... I was concerned about the simplest use of this API - e.g. by indie app developers...
Alice: in their issue #49 I wrote some explanation.
Alice: I feel like I want to bikeshed the names...
Alice: "Client" is document, not Scope... App is Scope.
Alice: if you're badging a scope then it's also going to badge things like bookmarks.
Dan: Scope has a lot of different contexts.
Alice: I think Client should be Document... I think we need Tess on this as well. Tess was asking why it couldn't be declarative. Let's pull it into the plenary discussion.
Discussed
Feb 17, 2020 (See Github)
Kenneth: ?
David: I think we had neither Tess nor Alice so wanted to bump to plenary.
Peter: now or face-to-face.
Alice: Should we wait for Dan? Not sure how good videoconferencing option at face-to-face will be? Tess and I probably most active on issue.
Alice: If we were to talk about it now... Tess and I talked a couple weeks ago. We disagreed on whether there should be 2 APIs. I'm reasonably convinced there should, Tess is not. I'm uncomfortable with 2 APIs looking so similar; Tess thinks they should be more similar and in fact the same.
Tess: That's a fair summary.
Alice: I think the fact that there are 2 APIs that look exactly the same will create confusion. navigator.setClientBadge
versus navigator.setAppBadge
. I'd want the APIs to look different. setAppBadge
is where there's only one surface (icon/bookmark); I think setClientBadge should perhaps live on document, very different because they're different things.
Tess: I'm comfortable with you providing that naming feedback on the issue. I'm with you on the naming. Could be comfortable with navigator.?.setBadge
and document.?.setBadge
. Or maybe one of them isn't called badge at all?
Alice: I can talk to Matt.
Tess: Maybe Dan will have a third set of thoughts.
Alice: I'll give feedback, and we'll check in again at face-to-face
Discussed
Feb 17, 2020 (See Github)
[bump to plenary for now
Discussed
Mar 16, 2020 (See Github)
Alice: I was supposed to do something...
Tess: I've not yet read the updated explainer.
Alice: (makes reminder)
Bumping out 1 week
Alice: I had a chat with Matt. I've been convinced for a while (though I think Tess disagrees) that tabs API and app API are significantly different and have different use case. As such I think it would be nice if the tabs version of the API was more closely tied to the document (makes no sense on navigator
). Current design is a weird compromise based on lack of agreement whether they were different use cases or not. I think we need to pick one, I would pick being different. That's the comment I need to leave
Discussed
Mar 23, 2020 (See Github)
Alice: Still haven't written up a comment.
[bumped
Comment by @alice Mar 30, 2020 (See Github)
Oof, so sorry I put this off so long, although I did chat with Matt about my comments in person before now, at least.
In short, using Navigator
to set a badge which is scoped to a single document seems odd to me.
I am happy with Navigator.setAppBadge()
, and it seems like Navigator.setClientBadge()
was intended to keep the document-based API as close as possible to the app-based API, short of having them be the same API which I believe was @hober and @marcoscaceres' preference.
However, I still believe the use cases for these two situations look different enough that separate APIs are warranted: in particular, that an installed application or a bookmark may have zero, one or multiple tabs/windows, whereas, a document by definition has one tab/window, and multiple instances of documents with the same URL may have different transient local state which authors may wish to expose as a badge.
That being the case, I think the two APIs being so similar will create confusion - I'd be hard placed to remember which of setAppBadge()
and setClientBadge()
was going to do the thing I want.
Could we have setClientBadge()
as an API on Document
instead, perhaps?
Comment by @mgiuca Mar 30, 2020 (See Github)
@alice Thanks for summarizing. That mostly accords with what we discussed in person. (gazes wistfully out the window ... ahhh. Back in the before times. sigh)
It's a pretty nice insight I think: we previously discussed whether the two APIs should go on Navigator or Document, but I don't think anyone (before Alice) suggested that setAppBadge
should go on Navigator, while setClientBadge
should go on Document, to better convey the semantics that setAppBadge
is setting something external to the document, while setClientBadge
is specific to the current document. I like this and would be supportive of moving setClientBadge
to Document, whilst keeping setAppBadge
on Navigator. (Happily, this means we won't have to change Chrome's implementation which only has setAppBadge
.)
That being the case, I think the two APIs being so similar will create confusion - I'd be hard placed to remember which of
setAppBadge()
andsetClientBadge()
was going to do the thing I want.
Beyond putting them on different parent objects, I don't want to just make the two APIs different for the sake of being different. Even though they have different scope, lifetime and badge location, they both represent essentially the same data model and semantics for the badge:
- The data model (integer, flag or clear) is the same.
- The rules around displaying a badge (e.g., UA deciding whether to saturate the value) are the same.
- The semantics of how the API maps onto the model (e.g., calling
set()
sets it to the flag state whereas callingset(0)
is equivalent to clearing) are the same.
I don't want to arbitrarily make the APIs different just so that users can better distinguish between the two.
But, I am supportive of moving setClientBadge
and clearClientBadge
to Document (or an object within).
Also @cmumford who is taking over ownership of the Badging API on the Chrome side.
Comment by @marcoscaceres Mar 30, 2020 (See Github)
Personally, I'd be inclined to leave them both on Navigator
tbh... if only to keep them consistent as to where to find them. I also feel like methods on Document
should affect the document tree or have a strong relationship the document itself. Although what @alice says about the relationship between .setClientBadge()
and the document holds, it still feels like it's affecting something outside the document... a browser tab, a home screen icon... now I'm thinking it would more accurately be on Window
, but let's not go there 🤭😂.
My 2c.
Comment by @alice Mar 30, 2020 (See Github)
Window
makes sense to me, why not go there?
Comment by @fallaciousreasoning Mar 31, 2020 (See Github)
+1 to Window
, conceptually that is what's being badged. Does putting it there increase the implementation complexity (or does it make getting the spec approved harder?)?
Comment by @dbaron Mar 31, 2020 (See Github)
The downside to Window
is that adding things to window pollutes the global namespace, and thus has the potential (at least in some edge cases) for breaking scripts that use the name you're adding as a variable name.
Comment by @alice Mar 31, 2020 (See Github)
The other reason not to have them both on Navigator
is that it's a source of confusion - I predict needing to look up every single time whether I want setAppBadge()
or setClientBadge()
.
I think Document
is defensible, if we don't want to go with Window
- the title and favicon are in the document, after all.
Comment by @marcoscaceres Mar 31, 2020 (See Github)
@hober, want to cast a tie breaker or add some thoughts?
Comment by @mgiuca Apr 1, 2020 (See Github)
Yeah, I don't want to use Window
just because it pollutes the global namespace.
I think it's important to consider sometimes that the mechanics of these things can be more important than the names. Even if "window" is the right name for this, it's mechanically problematic. These things go way way back to the history of the web, so the best thing to do is shrug and say "they have the wrong names, for historical reasons". Modern web design should consider Window
to mean "the global top-level namespace" and Document
to mean "the object that represents the current document and its window". New APIs should only go in Window
if they're fundamental things that should be available automatically, like a new array type, not a new API that will be called in one very special place across the entire site.
Discussed
Apr 6, 2020 (See Github)
Alice: reads her comment from 10 days ago and Matt Giuca's reply.
Tess: I don't have a strong preference between document or navigator.
Dan: Can we close?
[agreed to close
Discussed
Apr 6, 2020 (See Github)
Dan: I don't feel like we can deal with this one without Alice & Tess... Let's bump to the plenary call
Discussed
Apr 6, 2020 (See Github)
[ran out of time; pushed to breakout C
Comment by @hober Apr 8, 2020 (See Github)
I don't have a strong preference between document and navigator.
Comment by @hober Apr 8, 2020 (See Github)
I think this review has run its course, so I'm going to close it. Please let us know if anything changes and you'd like to re-open it. Thanks!
OpenedJun 18, 2019
こんにちはTAG!
I'm requesting a TAG review of:
Further details:
We'd prefer the TAG provide feedback as (please select one):