Re: Can Dispatch canDispatch()?

Olli Pettay wrote:
>>>>
>>>> But how would the hasEvent() work with plugins, extensions or
>>>> greasymonkey scripts? All those can create random events using
>>>> the normal DOM Events API.
>>>>
>>>
>>> If they want to dispatch trusted events they will have to register with
>>> the browsers internal events table.
>>> Otherwise they can always provide their own equivalent of hasEvent().
>>>
>>
>> What has trusted events to do with hasEvent()?
>> (AFAIK, trusted events are gecko specific thing.)
>
> (And in gecko nothing needs to be registered "with the browsers 
> internal events table" to be able to dispatch trusted events.
> Privileged script can dispatch trusted events.)
>


I don't see this being an issue. I'm not familiar with how plugins, etc 
integrate with the browser, so the following suggestions may not be 
valid. Please correct as appropriate.

If a plugin is dispatching a proprietary event then I don't think it 
matters if document.hasEvent() doesn't report it. The plugin may choose 
to provide its own lookup, eg: myPlugin.hasEvent().

If the plugin is providing a standard event because the browser doesn't 
implement it, then hasEvent() should report it.
Either
    the browser allows the plugin to register an event-type so that 
document.hasEvent() can report it,
Or
    the plugin overwrites document.hasEvent(), eg:

document._hasEvent = document.hasEvent;
document.hasEvent = function(ns, type) {
    return myPlugin.hasEvent(ns, type) || this._hasEvent(ns, type);
}

Received on Friday, 28 August 2009 03:00:49 UTC