G
Garrett Smith
A colleague of mine recently informed me with the emphatic title:
"HTML5, CSS3, and omg finally AddEventListener in new IE9!"
With a link to:
http://ie.microsoft.com/testdrive/
And from the getgo, anyone who is not both stupid and ignorant would
notice some major problems there.
For example: Under "HTML 5" category is a link to "DOM Events" (where my
colleague had directed my attention). To most anyone who can use google
and read, DOM Events is not part of HTML 5, but a completely separate
specification. Apparently nobody at Microsoft can search the web and
read, which would explain why D3E is categorized under HTML 5.
I replied to my colleagues email, but then decided to post my replies
here. My response to that email below (I edited it up a bit to be less
obnoxious).
BEGIN EMAIL REPLY:
I have no doubt that they totally f**ked it up.
My first glance at the Events; the first thing you're directing me to:
http://ie.microsoft.com/testdrive/HTML5/13DOM_Events/Default.html
http://validator.w3.org/check?uri=h...(detect+automatically)&doctype=Inline&group=0
They are serving invalid html document, w/XHTML doctype, as content-type
"text/html". Documents served with XHTML doctype should be sent with an
xml content type header. Sending XHTML as text/html forces browsers to
error-correct. The document at the following URL explains well enough:
http://hixie.ch/advocacy/xhtml
So MS does not know html. This is news or what?
I reformatted their example code. They posted a mix of tabs spaces. I
reformatted it to use space indentation. Have a look:
| var addSummaryListeners = function () {
|
|
| // Call "showSummary" on mouseover
| addEventListener("mouseover", showSummary,
| false);
|
| // Call "hideSummary" on mouseout
| addEventListener("mouseout", showSummary,
| false);
| }
| }
| }
The first most obvious things are:
1) Why is the EventTarget the global object?
2) Do they think that global object implements MouseEvents?
3) Why are there three closing curly braces for the function?
4) Why is the ExpressionStatement, a FunctionExpression not terminated
by a semicolon?
5) What is "..." in the function body?
The answer to all of these questions can be explained by the fact that
Microsoft does not hire competent individuals.
The extra semicolons and "..." can be explained as a formatting errors.
Relying on ASI (automatic semicolon insertion) is a beginner mistake or
careless mistake; it can taken be a sign of being under qualified.
Suggesting that the global object implements MouseEvents is
demonstration of a nonstandard feature.
The #1 mistake in the example is that the example is used to support
claims support of DOM events but instead provides a proprietary
(non-standard) example of MouseEvents on the global object. Classic
Microsoft. Virtually every example on MSDN uses code that will function
only in MSIE, often using things such as IE's global scope polluter,
document.all, and usually invalid HTML.
The Consequences.
Javascript library authors will likely end up believing that the global
object implements MouseEvents and EventTarget and expecting those things
to work. At least, those will be used for IE-only sites.
Microsoft should hire competent individuals to write unit tests to
ensure that the APIs they are producing are standard, valid, and
functional in known modern browsers (at least including Safari 2, IE7,
FF2).
Microsoft gets acknowledgment for trying. Unfortunately the effort falls
short of being acceptable.
The rest of the code tends to be worse. For example, they attempt to
provide a "fallback" for IE8 that requires javascript:
| // should probably do something similar for
| //IE7 but it's a lot more work
| if (_isIE8) {
| var xhtmllinks =
| document.querySelectorAll("a.noIE8");
|
| for (var i = 0; i < xhtmllinks.length; ++i){
| xhtmllinks.removeAttribute("href");
| xhtmllinks.style.color = "#ccc";
| xhtmllinks.setAttribute("title",
| "This page does not work in "
| + "Internet Explorer 8");
| }
| }
This is the most absurd piece of code yet. The removal of the href
attribute is likely to not work cross browser. The concept of basing a
fallback strategy on javascript is a demonstration of misunderstanding
what a fallback is, which is also demonstrated that the fallback is
targeted specifically for IE8 and IE8 only. The author did seem to
recognize at least the significance of IE7, else he would not have
included the comment: "for IE7 it's a lot more work.").
There is also the message to the user, written in English, not
localized, and appearing directly in the source code.
This is the most absurd code I have seen in quite a long time.
END EMAIL REPLY.
"HTML5, CSS3, and omg finally AddEventListener in new IE9!"
With a link to:
http://ie.microsoft.com/testdrive/
And from the getgo, anyone who is not both stupid and ignorant would
notice some major problems there.
For example: Under "HTML 5" category is a link to "DOM Events" (where my
colleague had directed my attention). To most anyone who can use google
and read, DOM Events is not part of HTML 5, but a completely separate
specification. Apparently nobody at Microsoft can search the web and
read, which would explain why D3E is categorized under HTML 5.
I replied to my colleagues email, but then decided to post my replies
here. My response to that email below (I edited it up a bit to be less
obnoxious).
BEGIN EMAIL REPLY:
I have no doubt that they totally f**ked it up.
My first glance at the Events; the first thing you're directing me to:
http://ie.microsoft.com/testdrive/HTML5/13DOM_Events/Default.html
http://validator.w3.org/check?uri=h...(detect+automatically)&doctype=Inline&group=0
They are serving invalid html document, w/XHTML doctype, as content-type
"text/html". Documents served with XHTML doctype should be sent with an
xml content type header. Sending XHTML as text/html forces browsers to
error-correct. The document at the following URL explains well enough:
http://hixie.ch/advocacy/xhtml
So MS does not know html. This is news or what?
I reformatted their example code. They posted a mix of tabs spaces. I
reformatted it to use space indentation. Have a look:
| var addSummaryListeners = function () {
|
|
| // Call "showSummary" on mouseover
| addEventListener("mouseover", showSummary,
| false);
|
| // Call "hideSummary" on mouseout
| addEventListener("mouseout", showSummary,
| false);
| }
| }
| }
The first most obvious things are:
1) Why is the EventTarget the global object?
2) Do they think that global object implements MouseEvents?
3) Why are there three closing curly braces for the function?
4) Why is the ExpressionStatement, a FunctionExpression not terminated
by a semicolon?
5) What is "..." in the function body?
The answer to all of these questions can be explained by the fact that
Microsoft does not hire competent individuals.
The extra semicolons and "..." can be explained as a formatting errors.
Relying on ASI (automatic semicolon insertion) is a beginner mistake or
careless mistake; it can taken be a sign of being under qualified.
Suggesting that the global object implements MouseEvents is
demonstration of a nonstandard feature.
The #1 mistake in the example is that the example is used to support
claims support of DOM events but instead provides a proprietary
(non-standard) example of MouseEvents on the global object. Classic
Microsoft. Virtually every example on MSDN uses code that will function
only in MSIE, often using things such as IE's global scope polluter,
document.all, and usually invalid HTML.
The Consequences.
Javascript library authors will likely end up believing that the global
object implements MouseEvents and EventTarget and expecting those things
to work. At least, those will be used for IE-only sites.
Microsoft should hire competent individuals to write unit tests to
ensure that the APIs they are producing are standard, valid, and
functional in known modern browsers (at least including Safari 2, IE7,
FF2).
Microsoft gets acknowledgment for trying. Unfortunately the effort falls
short of being acceptable.
The rest of the code tends to be worse. For example, they attempt to
provide a "fallback" for IE8 that requires javascript:
| // should probably do something similar for
| //IE7 but it's a lot more work
| if (_isIE8) {
| var xhtmllinks =
| document.querySelectorAll("a.noIE8");
|
| for (var i = 0; i < xhtmllinks.length; ++i){
| xhtmllinks.removeAttribute("href");
| xhtmllinks.style.color = "#ccc";
| xhtmllinks.setAttribute("title",
| "This page does not work in "
| + "Internet Explorer 8");
| }
| }
This is the most absurd piece of code yet. The removal of the href
attribute is likely to not work cross browser. The concept of basing a
fallback strategy on javascript is a demonstration of misunderstanding
what a fallback is, which is also demonstrated that the fallback is
targeted specifically for IE8 and IE8 only. The author did seem to
recognize at least the significance of IE7, else he would not have
included the comment: "for IE7 it's a lot more work.").
There is also the message to the user, written in English, not
localized, and appearing directly in the source code.
This is the most absurd code I have seen in quite a long time.
END EMAIL REPLY.