- From: Maciej Stachowiak <mjs@apple.com>
- Date: Thu, 15 Oct 2009 11:29:31 -0700
- To: Mike Shaver <mike.shaver@gmail.com>
- Cc: Allen Wirfs-Brock <Allen.Wirfs-Brock@microsoft.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss Steen <es-discuss@mozilla.org>
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@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" 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?"). > > Mike > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss
Received on Thursday, 15 October 2009 18:37:12 UTC