Strategies for standardizing mistakes
mjs at apple.com
Thu Oct 15 11:29:31 PDT 2009
On Oct 15, 2009, at 10:54 AM, Mike Shaver wrote:
> 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");
Just as a minor point of technical correction - this will actually
alert "not IE" in Firefox because the right-hand sign of an assignment
is considered a detecting access. (Just tested to confirm.)
> 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?").
> es-discuss mailing list
> es-discuss at mozilla.org
More information about the es-discuss