Tuesday, July 24th, 2007
Category: JavaScript
, Library
<
>p
>Tavs Dokkedahl has written a small script that makes IE conform to the W3C DOM3 Event recommendation (at least the part that FF supports).
The Uniform Event Model adds support for the capture, atTarget and bubbling phases and provide most of the EventListener interface including among others the addEventListener, removeEventListener, createEvent, initEvent and dispactEvent methods. All handlers are passed an event object with almost complete information according to standards. See the list of features for detailed information on event flow, methods and properties.
Tavs has documentation that covers:
- An introduction to the framework
- The available W3C features
- The perfomance implications.
- W3C approves specification for Web site scripting
Seeking to establish an industry standard for Web site scripting, the World Wide Web Consortium (W3C) has published the...
- What is the W3C doing now?
Last week I suggested the W3C may be losing its way, but it is still doing some good...
- What's new at the W3C
The W3C continues to be the main organization for creation of internationally recognized standards for XML, WSDL, and HTML. At any given time, a large...
- W3C log
A W3C log is an access log for Web servers in which text files are generated containing data about each access request, including the source Internet...
- DOM Level 2: Better than SAX?
Lauren Wood, chair of the W3C DOM Working Group, answers our questions about the DOM Level 2, and XML authority Benont Marchal, shares his thoughts on...
Interesting. What happens if you alter the DOM using innerHTML? Will the resulting nodes by “UEMed”?
Sometimes it seems that the time is right for some ideas. We are currently working on moving qooxdoo’s DOM event handling code to it’s own layer, independent of the widget stuff. This event layer will have some of the same features, e.g. support for the capturing phase in IE and unified event objects modeled after the W3C DOM standard. Special mouse and key event handlers are responsible for normalizing event sequences and in the case of the key handler computing the key identifier. Another interesting feature, which we have brought from the IE to the other browsers is mouse event capturing.
Early documentation can ba found here: http://qooxdoo.org/documentation/general/dom_event_layer
Maybe I’m rusty on my algorithm time complexity theory, but on the perf page in the creator’s documentation he lists two algorithms that include nested loops as O(n). That sounds more like O(n^2) or at best maybe O(n log n) to me. Feel free to correct me if I’m wrong, computational theorists.
The outer loop runs a constant number (100) of times: 100*n = O(n) !
Yes 100 * n != O(n) but, 100 * O(n) :P.
I haven’t looked at the code, but I suspect it has the same problems with
thismentioned in PPK’s addEvent() considered harmful.Thanks for the comments.
@ Steve Brewer. I am working on replacing the existing innerHTML method. Note however that this method is not in the W3C recommendations. But since it is wildly supported and used (and misused) it would be a good idea to support it.
@ Jason. The perfomance tests are not scientifically correct. They are my best shoot at an upper bound on the worst case scenario. You’re right that 2 for loops would produce O(n^2) but the inner loop is executed only twise at a maximum. Therefore I feel it is closer to the real world to regard the inner loop as a constant – hence the O(n) result.
@ Braden Anderson. If you look at the code you will see that there is no resemblence with UEM and the original code of Scott Andrew. UEM does not use the native addEvent nor removeEvent() methods. It currently uses the fireEvent method to enulate dispatchEvent although it is not strictly nessesary. The addEvent() method you are refering to is a nice solution but falls short in many places.
Tavs, I don’t understand why you said the inner loop executes only twice at a maximum (in your response to Jason). But IF that’s the case, then since the outer loop is 100 times always, the growth rate would then be independent of the size of the inputs. The the big-oh should be O(1). (Constant factor is dropped in big-oh notation).
@ibolmo
“100 * O(n)” is not a correct statement, as you can’t multiply a number with a collection of functions (thats what the big O notation represents).
In computer sience “100*n = O(n)” is quite right. It has the same meaning as f(n)=100*n is element of O(n).
See: http://en.wikipedia.org/wiki/Big_O_notation
@ Steve Brewer. I found a way to support innerHTML – it might contain beta errors but the approach seems good. Try it out if you like.
@ Kevin Hoang Le. You can only have two event handlers of the same type with the same function registered for any one element – hence it can execute twice at maximum. The loopNum variable is only in the code for testing purposes. It tells how many times to test the loop. It is not an integral part of UEM and thus does not count in the result for the code perfomance.