Closed tomgrohl closed 13 years ago
This test won't save much processing to the browser and with or without the test, the hook will simply not work. But it won't break anything. So it's not really needed.
I thought that but a test I did gives me an error saying that cssHooks is undefined ( in firefox and chrome) and object expected ( in IE ).
By the looks of it, it may be best to use them, that way it would avoid throwing any errors.
Oh, of course. On the other hand this can be a good clue that something is wrong with the jQuery version...
Instead of failing silently you will see that cssHooks is missing somewhere, I mean.
Ah ok. Maybe a check is need before hand then. Something like:
if( !$.cssHooks ) { $.error("The version of jQuery you are using doesn't support cssHooks"); }
Might be good to have in.
To prevent the error of assigning to a property of undefined I'd say that yeah, the check should be performed.
It is not a common practice to do this kind of things in jQuery plugins. You should rather indicate in the source code of your file that the plugin depends on jQuery 1.4.3+, see skeleton.js for an example: https://github.com/brandonaaron/jquery-cssHooks/blob/master/skeleton.js
An error will be thrown anyway if jQuery.cssHooks is not defined, and it should not take long for the developer to find out what the problem is.
Yeah your right. Developers would be used to seeing that kind of error so they should be able to find out what the problem is with ease.
I'll update my cssHooks and remove this check and add comments.
In the cssHooks I wrote I check that the browsers supports the feature to be used ( border radius, border image..), but I also check to see if $.cssHooks exists to avoid errors when trying to use it with older versions of jQuery.
Wasn't sure if this was needed though, any thoughts?