Re: Feedback from Safari on Web Notifications

On Mar 13, 2012, at 1:44 AM, Anne van Kesteren wrote:

> On Tue, 13 Mar 2012 01:32:18 +0100, Jon Lee <jonlee@apple.com> wrote:
>> So by having the event listeners as part of the options dictionary, would it make sense, then, to remove the assignable attributes? Therefore, the only way to modify the listeners is through add/removeEventListener()?
> 
> If we make the constructor queue a task, you could still assign event listeners in the same task that created the constructor.
I don't quite understand what this means. If the constructor creates the Notification and also queues/presents the notification, then why would anyone want to re-assign listeners? The code already has an opportunity to set all the listeners in the options dictionary. By the time the constructor is finished, the notification is already shown, so trying to change onshow doesn't do anything useful. Same with onerror, since that only gets called if the notification could not be shown. I suppose one might want to do it for the other handlers, but I don't think there's any extra information that you gain once the constructor is executed that might require you to alter the listener you already added.

Another question. Take this code:

function a() {}
function b() {}
var n = new Notification('title', 'body', {onshow:a, onclose:b});

Does the options object then equate to something like:
n.onshow = a;

or
n.addEventListener('show', a, false);

Jon

Received on Tuesday, 13 March 2012 17:30:30 UTC