W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2010

[whatwg] Should window.name be [Replaceable]?

From: Joseph Pecoraro <pecoraro@apple.com>
Date: Sun, 4 Jul 2010 21:05:49 -0700
Message-ID: <A9056ACD-3716-4E6A-9E79-76D7CB1D56FB@apple.com>
Should window.name be [Replaceable]?

There are a number of "[Replaceable]" [1] properties on the window
object. However, "window.name" is not marked as such [2]. Not being
marked as replaceable means that if authors use a global variable
named "name" it will be coerced into a string. For many this causes
confusion. It seems some browsers have opted to make it replaceable.

Test case. You can test your browser at [3].

    (function() {
        var arr = [];
        arr.push( typeof window.name );
        window.name = 1;
        arr.push( typeof window.name );
        name = 1;
         // "number" if [Replaceable], "string" otherwise
        arr.push( typeof window.name );
        alert( arr );
    })();

Browser Results:

    - Safari 5 / WebKit Nightly and Chrome 5
      NOT [Replaceable], printing "string,string,string" 
    
    - Firefox 3.6.3 / 3.7a5 and Opera 10.5.3 / 10.6
      [Replaceable], printing  "string,string,number"

    - I didn't have access to IE to test. I'd appreciate
      someone giving it a shot to see how they act.

Has there been discussion on this in the past? I searched and
didn't find any discussion.

- Joe

[1]: http://dev.w3.org/2006/webapi/WebIDL/#Replaceable
[2]: http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#the-window-object
[3]: https://bug-19967-attachments.webkit.org/attachment.cgi?id=60491
Received on Sunday, 4 July 2010 21:05:49 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:24 UTC