Well, I've been using my JavaScript library, Fork, in production for a
couple years. It hasn't needed any fixes but I'd still like to update
it have a new API more to my current tastes. I'd also like to change
the way the feature testing works. The original Fork had these
isSupported functions to test if various parts of the API will work. I
think I'd rather wrap those bits of code in their feature tests so
that the bits of code are not even defined if they won't work.
Now the library is
FORK.Event.addListener = function(){};
FORK.Event.isSupported = function(){return test ? true : false;};
and a user would write
if (FORK.Event.isSupported()) {
Fork.Event.addListener();
}
I'd rather have the library be
if (test) {
FORK_addListener = function(){};
}
and then the user would write
if (typeof FORK_addListener == 'function') {
FORK_addListener();
}
I've digressed a lot but if you have any thoughts on the above please
comment.
What I need to test for is in the event library. Safari 2.0.3-, if I
remember correctly, had a bug where a click or double click event
could not be preventDefault'ed. You've may seen me write about this
before. I wrote about it in the appendix of one article you've read
http://peter.michaux.ca/articles/cross-browser-widgets
// Feature test that the Safari workaround will work
// This is *not* a browser sniff! Browsers other
// than Safari will use the workaround if they
// have the necessary features. This is not a problem.
// Tested Safari 1.0, 1.2, 1.3, 2.0 and they all
// need the workaround and all return typeof 'object'
// for unset global.onclick property.
My event library worked around this using DOM0 event handlers. That is
a bunch of ugly code that I'd like to eliminate almost purely for
aesthetic reasons but actually the workaround could clobber an
existing DOM0 handler. Also having the workaround as the comment above
says requires an onunload event which messes with Firefox's caching
system, I think.
These old Safari browsers were auto updated and I doubt there are even
many 2.x users now anyway. Maybe less than 0.1% of web users have one
of these browsers.
I could ignore the problem and Safari 2.x- users just get some buggy
behavior. This doesn't seem good enough.
You could argue that the default behavior of following the link should
be acceptable. In fact, maybe you did argue that once. I don't like
this rationalization and where my scripts are used I don't always have
complete control (over business decisions.) Sometimes there are
"working in groups" compromises that I have to make to move on in life
and not make enemies while belaboring a point about graceful
degradation.
What I am willing to do is just put either the Safari 2.0.3- users or
even the whole Safari 2.x- users down the degradation path. For them
the event library just wouldn't be defined at all. Ideally they would
have the same user experience as IE5 or NN4 users get: a script-free
user experience. (Note this is much different than what I wrote in the
previous paragraph where the Safari users would see a mostly
JavaScript enabled experience and sometimes see a broken JavaScript
experience as they would only be partly degraded and event handlers
would be firing.)
So I need to identify either Safari 2.0.3- or Safari 2.x- browsers. I
don't think there is an acceptable direct test for the problem of a
click or double click not being preventDefault'ed. The direct test
would require simulating a click or double click and seeing if the
page refreshes. That is too disruptive. So I was thinking about using
multiple object inference for objects only old Safari browsers have
and that no one in their right mind would ever add to another browser.
Yes it is sniffing but it is the most robust kind of sniffing if
enough really exotic objects are tested that only ever existed in
Safari.
I just need to find the right set of objects to test and I've
procrastinated for a long time.
Peter