archives

« Bugzilla Issues Index

#4052 — 22.2.3.26 %TypedArray%.prototype.subarray: Use standard array index conversion+validation


22.2.3.26 %TypedArray%.prototype.subarray( [ begin [ , end ] ] )

%TypedArray%.prototype.subarray should use the same relative array index processing steps as used everywhere else. That means:


Change steps 7-10 to:

> Let relativeBegin be ToInteger(begin).
> ReturnIfAbrupt(relativeBegin).
> If relativeBegin < 0, let beginIndex be max((srcLength + relativeBegin), 0); else let beginIndex be min(relativeBegin, srcLength).



Change steps 11-15 to:

> If end is undefined, let relativeEnd be srcLength; else let relativeEnd be ToInteger(end).
> ReturnIfAbrupt(relativeEnd).
> If relativeEnd < 0, let endIndex be max((srcLength + relativeEnd), 0); else let endIndex be min(relativeEnd, srcLength).



And finally steps 16-17 to:
> Let newLength be max(endIndex - beginIndex, 0).


fixed in rev35 editor's draft


fixed in rev35