W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2011

[Bug 12798] Default to [TreatNullAs=EmptyString]

From: <bugzilla@jessica.w3.org>
Date: Mon, 13 Jun 2011 21:14:21 +0000
To: public-script-coord@w3.org
Message-Id: <E1QWESj-0006G5-MV@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=12798

Allen Wirfs-Brock <allen@wirfs-brock.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |allen@wirfs-brock.com

--- Comment #10 from Allen Wirfs-Brock <allen@wirfs-brock.com> 2011-06-13 21:14:20 UTC ---
(In reply to comment #8)
> But this kind of common API doesn't magically convert null to "null".
> 
> var o = {
>   _a : "foo",
>   setA: function(v) {
>     this._a = v;
>   },
>   getA: function(v) {
>     return this._a;
>   }
> }
> 
> var value = null;
> o.setA(value);
> alert(value == o.getA());
> 
> So, I'm not sure "And it is what's most consistent with other JS APIs. "
> argument really holds.

The above setA method doesn't do any conversion so it simply stores whatever
was passed as the v argument.  If a JavaScript programmer wanted to enforce
that _a was a string they would most likely code it as:

   setA: function(v) {
     this._a = String(v);
   },

This String conversion is defined by ECMAScript in terms of ToString (section
9.8) which converts null to "null" and undefined to "undefined".

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Monday, 13 June 2011 21:14:23 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:03 UTC