How to expose Battery Status (was: On Battery API)


[I'd like to make sure this important issue Doug pointed out does not go unnoticed, so I'd like to elaborate it a bit.]

On 16.6.2011, at 15.50, ext Anssi Kostiainen wrote:

> On 15.6.2011, at 19.48, ext Doug Turner wrote:
>> There are a few concerns/ideas I have about the Battery API.
>> 1) I do not think we want handlers to hang off of the window object.
>> window.onbatterystatus is bad.  we have addEventHandler()
> I notice the Device Orientation Event only exposes itself via window.addEventListener(), while e.g. the online and offline events also have document.ononline and document.onoffline handlers (mirrored also on document.body) as well as corresponding attributes on the <body>. But there's nothing on window. So perhaps window.onbatterystatus should not be there in the global namespace.

Actually, it appears that as per the HTML5 spec [1] ononline/onoffline event handlers should be supported also by Window objects, but implementations do not seem to do that currently (e.g. see this test case at [2]). I found some old -- but IMHO still relevant and interesting -- discussion from the Mozilla Bugzilla at [3,4]. The short summary is the window.ononline/offline was in, but has since been removed.

> How do others feel about that?

My personal take on this is we should pave the cowpaths if any. This feature should work in a way which is the most consistent with other similar features. As said, we have the Device Orientation and online/offline events, but both expose themselves differently. In addition to those we have a bunch of other event handlers (some legacy, some new) [1] which hang off of the window such as onmessage, onstorage etc.

I'd prefer to go to LC with the current spec and gather more implementers' feedback and adjust the spec accordingly when we have running code around. WebKit implementation can be tracked at [5], and there's a related thread on webkit-dev ML at [6].

Doug - Are you planning to hack something around this? Would be cool to get you guys on board as well in addition to WebKitters :)








Received on Monday, 20 June 2011 11:21:58 UTC