Mootools
Ok, so the moral of the story here is this: Don’t determine what version a browser is based on the methods available. I don’t think I was clear about this in the past because I’ve never implemented it myself. What you’re supposed to do is detect whether or not the native functionality exists, if it does, then use it. If not, then either recreate it the functionality or raise an exception (unsupported).
I always thought testing the capability of the browser (instead of using browser version strings) meant conditions like this all over the place before you used the function:
If (window.fancyFunction) {
window.fancyFunction(
} else {
doSomethingLikeFancyFunction…
}
But no, what is really done is only done once at the library load:
If (window.fancyFunction) {
window.fancyFunction(
} else {
// declare it for use later, now your code doesn’t care what the browser supports
window.fancyFunction() = function() {
doSomethingLikeFancyFunction…
}
}
Of course, this applies to any dynamic language. This might even be considered some form of early binding dependency injection, I dunno. Anyway, time for J’s demo.
