document.all is a non-primitive object in the DOM that is falsy.
For example, this code doesn\'t do anything:
if (document.all) {
al
There is now an [[IsHTMLDDA]] internal slot for objects:
An [[IsHTMLDDA]] internal slot may exist on implementation-defined objects. Objects with an [[IsHTMLDDA]] internal slot behave like
undefinedin the ToBoolean and Abstract Equality Comparison abstract operations and when used as an operand for thetypeofoperator.
The HTML Standard has also been updated to add that internal slot for objects that implement the HTMLAllCollection interface:
Objects that implement the HTMLAllCollection interface are legacy platform objects with an additonal [[Call]] internal method described in the section below. They also have an [[IsHTMLDDA]] internal slot.
The reason for this madness is specified in this note in the HTML Standard:
These special behaviors are motivated by a desire for compatibility with two classes of legacy content: one that uses the presence of
document.allas a way to detect legacy user agents, and one that only supports those legacy user agents and uses thedocument.allobject without testing for its presence first.
So basically the standard wants to be compatible with these two types of code:
Code that checks if it is running inside Internet Explorer to use its non-standard features, like document.all and Activex;
if (document.all) {
useActiveXStuff();
}
Code that assumes it's running inside Internet Explorer and uses document.all.
document.all["my-button"].onclick = function () {
alert("hi");
};