real *nix devs don’t test in IE

Over at basket.kde.org they are understandably Windows-averse. I guess their website is not exactly targeted at IE users, but even so some cross-browser testing would uncover bugs and errors in their JS. Snippet:

    // Cross-browser implementation of element.addEventListener()
    function addEventListener(element, type, expression, bubbling) {
     bubbling = bubbling || false;
     if (window.addEventListener) { // Standard
      element.addEventListener(type, expression, bubbling);
      return true;
     } else if (window.attachEvent) { // IE
      element.attachEvent('on' + type, expression);
      return true;
     } else return false;
    }

Whoever wrote that obviously is confused about event bubbling versus event capturing (luckily it defaults to a sensible false!) but the main problem with this code is the line

if (window.addEventListener) { // Standard

Um, no, what you are seeing there is not the W3C standardised window.addEventListener1. You're actually checking for the existence of this very function – the one we're inside when we hit that statement. Naturally IE chokes on the next line and no event handlers are added. (If you ask, it should read if(element.addEventListener).)

So – a slick, good-looking production site that wasn't tested with IE – what a rarity! :p

Edit – note 1: well, actually W3C didn't specify addEventListener for window in the first place, it remains a Gecko extension like I've complained about earlier so the comment "// Standard" is doubly wrong..

Advertisements

6 thoughts on “real *nix devs don’t test in IE

  1. and in opera, I can't get the top menu to work.EDIT: and if you hover over the feature screenshots, the magnified version that should pop up right where the mouse is actually appears at the very bottom of the page. Too bad if that part is not shown on the screen at the moment.Hope the program works better than their site.

  2. Hey thanks WildEnte, I didn't notice the top menu being broken. Looks like a CSS issue since it works if you turn styles off. I've filed it as bug 252843.The feature screenshots problem is what I actually was investigating. The site tries to position the screenshots by reading "x" and "y" properties from the IMG element you hover. I don't know why IMG elements (only?!) have .x and .y in Firefox, it looks like a Netscape 4 feature they've kept for some reason..?

  3. JavaScript: The World's Most Misunderstood Programming LanguageIt would have helped in this case if the global object had a more accurate name. It isn't apparent to beginners that objects created in the global namespace are added as properties to an object named "window".

  4. Originally posted by WildEnte:

    and in opera, I can't get the top menu to work.

    Same issue as wordpress. Floated links with big margin-bottom.

  5. Basically treating IE's event-model as a drop-in replacement for w3c's event-model is dead wrong. This approach will only work for very simple cases, else you will soon fall prey to the many disadvantages of IE's model – the lack of proper scoping for the executioncontext of the handler being one of them.Also note that IE/Mac doesn't support either addEventListener or attachEvent

  6. Oh the shame. I read it 3 times and then gave up looking for the IE bug (I got the bubbling one). As soon as I read your comments, I realised the function name. What can I say? You know the more you read something, the more you don't look at what you're reading, take it from someone whose job involves proof reading. Can't see the wood for the trees. :faint:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s