Strategies for standardizing mistakes
mike.shaver at gmail.com
Thu Oct 15 10:54:06 PDT 2009
On Thu, Oct 15, 2009 at 1:47 PM, Allen Wirfs-Brock
<Allen.Wirfs-Brock at microsoft.com> wrote:
> Is the Mozilla document.all optimization contingent upon the occurrence of the text "document.all"?
No, but it's contingent on the property lookup being the
truthyness-testing-expression. (I wouldn't call it an optimization;
if anything it adds some cost to certain paths.)
> What happens for:
> var docAll = document.all;
> if (docAll) alert("IE"); else alert("not IE");
var doc = document;
if (doc.all) alert("IE"); else alert("not IE");
It was something that was intentionally targetted at the common case
of the simple feature test, which is almost always "document.all".
This is done by the host object implementation, which is given access
to limited context ("is this access one that's being used to detect
the presence of a property, versus fetching the value?").
More information about the es-discuss