- From: Anne van Kesteren <notifications@github.com>
- Date: Sun, 23 Nov 2025 23:26:46 -0800
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/webidl/pull/1529/review/3498640943@github.com>
@annevk commented on this pull request.
I did an editorial pass.
> 1. Let |offset| be 0.
- 1. Let |length| be 0.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
- 1. Set |jsArrayBuffer| to |jsBufferSource|.\[[ViewedArrayBuffer]].
- 1. Set |offset| to |jsBufferSource|.\[[ByteOffset]].
- 1. Set |length| to |jsBufferSource|.\[[ByteLength]].
- 1. Otherwise:
- 1. Assert: |jsBufferSource| is an {{ArrayBuffer}} or
- {{SharedArrayBuffer}} object.
- 1. Set |length| to |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. Let |length| be |bufferSource|'s [=BufferSource/byte length=].
+ 1. If |bufferSource| is a [=buffer view type=] instance, then:
```suggestion
1. If |bufferSource| is a [=buffer view type=] instance:
```
> @@ -9316,15 +9312,40 @@ a reference to the same object that the IDL value represents.
1. Return |bytes|.
</div>
+<div algorithm>
+ The <dfn export for="ArrayBufferView">byte offset</dfn> of an {{ArrayBufferView}}
+ |view| is the value returned by the following steps:
+
+ 1. Let |jsView| be the result of [=converted to a JavaScript value|converting=] |view| to
+ a JavaScript value.
+ 1. If [$IsArrayBufferViewOutOfBounds$](|jsView|) is true, throw a {{TypeError}} exception.
```suggestion
1. If [$IsArrayBufferViewOutOfBounds$](|jsView|) is true, then throw a {{TypeError}} exception.
```
> <div algorithm>
The <dfn export for="BufferSource">byte length</dfn> of a [=buffer source type=] instance
|bufferSource| is the value returned by the following steps:
1. Let |jsBufferSource| be the result of [=converted to a JavaScript value|converting=]
|bufferSource| to a JavaScript value.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] internal slot, then return
- |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
```suggestion
1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=]:
```
> 1. Let |offset| be 0.
- 1. Let |length| be 0.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
- 1. Set |jsArrayBuffer| to |jsBufferSource|.\[[ViewedArrayBuffer]].
- 1. Set |offset| to |jsBufferSource|.\[[ByteOffset]].
- 1. Set |length| to |jsBufferSource|.\[[ByteLength]].
- 1. Otherwise:
- 1. Assert: |jsBufferSource| is an {{ArrayBuffer}} or
- {{SharedArrayBuffer}} object.
- 1. Set |length| to |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. Let |length| be |bufferSource|'s [=BufferSource/byte length=].
+ 1. If |bufferSource| is a [=buffer view type=] instance, then:
+ 1. Set |arrayBuffer| to |bufferSource|'s [=underlying buffer=].
+ 1. Set |offset| to |bufferSource|'s [=ArrayBufferView/byte offset=].
+ 1. Assert: |arrayBuffer| is an {{ArrayBuffer}} or {{SharedArrayBuffer}} object.
```suggestion
1. [=/Assert=]: |arrayBuffer| is an {{ArrayBuffer}} or {{SharedArrayBuffer}} object.
```
> <div algorithm>
The <dfn export for="BufferSource">byte length</dfn> of a [=buffer source type=] instance
|bufferSource| is the value returned by the following steps:
1. Let |jsBufferSource| be the result of [=converted to a JavaScript value|converting=]
|bufferSource| to a JavaScript value.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] internal slot, then return
- |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
+ 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
```suggestion
1. [=/Assert=]: |jsBufferSource| is a [=typed array type=] instance.
```
> <div algorithm>
The <dfn export for="BufferSource">byte length</dfn> of a [=buffer source type=] instance
|bufferSource| is the value returned by the following steps:
1. Let |jsBufferSource| be the result of [=converted to a JavaScript value|converting=]
|bufferSource| to a JavaScript value.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] internal slot, then return
- |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
+ 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
+ 1. Let |taRecord| be [$MakeTypedArrayWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. Return [$TypedArrayByteLength$](|taRecord|).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is a {{DataView}}.
```suggestion
1. [=/Assert=]: |jsBufferSource| is a {{DataView}}.
```
> <div algorithm>
The <dfn export for="BufferSource">byte length</dfn> of a [=buffer source type=] instance
|bufferSource| is the value returned by the following steps:
1. Let |jsBufferSource| be the result of [=converted to a JavaScript value|converting=]
|bufferSource| to a JavaScript value.
- 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] internal slot, then return
- |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
+ 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
+ 1. Let |taRecord| be [$MakeTypedArrayWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. Return [$TypedArrayByteLength$](|taRecord|).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is a {{DataView}}.
+ 1. Let |viewRecord| be [$MakeDataViewWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. If [$IsViewOutOfBounds$](|viewRecord|) is true, return 0.
```suggestion
1. If [$IsViewOutOfBounds$](|viewRecord|) is true, then return 0.
```
> - 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] internal slot, then return
- |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
+ 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
+ 1. Let |taRecord| be [$MakeTypedArrayWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. Return [$TypedArrayByteLength$](|taRecord|).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is a {{DataView}}.
+ 1. Let |viewRecord| be [$MakeDataViewWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. If [$IsViewOutOfBounds$](|viewRecord|) is true, return 0.
+ 1. Return [$GetViewByteLength$](|viewRecord|).
+ 1. Otherwise, if [$IsSharedArrayBuffer$](|jsBufferSource|) is true, then:
```suggestion
1. Otherwise, if [$IsSharedArrayBuffer$](|jsBufferSource|) is true:
```
> - |jsBufferSource|.\[[ByteLength]].
- 1. Return |jsBufferSource|.\[[ArrayBufferByteLength]].
+ 1. If |jsBufferSource| has a \[[ViewedArrayBuffer]] [=/internal slot=], then:
+ 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
+ 1. Let |taRecord| be [$MakeTypedArrayWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. Return [$TypedArrayByteLength$](|taRecord|).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is a {{DataView}}.
+ 1. Let |viewRecord| be [$MakeDataViewWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. If [$IsViewOutOfBounds$](|viewRecord|) is true, return 0.
+ 1. Return [$GetViewByteLength$](|viewRecord|).
+ 1. Otherwise, if [$IsSharedArrayBuffer$](|jsBufferSource|) is true, then:
+ 1. Assert: |jsBufferSource| is a {{SharedArrayBuffer}}.
```suggestion
1. [=/Assert=]: |jsBufferSource| is a {{SharedArrayBuffer}}.
```
> + 1. If |jsBufferSource| has a \[[TypedArrayName]] [=/internal slot=]:
+ 1. Assert: |jsBufferSource| is a [=typed array type=] instance.
+ 1. Let |taRecord| be [$MakeTypedArrayWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. Return [$TypedArrayByteLength$](|taRecord|).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is a {{DataView}}.
+ 1. Let |viewRecord| be [$MakeDataViewWithBufferWitnessRecord$](|jsBufferSource|,
+ Seq-Cst).
+ 1. If [$IsViewOutOfBounds$](|viewRecord|) is true, return 0.
+ 1. Return [$GetViewByteLength$](|viewRecord|).
+ 1. Otherwise, if [$IsSharedArrayBuffer$](|jsBufferSource|) is true, then:
+ 1. Assert: |jsBufferSource| is a {{SharedArrayBuffer}}.
+ 1. Return [$ArrayBufferByteLength$](|jsBufferSource|, Seq-Cst).
+ 1. Otherwise:
+ 1. Assert: |jsBufferSource| is an {{ArrayBuffer}}.
```suggestion
1. [=/Assert=]: |jsBufferSource| is an {{ArrayBuffer}}.
```
> @@ -9348,10 +9369,10 @@ a reference to the same object that the IDL value represents.
<dfn id=arraybuffer-write-startingoffset export for="ArrayBuffer/write,SharedArrayBuffer/write">|startingOffset|</dfn>
(default 0):
+ 1. Assert: |bytes|'s [=byte sequence/length=] ≤ |arrayBuffer|'s [=byte length=]
```suggestion
1. [=/Assert=]: |bytes|'s [=byte sequence/length=] ≤ |arrayBuffer|'s [=byte length=]
```
> @@ -9362,16 +9383,12 @@ a reference to the same object that the IDL value represents.
{{ArrayBufferView}} |view|, optionally given a
<dfn export for="ArrayBufferView/write">|startingOffset|</dfn> (default 0):
- 1. Let |jsView| be the result of [=converted to a JavaScript value|converting=] |view| to
- a JavaScript value.
- 1. Assert: |bytes|'s [=byte sequence/length=] ≤ |jsView|.\[[ByteLength]] −
+ 1. Assert: |bytes|'s [=byte sequence/length=] ≤ |view|'s [=byte length=] −
```suggestion
1. [=/Assert=]: |bytes|'s [=byte sequence/length=] ≤ |view|'s [=byte length=] −
```
> <l spec=ecmascript>{{TypeError}}</l>.
- 1. Let |arrayBufferData| be |jsArrayBuffer|.\[[ArrayBufferData]].
- 1. Let |arrayBufferByteLength| be |jsArrayBuffer|.\[[ArrayBufferByteLength]].
- 1. Perform [=?=] [$DetachArrayBuffer$](|jsArrayBuffer|).
- 1. If |targetRealm| is not given, let |targetRealm| be the [=current realm=].
- 1. Let |jsTransferred| be [=?=]
- [$AllocateArrayBuffer$](|targetRealm|.\[[Intrinsics]].\[[{{%ArrayBuffer%}}]], 0).
- 1. Set |jsTransferred|.\[[ArrayBufferData]] to |arrayBufferData|.
- 1. Set |jsTransferred|.\[[ArrayBufferByteLength]] to |arrayBufferByteLength|.
+ 1. If |preserveResizability| is true, then:
```suggestion
1. If |preserveResizability| is true:
```
> <l spec=ecmascript>{{TypeError}}</l>.
- 1. Let |arrayBufferData| be |jsArrayBuffer|.\[[ArrayBufferData]].
- 1. Let |arrayBufferByteLength| be |jsArrayBuffer|.\[[ArrayBufferByteLength]].
- 1. Perform [=?=] [$DetachArrayBuffer$](|jsArrayBuffer|).
- 1. If |targetRealm| is not given, let |targetRealm| be the [=current realm=].
- 1. Let |jsTransferred| be [=?=]
- [$AllocateArrayBuffer$](|targetRealm|.\[[Intrinsics]].\[[{{%ArrayBuffer%}}]], 0).
- 1. Set |jsTransferred|.\[[ArrayBufferData]] to |arrayBufferData|.
- 1. Set |jsTransferred|.\[[ArrayBufferByteLength]] to |arrayBufferByteLength|.
+ 1. If |preserveResizability| is true, then:
+ 1. Let |jsTransferred| be [=?=] [$ArrayBufferCopyAndDetach$](|jsArrayBuffer|, undefined,
+ Preserve-Resizability).
+ 1. Otherwise,
```suggestion
1. Otherwise:
```
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1529#pullrequestreview-3498640943
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/webidl/pull/1529/review/3498640943@github.com>
Received on Monday, 24 November 2025 07:26:50 UTC