DOM Level 3 CustomEvents not bubbling on WebKit

Posted by Edu Felipe on Stack Overflow See other posts from Stack Overflow or by Edu Felipe
Published on 2010-06-10T19:49:25Z Indexed on 2010/06/10 19:53 UTC
Read the original article Hit count: 198

Filed under:
|

I'm observing CustomEvents not bubbling, even though I set bubbling to true. The code below:

var evt = document.createEvent("CustomEvent")
evt.initCustomEvent("mycustomevent", true, false)

var someh1 = document.getElementById("someh1")
someh1.addEventListener("mycustomevent", function(){ alert("OMG!"); })

document.getElementsByTagName("body")[0].dispatchEvent(evt)

With the HTML below:

<html>
  <head></head>
  <body>
    <h1 id="someh1">content!</h1>
  </body>
</html>

Never shows the alert, demonstrating that the event is not bubbling down. Am I doing something wrong?

Please note that if I do a getElementById("someh1") and run the dispatchEvent on it, the alert is displayed.

Thanks!

© Stack Overflow or respective owner

Related posts about html

Related posts about dom