Greetings to all of you guys! I'd like to share some thoughts about cloning events.
Here's some background quoted from http://www.quirksmode.org/js/events_advanced.html [...] "One problem of the current implementation of W3C's event registration model is that you can't find out if any event handlers are already registered to an element. In the traditional model you could do: alert(element.onclick) and you see the function that's registered to it, or undefined if nothing is registered. Only in its very recent DOM Level 3 Events W3C adds an eventListenerList to store a list of event handlers that are currently registered on an element. This functionality is not yet supported by any browser, it's too new. However, the problem has been addressed. Fortunately removeEventListener() doesn't give any errors if the event listener you want to remove has not been added to the element, so when in doubt you can always use removeEventListener()." [...] the miss for a browser native "eventListenerList" is not a real issue for removing events except that all responsibility to remember and destroy registered handlers is on the application layer. More: unregistering handlers could become trivial in the future (if) and when #7435 will be merged into trunk. but what about cloning events? W3C specs are clear about this: http://www.w3.org/TR/2000/PR-DOM-Level-2-Events-20000927/events.html [...] "When a Node is copied using the cloneNode method the EventListeners attached to the source Node are not attached to the copied Node. If the user wishes the same EventListeners to be added to the newly created copy the user must add them manually." [...] this could be a fair problem when operating on predictable node structures, or maybe an application layer nightmare if you have to deal with unknown tree structures. Now worst: * Moz guys here decided to follow standards in y2k: https://bugzilla.mozilla.org/show_bug.cgi?id=26528 * Opera 9 behaves the same as Moz * .... who knows what other browsers do! * M$ guys decided that IE7 still behaves in it's way: the test that follows show that events are copied along with nodes. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="js/prototype/prototype.js"></ script> <script> function sayHello() { alert('Hello!'); } function testEventsClone() { var el = new Element('div').update('<a href="#">click me</a>'); Event.observe(el,'click',sayHello); document.body.appendChild(el); var el2 = el.cloneNode(true); document.body.appendChild(el2); } Event.observe(window,'load',testEventsClone); </script> <title>CloneNode Test</title> </head> <body> </body> </html> can someone argue how do deal with the whole mess? --htrex; --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---