Page MenuHomePhabricator

Internet Explorer should be added to javascript browser detection globals
Closed, DeclinedPublic

Description

As wikibits.js already does browser detection and stores its findings where any JavaScript extension besides just wikibits itself can us it, it seems logical that msie should also be detected. There are surely many extensions doing their own ad hoc msie detection in a variety of ways. Extending the wikibits.js browser detection to cover more browsers in one central place must be a good thing. It already detects the following so why not add more?

is_ff2_win
is_ff2_x11
is_gecko
is_khtml
is_opera
is_opera_95
is_opera_preseven
is_opera_seven
is_safari


Version: unspecified
Severity: enhancement

Details

Reference
bz12766

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:03 PM
bzimport set Reference to bz12766.
bzimport added a subscriber: Unknown Object (MLST).

It would actually probably be best to allow extending Site or Extension JS to use special IE only JS pages. As in, those through IE's conditional comments. Or have those scripts automatically add the is_ie and is_ie_?? variables to get the best compatibility.

herd wrote:

Why not simply add belo the other conditionals:

<!--[if IE]><script type="text/javascript">var is_msie = true;</script><![endif]-->

And anything more detailed than that can check the browser agent version.
Although in wikibits.js, should be something like:

if(!window.is_msie) var is_msie = false;

Then you can simply check if(is_msie) or if(!is_msie).

Maybe a little more than that... like a is_msie_7, because there is a lot new in IE 7 which will break in previous versions. Same for 6 because the 5 and olders don't have as much as it.

So...

is_msie
is_msie_presix
is_msie_six
is_msie_postsix

(In reply to comment #3)

Maybe a little more than that... like a is_msie_7, because there is a lot new
in IE 7 which will break in previous versions. Same for 6 because the 5 and
olders don't have as much as it.

So...

is_msie
is_msie_presix
is_msie_six
is_msie_postsix

Do we really have to repeat the mistakes of the past? Globals are bad because they can't be lazy-initialised. This is true in both JS and PHP.

If you need the result of a computation, you should call a function to get it, not run the computation on every request and make the result available via a global variable.