Quantcast
Channel: AllInGeek.com » java
Viewing all articles
Browse latest Browse all 10

GWT can be Magical

$
0
0

The person or people responsible for the following must either be much more knowledgeable than I about JavaScript if statements, or simply more sinister. While pretty compiling one of my GWT modules today, I decided to take a peek at the generated source. As I was scrolling through the the module, my coworker pointed something out. This is what I found:

    if (function(){
      return ua.indexOf('msie') != -1 && $doc_0.documentMode >= 8;
    }
    ())
      return 'ie8';
    if (function(){
      var result = /msie ([0-9]+)\.([0-9]+)/.exec(ua);
      if (result && result.length == 3)
        return makeVersion(result) >= 6000;
    }
    ())
      return 'ie6';

After a few moments with a baffled expression on my face, he made the announcement that he would henceforth be performing all conditional expression evaluations within anonymous functions.  I couldn’t agree more.  I mean, what better way to mess with the person who will be reviewing, or worse yet, supporting your code?  Now, I see what they did there in the IE 6 test.  Quite the cleaver hack. Kinda. But to use the same mechanism for the IE8 test is just plain strange.  Does anyone have a reason why this pattern might be desirable? I’ve since taken an oath to refrain from examining the generated crap, no matter how pretty it may proclaim to be, until I’ve come a bit further in my GWT mastery.


Viewing all articles
Browse latest Browse all 10

Trending Articles