Skip to content

Commit

Permalink
Throw, instead of assert, for transferring detached ArrayBuffers
Browse files Browse the repository at this point in the history
This makes the algorithm more user-friendly, as this is generally the desired behavior, and the algorithm can already throw for other reasons so callers are expected to handle that.
  • Loading branch information
domenic committed Jul 19, 2024
1 parent d6927d5 commit 155ae10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -9075,7 +9075,8 @@ a reference to the same object that the IDL value represents.

1. Let |jsArrayBuffer| be the result of [=converted to a JavaScript value|converting=]
|arrayBuffer| to a JavaScript value.
1. Assert: [$IsDetachedBuffer$](|jsArrayBuffer|) is false.
1. If [$IsDetachedBuffer$](|jsArrayBuffer|) is false, then [=JavaScript/throw=] a
<l spec=ecmascript>{{TypeError}}</l>.
1. Let |arrayBufferData| be |jsArrayBuffer|.\[[ArrayBufferData]].
1. Let |arrayBufferByteLength| be |jsArrayBuffer|.\[[ArrayBufferByteLength]].
1. Perform [=?=] [$DetachArrayBuffer$](|jsArrayBuffer|).
Expand All @@ -9088,7 +9089,8 @@ a reference to the same object that the IDL value represents.
value of type {{ArrayBuffer}}.

<p class="note">This will throw an exception under the same circumstances as
[=ArrayBuffer/detaching=].
[=ArrayBuffer/detaching=], and also for {{ArrayBuffer}}s that are already
[=BufferSource/detached=].
</div>

<h4 id="js-frozen-array" oldids="es-frozen-array">Frozen arrays — FrozenArray&lt;|T|&gt;</h4>
Expand Down

0 comments on commit 155ae10

Please sign in to comment.