More Evil On Safari

Found an issue with Safari (tested against version 1.3.1)

With the following code….

var l_a5 = document.getElementById("a5");

l_a5.onclick = f1;

l_a5.onclick = null;


.. when clicking on the element referenced by l_a5 will result in both events triggering in the order f2,f1

Every other browser that supports addEventListener only triggers the single event f2

If you think about f1 should never fire, because the reference to it has been set to null – somehow, Safari remembers.

Here is a testcase  (see the last test) for browsers that support addEventListener which are off the top of my head Netscape,Firefox,Mozilla and Safari.

The testcase is used to show how different browsers handle a mixture of event listeners added by addEventListener  and inline or assigned eg. element.onevent = function.  Here is another testcase for my addEventListener replacement where you can see that I have made an attempt to normalise all the different quirks and emulate the way that the latest Mozilla engine handles some of these situations for all other browsers.

I’ve made a note in more detail on this problem here.

About James McParlane

CTO Massive Interactive. Ex Computer Whiz Kid - Now Grumpy Old Guru.
This entry was posted in JavaScript. Bookmark the permalink.

1 Response to More Evil On Safari

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s