This Week in HTML 5 – Episode 19
Welcome back to "This Week in HTML 5," where I'll try to summarize the major activity in the ongoing standards process in the WHATWG and W3C HTML Working Group. Despite it being almost February already, this episode will focus on changes and discussion from the week of January 19th. Normal weekly updates will resume on Monday.
There are 3 pieces of big news for the week of January 19th. Big news #1: r2692, a major revamp of the way application caches are defined. Application caches are the heart of the offline web model which can be used to allow script-heavy web applications like Gmail to work even after you disconnect from the internet. Here is the new definition of how application caches work:
Each application cache has a completeness flag, which is either complete or incomplete.
An application cache group is a group of application caches, identified by the absolute URL of a resource manifest which is used to populate the caches in the group.
An application cache is newer than another if it was created after the other (in other words, application caches in an application cache group have a chronological order).
Only the newest application cache in an application cache group can have its completeness flag set to incomplete, the others are always all complete.
Each application cache group has an update status, which is one of the following: idle, checking, downloading.
A relevant application cache is an application cache that is the newest in its group to be complete.
Each application cache group has a list of pending master entries. Each entry in this list consists of a resource and a corresponding
Documentobject. It is used during the update process to ensure that new master entries are cached.An application cache group can be marked as obsolete, meaning that it must be ignored when looking at what application cache groups exist.
A
Documentinitially is not associated with an application cache, but steps in the parser and in the navigation sections cause cache selection to occur early in the page load process.Multiple application caches in different application cache groups can contain the same resource, e.g. if the manifests all reference that resource.
The end result of this major work is actually pretty similar to how application caches worked before, but there were some edge cases (such as handling 404 errors when fetching the application manifest) which are now handled in a sane fashion. It also paved the way for r2693, which makes it possible for application caches to become "obsolete" (meaning they must be ignored when deciding which caches exist).
Big news #2: r2684, which redefines the on* attributes in a way that doesn't suck quite as much. Also, it defines the widely used (but poorly understood) onerror attribute in a way that matches what browsers actually do with it. Here is the meat of it:
All event handler attributes on an element, whether set to null or to a
Functionobject, must be registered as event listeners on the element, as if theaddEventListenerNS()method on theElementobject'sEventTargetinterface had been invoked when the event handler attribute's element or object was created, with the event type (type argument) equal to the type described for the event handler attribute in the list above, the namespace (namespaceURI argument) set to null, the listener set to be a target and bubbling phase listener (useCapture argument set to false), the event group set to the default group (evtGroup argument set to null), and the event listener itself (listener argument) set to do nothing while the event handler attribute's value is not aFunctionobject, and set to invoke thecall()callback of theFunctionobject associated with the event handler attribute otherwise.The listener argument is emphatically not the event handler attribute itself.
When an event handler attribute's
Functionobjectw is invoked, itscall()callback must be invoked with one argument, set to theEventobject of the event in question.The handler's return value must then be processed as follows:
- If the event type is
mouseoverIf the return value is a boolean with the value true, then the event must be canceled.
- If the event object is a
BeforeUnloadEventobjectIf the return value is a string, and the event object's
returnValueattribute's value is the empty string, then set thereturnValueattribute's value to the return value.- Otherwise
If the return value is a boolean with the value false, then the event must be canceled.
The
Functioninterface represents a function in the scripting language being used. It is represented in IDL as follows:[Callback=FunctionOnly, NoInterfaceObject] interface Function { any call([Variadic] in any arguments); };The
call(...)method is the object's callback.In JavaScript, any
Functionobject implements this interface.
Big news #3: r2685 and r2686 defines a whole slew of important events that are fired on the Window object, including onbeforeunload, onerror, and onload. Previously, some of these were defined on the <body> element, which didn't actually match current browser behavior.
The following are the event handler attributes that must be supported by
Windowobjects, as DOM attributes on theWindowobject, and with corresponding content attributes and DOM attributes exposed on thebodyelement:
onbeforeunloadMust be invoked whenever a
beforeunloadevent is targeted at or bubbles through the element or object.onerrorMust be invoked whenever an
errorevent is targeted at or bubbles through the object.Unlike other event handler attributes, the
onerrorevent handler attribute can have any value. The initial value ofonerrormust beundefined.The
onerrorhandler is also used for reporting script errors.onhashchangeMust be invoked whenever a
hashchangeevent is targeted at or bubbles through the object.onloadMust be invoked whenever a
loadevent is targeted at or bubbles through the object.onmessageMust be invoked whenever a
messageevent is targeted at or bubbles through the object.onofflineMust be invoked whenever a
offlineevent is targeted at or bubbles through the object.ononlineMust be invoked whenever a
onlineevent is targeted at or bubbles through the object.onresizeMust be invoked whenever a
resizeevent is targeted at or bubbles through the object.onstorageMust be invoked whenever a
storageevent is targeted at or bubbles through the object.onunloadMust be invoked whenever an
unloadevent is targeted at or bubbles through the object.
Other interesting tidbits from the week of January 19th:
- r2683 defines the concept of an override URL in order to prevent
javascript:URLs (which you should never, ever use) from breaking through the cross-domain origin security policy. - r2697 provides an algorithm for determining the character encoding of an external script referenced by a
<script>element. - r2698 clarifies that
relattributes are case-insensitive. - r2703 tweaks the parsing algorithm of the misplaced
<frameset>elements to be more compatible with Internet Explorer.
Tune in next week for another exciting episode of "This Week in HTML 5."
You may saying “exciting” sarcastically, but to me, this is a very interesting peek into how specs are written. Thanks for these updates and keep it up!
Thats great to see ononline and onoffline finally made official and not just MS!
[…] Pilgrim release a couple of HTML 5 roundup posts in a row. In his first post he talks […]