Re: typeof document.all

On Oct 13, 2009, at 12:20 PM, Anne van Kesteren wrote:

> On Tue, 13 Oct 2009 20:58:57 +0200, Brendan Eich  
> <brendan@mozilla.org> wrote:
>> But according to bugs I've cited, see
>>
>> https://bugzilla.mozilla.org/show_bug.cgi?id=253150#c4
>> https://bugzilla.mozilla.org/show_bug.cgi?id=253150#c12
>> https://bugzilla.mozilla.org/attachment.cgi?id=154617
>>
>> it was not, and by default we presume is not, web-compatible.
>>
>> Indeed Google codesearch discloses:
>>
>> http://www.google.com/codesearch?hl=en&lr=&q=lang%3Ajavascript+%22.all+%3D%3D+undefined%22&sbtn=Search
>> http://www.google.com/codesearch?hl=en&lr=&q=lang%3Ajavascript+%22.all+!%3D+undefined%22&sbtn=Search
>> http://www.google.com/codesearch?hl=en&lr=&q=lang%3Ajavascript+%22.all+%3D%3D+null%22&sbtn=Search
>> http://www.google.com/codesearch?hl=en&lr=&q=lang%3Ajavascript+%22.all+!%3D+null%22&sbtn=Search
>>
>> So I don't think what you describe, if that's all Opera does, is  
>> sufficient, because false != null and false != undefined.
>
> I quickly skimmed through these and it seems most have something  
> special for Opera, are part of a comment, or are part of the Gecko  
> codebase, or something to that effect.

http://www.google.com/codesearch/p?hl=en&sa=N&cd=2&ct=rc#m6yMHImV59o/ 
XoopsModules/content/trunk/js/content.js&q=lang:javascript%20%22.all 
%20!%3D%20undefined%22

There are others like that. I don't know if it works on Opera due to  
some predicate condition in the control flow, though.


> Anyway, yeah, maybe we should be more like WebKit. Good reason to  
> get this all defined :-)


I agree we need some specification, the question is how much. You have  
an object that converts to false in boolean contexts, and of course it  
masquerades as undefined to typeof. But undefined converts to false  
and compares == (not ===) null. You might just need to change a false  
to undefined, and you win.

/be

Received on Tuesday, 13 October 2009 20:51:04 UTC