Re: [webidl] DOMString

On Apr 21, 2009, at 1:38 AM, Anne van Kesteren wrote:

> If something takes a DOMString as value is it clearly defined what  
> happens if the toString algorithm throws or returns a non-DOMString?  
> I haven't been able to find descriptions for that in the Web IDL  
> specification. E.g.
>
> obj  = { toString:function() { throw("haha") } }
> obj2 = { toString:function() { return 1 } }
> obj3 = { toString:function() { return obj } }

The [[ToString]] algorithm is defined in ECMAScript (Section 9.8,  
[1]), the specified behaviour would result in [[ToString]] on obj2  
producing the string "1";  [[ToString]] on obj3 will result in a  
TypeError, as [[DefaultValue]] will produce a non-primitive type  
(Section 9.1, [1])

I would assume that the exception will be propagated to the runtime,  
but it should be stated.

--Oliver

[1] ECMA262-5 RC http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf

>
>
> -- 
> Anne van Kesteren
> http://annevankesteren.nl/
>

Received on Tuesday, 21 April 2009 08:56:08 UTC