[webkit-dev] Optional parameter in IDL and undefined JS value
jianli at chromium.org
Thu Apr 21 00:29:35 PDT 2011
It seems that we're doing the right thing for Array.slice in WebKit in order
to be consistent with ECMAScript 5, 220.127.116.11. Since Blob.slice in File API
is following the same route, we probably want to fix the handling in
Blob.slice and keep other DOM methods as they're now.
On Thu, Apr 21, 2011 at 12:14 AM, Jian Li <jianli at chromium.org> wrote:
> The current File API spec says that:
> If the end parameter is not provided (undefined), let relativeEnd be
> This seems to indicate that passing undefined as end parameter is same as
> omitting it. Per the latest discussion on public-webapps, we're in the
> process of making it be more like Array.slice. I will also ping the spec
> author about this issue.
> Unfortunately we have inconsistency between Array.slice and other DOM
> methods, in terms of handling undefined parameter value in WebKit. We also
> have inconsistency among different browser vendors for interpreting
> Array.slice(start, undefined).
> On Wed, Apr 20, 2011 at 11:17 PM, Cameron McCormack <cam at mcc.id.au> wrote:
>> Jian Li:
>> > > I am referring to Blob.slice(start, end) that mimics Array.slice.
>> Where in
>> > > WebIDL has this behavior defined? Sorry I can't find it in the spec.
>> > >
>> > > For Array.slice(start, end), both Safari and Chrome treat passing
>> > > as omitted parameter, while Firefox and IE treat passing undefined as
>> Ryosuke Niwa:
>> > Doesn't that mean the current behavior (i.e. treating undefined as 0) is
>> > correct since that's what other browsers do?
>> The File API spec currently says:
>> Blob slice(in optional long long start,
>> in optional long long end,
>> in optional DOMString contentType);
>> and Web IDL says that if you call
>> blob.slice(10, undefined);
>> then this is calling the function with two arguments, where the second
>> argument will be converted to 0 due to how the conversion of JS
>> undefined to an IDL long long value is defined. This is not the same as
>> Whenever some optional arguments are omitted, the prose for the
>> definition of the operation defines what that means; it’s not
>> automatically “convert from undefined”.
>> There is no way in Web IDL to state that when undefined is passed as an
>> argument explicitly that it is handled differently from the rules in
>> http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping (although the
>> authors of the File API spec could include this additional requirement
>> in prose, overriding Web IDL, if they wanted).
>> Cameron McCormack ≝ http://mcc.id.au/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev