[webkit-help] DOM Events do not work for new documents

Lucas Clemente luke.clemente at googlemail.com
Thu Jan 6 12:01:28 PST 2011


Hi there,

Try the following js code:

  doc = document.implementation.createDocument("", "root", null);
  doc.addEventListener("DOMNodeInserted", function(event) {
                         alert("changed!");
                       }, false);
  doc.documentElement.appendChild(doc.createElement("test"));

This should show a dialog, however it does not do anything in Webkit-based
browsers (tried Chrome Dev and current Safari on Mac). Works for Firefox and
Opera.

Using the HTML document *does* work:

  document.addEventListener("DOMNodeInserted", function(event) {
                              alert("changed!");
                            }, false);
  document.body.appendChild(document.createElement("button"));

Is this a bug or do I miss something?

Best,
Lucas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20110106/4fa4bd2c/attachment.html>


More information about the webkit-help mailing list