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

Re: Some comments on the API

From: Jonas Sicking <jonas@sicking.cc>
Date: Sun, 17 Oct 2010 11:26:58 -0700
Message-ID: <AANLkTimqxMpQWbQM6Rniz8TiJ2DSVshRDWW7EiVLb3zW@mail.gmail.com>
To: Doug Turner <dougt@dougt.org>
Cc: 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 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
Received on Sunday, 17 October 2010 18:27:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 17 December 2012 14:48:27 GMT