W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2009

Re: Strategies for standardizing mistakes

From: Mike Shaver <mike.shaver@gmail.com>
Date: Thu, 15 Oct 2009 13:54:06 -0400
Message-ID: <cc092ba00910151054x30770ac7uea0294f7acffc1b1@mail.gmail.com>
To: Allen Wirfs-Brock <Allen.Wirfs-Brock@microsoft.com>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss Steen <es-discuss@mozilla.org>
On Thu, Oct 15, 2009 at 1:47 PM, Allen Wirfs-Brock
<Allen.Wirfs-Brock@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");

"IE"

var doc = document;
if (doc.all) alert("IE"); else alert("not IE");

"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?").

Mike
Received on Thursday, 15 October 2009 17:54:40 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:02 UTC