Events.js
Events.js copied to clipboard
browser compatibility
i just test it on IE 6, and its not work, could you making it to support IE 6, and other browser? i like this framework, hope you can make it compatible with other browser
thx
+1 for IE6
I don't even have a copy of IE6 to test on. If you can tell me a specific error you're encountering, I will look into it.
I can give you TeamViewer access to my virtual machine with fresh vanilla Windows XP installation with IE6. Eh? :)
Looks like it is giving an error when i try to fire a click event of mine in IE7: SCRIPT5007: Unable to get value of the property 'prototype': object is null or undefined events.js, line 441 character 4
When a browser does not support the hasOwnProperty
method on the Event object type (a problem most common in IE versions), Events.js attempts to extend those objects with a custom hasOwnProperty
method, which is where the error is occurring.
// Line: 437
addHasOwnProperty = (function() {
var hop = function(prop) {
if (typeof this == 'undefined' || typeof prop == 'undefined' ||
typeof this[prop] == 'undefined') {return false;}
return this[prop] !== this.constructor.prototype[prop]; // this line causes the error
};
return function(obj) {
try {
obj.prototype.hasOwnProperty = hop;
if (typeof obj.hasOwnProperty !== 'function') {throw 0;}
} catch (e) {
obj.hasOwnProperty = hop;
}
};
}());
It seems that the browser is having trouble looking up the value of this.constructor
, a problem which should never happen when just dealing with an event object. It seems to me that the problem is with the event object itself that is being passed to this function. Beyond that, I don't really know at the moment; I haven't really done any work on this project in a long time, it would take some serious digging for me to figure out what exactly is going wrong and where, and I don't really have the time myself.
For event handling in IE6 to IE8, you might want to check out https://github.com/jonathantneal/EventListener . Except for the random firing order issue ( http://cute-solutions.blogspot.be/2006/02/order-of-events.html ), I got the EventListener.oldie.js file to work fine on IE6 to IE8.
Another interesting event handling implementation is the one by Dean Edwards ( http://dean.edwards.name/weblog/2005/10/add-event2/ ). jQuery's event handling mechanism is based on it and doesn't suffer from the random firing order issue.