OK Dave, I take this points and didn't realize that browser detection was quite so unreliable. I also didn't realize that you could test for whether a browser supports something as minor as a particular pseudo-selector. So I'm gonna change my request to this:
In the next incarnation of jQuery docs, could we please change the $.browser docs to reflect something similar to what Dave has said here? Say that the browser detection is actually unreliable as browsers can and do lie about their model and version, and plugins change browser version strings too, and also emphasize that you can test for most things (eg. support for even individual CSS pseudo- selectors) so you shouldn't need it. Also point to various docs on how to test for various things that you may wish to test for, because I had to say I had no idea you could test for that. :-) Finally, I would suggest that even if $.browser is removed someday, these docs I'm suggesting stick around forever, just to tell people how they can achieve what they want instead without using (unreliable) browser version detection. Sooo... Could we at least change the docs in this way please? :-) Best regards, Jeremy Morton (Jez) On Oct 29, 5:14 pm, Dave Methvin <dave.meth...@gmail.com> wrote: > jQuery is not trying to stop you from detecting browsers, rendering > engines, and/or features any way you'd like in your own code. It's > just telling you to avoid the use of $.browser. jQuery core no longer > uses $.browser internally because it was not reliable and it's > impossible to test. > > > The suggestion was that the jQuery documentation be > > reworded so that $.browser not be called 'Deprecated', > > but that its usage perhaps be discouraged. > > Take a look athttp://dev.jquery.com/ticket/2661. What better way to > discourage its use than to have it return bad information? ;-) If > $.browser remains in jQuery, people expect it to be "correct" for > their definition of correct. Perhaps another round of patches in 1.4 > can make it work well enough that there won't be tons of additional > bugs reported against it, but I kind of doubt it. If it can't be fixed > then I think it *should* be removed. > > You could argue that $.browser should use feature detection to guess > browsers instead of userAgent, but that just opens a different can of > worms. Considerhttp://dev.jquery.com/ticket/5391. If Chrome and > Safari essentially use the same core engine, should they be treated as > a single browser or as different browsers? To answer that, you need to > know if $.browser users are trying to detect the browser brand name, > the browser rendering engine, or infer particular browser capabilities > based on their own experimental observations. > > These dilemmas go away if you use feature detection or conditional > comments instead of $.browser, because *you* know what you were really > trying to get at. Or, craft your own detection based on the presence a > feature you think is a good proxy for the feature you can't detect > directly. > > > For instance I'm developing a webpage and I happen to know > > that IE7 doesn't support the 'before' or 'after' pseudo selectors... > > It seems like it could be feature-detected with a small load-time test > case with an element and some CSS to determine whether those pseudo > selectors work. Or, just use conditional comments in your code if it's > really IE-specific. -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.