W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2011

[DOM3Events] stop propagation and canceled flags

From: Anne van Kesteren <annevk@opera.com>
Date: Tue, 01 Mar 2011 12:06:45 +0100
To: www-dom@w3.org
Message-ID: <op.vrnvtihw64w2qv@anne-van-kesterens-macbook-pro.local>

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>
   var e = document.createEvent("Event")
   e.initEvent("test", false, true)
   document.addEventListener("test", function() { w("invoked") }, false)
   w("d1: " + document.dispatchEvent(e))
   w("d2: " + document.dispatchEvent(e))

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>
   function callback(ev) {
     if("defaultPrevented" in ev)
       w("ev: " + ev.defaultPrevented)
       w("ev: " + ev.getPreventDefault())
   var e = document.createEvent("Event")
   e.initEvent("test", false, true)
   document.addEventListener("test", callback, false)
   w("d1: " + document.dispatchEvent(e))
   w("d2: " + document.dispatchEvent(e))

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
Received on Tuesday, 1 March 2011 11:07:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:36:58 UTC