- From: Marcos Caceres <w3c@marcosc.com>
- Date: Wed, 23 May 2012 12:28:58 +0100
- To: Bjoern Hoehrmann <derhoermi@gmx.net>
- CC: Doug Turner <dougt@mozilla.com>, "N.V.Balaji" <nv.balaji@samsung.com>, ext Jonas Sicking <jonas@sicking.cc>, public-device-apis@w3.org, Anssi Kostiainen <anssi.kostiainen@nokia.com>, Dzung D ext Tran <dzung.d.tran@intel.com>
On 23/05/2012 02:24, Bjoern Hoehrmann wrote: > * Marcos Caceres wrote: >> On 22/05/2012 18:13, Doug Turner wrote: >>>> The reason for the event to bubble is also unclear. >>> These APIs are based on DOM events. See http://www.w3.org/TR/DOM-Level-2-Events/events.html >> Not sure what you mean, but the event has nothing to "bubble" up to >> (hence, bubbling has no use case). This also seems to contradict the >> defaults in DOM4: >> >> " The bubbles and cancelable attributes must return the values they were >> initialized to. When an event is created the attributes must be >> initialized to false." >> >> Can we just agree to leave it to the DOM4 defaults and not worry about it? > There is no contradiction. The quoted text refers to the value of these > attributes after an event object has been created using `.createEvent`. I think it's for both the Constructor and for .createEvent: http://www.w3.org/TR/dom/#constructing-events > Whether any event defined by this Working Group bubbles has do be de- > fined by the Working Group. If the target of the event is the Window > object, it should use the dominant bubbling behavior for events that're > also targeted at the Window object, unless there are good reasons to do > otherwise. Ok (but still avoids the use case question - which should be used to justify why something is in the spec). No one has answered what they use case is, and I can't think of one as a javascript developer. Below is a rough sample of the "dominant bubbling behavior" for events fired at Window (as per HTML spec). Number of events that bubble on Window in HTML5 is 2. Number of events that don't bubble on Window in HTML is 5. Number of events that are not fired at the window (but are fired at parts of the Document) and do not bubble is 100+ (search for "fire a simple event"). Events that bubble in HTML are around ~21 (search for "not bubble"). Here are the ones that are fired at Window. Bubble: "If state changed is true, fire a popstate event at the Window object of the Document, using the PopStateEvent interface, with the state attribute initialized to the value of state. This event must bubble but not be cancelable and has no default action." " If hash changed is true, then fire a hashchange event at the browsing context's Window object, using the HashChangeEvent interface, with the oldURL attribute initialized to old URL and the newURL attribute initialized to new URL. This event must bubble but not be cancelable and has no default action." Don't bubble: "Fire a pagehide event at the Window object of the Document, but with its target set to the Document object (and the currentTarget set to the Window object), using the PageTransitionEvent interface, with the persisted attribute initialized to true. This event must not bubble, must not be cancelable, and has no default action." " If the Document is in a browsing context, then queue a task to fire a pageshow event at the Window object of the Document, but with its target set to the Document object (and the currentTarget set to the Window object), using the PageTransitionEvent interface, with the persisted attribute initialized to false. This event must not bubble, must not be cancelable, and has no default action." " If the current document readiness of the specified entry's Document is "complete", queue a task to fire a pageshow event at the Window object of that Document, but with its target set to the Document object (and the currentTarget set to the Window object), using the PageTransitionEvent interface, with the persisted attribute initialized to true. This event must not bubble, must not be cancelable, and has no default action." " The user agent must fire a simple event* named beforeprint at the Window object of the Document that is being printed, as well as any nested browsing contexts in it." " Queue a task to dispatch the event created in the previous step at the Window object on which the method was invoked. The task source for this task is the posted message task source." (MessageEvent) * " Firing a simple event named e means that an event with the name e, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the Event interface, must be created and dispatched at the given target."
Received on Wednesday, 23 May 2012 11:29:33 UTC