W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: [whatwg] WebIDL and HTML5

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Mon, 25 Aug 2008 11:44:42 -0700
Message-ID: <c9e12660808251144i6f4b47d5o2fea2526c7e193d5@mail.gmail.com>
To: "Boris Zbarsky" <bzbarsky@mit.edu>
Cc: "Web Applications Working Group WG" <public-webapps@w3.org>

On Mon, Aug 25, 2008 at 11:28 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> Garrett Smith wrote:
>> window.open();
> Which should be equivalent to window.open(undefined) (and isn't in some
> UAs), right?
> What should window.open(null) do?
>> If the first argument is null or undefined or the empty string, no uri
>> is loaded and an blank/empty window is displayed.
> This is not the case in Firefox, Opera, or Safari.  Safari and Firefox treat
> null as "null".  Opera treats it as "".  Opera treats undefined as "", while
> Safari and Firefox treat it as "undefined".
> This is for window.open's first argument.
>> There seems to be no mapping though Ian has requested documenting such
>> mapping.
> No mapping of what?  ""+null is "null".  ""+undefined is "undefined".

The addition operator results in concatenation when either operand is
a string. This results in a calls to the internal ToString, which is
what I'm suggesting should be the general rule.

> Those
> are basically what Firefox and Safari do. That doesn't seem like the right
> thing to do here, necessarily.

I agree that loading path + '/null' or path + 'undefined' is not
desirable. Any application that relies on this is already broken,
arguably, because, contrary to your observations, safari first checks
to see if the argument is null or undefined or the empty string, and,
if that is true, then no uri is loaded. Example:

<html lang="en">
<a href="javascript:void(window.open());">open()</a>
<a href="javascript:void(window.open(null));">open(null)</a>
<a href="javascript:void(window.open(undefined));">open(undefined)</a>
<a href="javascript:void(window.open(0));">open(0)</a>

Result in Safari:

 window.open(0), loads "can't find that page".
 all others load blank window

Result in Firefox:
 open() open('') open blank window
 all others load "can't find that page"

Ian and others, you may use this and any other test case I post up.

>> Are there other examples for "if the argument is null or undefined..."?
> Sure.  A lot of the namespace-relatd DOM methods, as well as all sorts of
> DOM0 stuff.
>> There are probably others but I can't think of them. I think the
>> majority of the time that strings will want to go to ToString,
>> booleans will want to go to ToBoolean.
> That can be the default, perhaps.  But I suspect usually null should become
> "", not "null".


> -Boris
Received on Monday, 25 August 2008 18:45:17 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:11 UTC