- From: Anne van Kesteren <annevk@opera.com>
- Date: Tue, 01 Mar 2011 12:06:45 +0100
- To: www-dom@w3.org
Hi,
http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#event-flow
says "As the final step of the event dispatch, for reasons of backwards
compatibility, the implementation must reset the event object's
internal-propagation and default-action-prevention states."
As far as I can tell this is not implemented this way. Propagation is not
reset in either Opera or WebKit (it is in Gecko).
Load the following in
http://software.hixie.ch/utilities/js/live-dom-viewer/ to test:
<!DOCTYPE html>
...<script>
var e = document.createEvent("Event")
e.initEvent("test", false, true)
document.addEventListener("test", function() { w("invoked") }, false)
e.stopPropagation();
w("d1: " + document.dispatchEvent(e))
w("d2: " + document.dispatchEvent(e))
</script>
Similarly, in Opera, WebKit or Gecko the canceled flag does not appear to
be reset. Load the following in the same viewer to test:
<!DOCTYPE html>
...<script>
function callback(ev) {
if("defaultPrevented" in ev)
w("ev: " + ev.defaultPrevented)
else
w("ev: " + ev.getPreventDefault())
}
var e = document.createEvent("Event")
e.initEvent("test", false, true)
document.addEventListener("test", callback, false)
e.preventDefault();
w("d1: " + document.dispatchEvent(e))
w("d2: " + document.dispatchEvent(e))
</script>
So it appears that there is no backwards compatibility issue here.
Having said that, something to reset these flags might be nice so event
objects can be reused. Or do we always want people to create new event
objects? Maybe invoking initEvent() should reset these flags? As invoking
initEvent() can also change the nature of it being cancelable.
Kind regards,
--
Anne van Kesteren
http://annevankesteren.nl/
Received on Tuesday, 1 March 2011 11:07:23 UTC