W3C home > Mailing lists > Public > public-web-notification@w3.org > October 2010

Re: Some comments on the API

From: John Gregg <johnnyg@google.com>
Date: Mon, 18 Oct 2010 09:30:59 -0700
Message-ID: <AANLkTi=6myDqKndMmCFYOsqeO0Ce=2vj6JA7bgFkN1yZ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Doug Turner <dougt@dougt.org>, Anne van Kesteren <annevk@opera.com>, James Graham <jgraham@opera.com>, Web Notification WG <public-web-notification@w3.org>
On Sun, Oct 17, 2010 at 11:26 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Sun, Oct 17, 2010 at 9:16 AM, Doug Turner <dougt@dougt.org> wrote:
>>>  Per the current specification it would be at window.Notification, to be exact.
>> Right.  I am not an advocate of putting this on window.  This is unlike alert(), confirm(), prompt() which are tied to a dom window.  This api is tied more to a user agent itself, and for that, we use navigator.*.
> I think the point Anne is trying to make is that as long as we return
> an object of a sort, that object is going to have an interface. And
> since it uses an interface, in this case Notification, we will be
> exposing a so called interface-object in the global scope. We do this
> for almost all interfaces, for example you can do
> window.Node
> window.Element
> window.XMLHttpRequest
> window.MouseEvent
> window.HTMLInputElement
> These interface objects are mainly useful for two things, it allows
> you to extend objects by doing:
> window.Node.prototype.removeFromParent = function() {
>  this.parentNode.removeChild(this);
> }
> and by testing that an object is of a particular type
> if (someElement instanceof HTMLInputElement) {
>  ..do stuff..
> }
> Anyhow, since with this proposed interface we would be using a new
> Notification interface, and thus add its interface-object to the
> global scope, we already have added window.Notification. And so if we
> allow the syntax
> x = new Notification;
> we don't actually add any *additional* risk of collisions.
> / Jonas

For what it's worth, the current draft has specified accessing
notifications from the navigator object for quite some time.  See
section 5 [1]: "In page context, the NotificationCenter methods are
accessed from the Navigator object."

[1] http://dev.w3.org/2006/webapi/WebNotifications/publish/Notifications.html#window
Received on Monday, 18 October 2010 16:31:37 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:53:13 UTC