feat(ext/web): use ArrayBuffer.was_detached() (#16307)

This PR adds a way to reliably check if an ArrayBuffer was detached
This commit is contained in:
Marcos Casagrande 2022-10-25 14:22:37 +02:00 committed by GitHub
parent a189c5393e
commit 34fb380ed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 26 deletions

View file

@ -193,7 +193,13 @@
* @returns {boolean}
*/
function isDetachedBuffer(O) {
return ReflectHas(O, isFakeDetached);
if (O.byteLength !== 0) {
return false;
}
// TODO(marcosc90) remove isFakeDetached once transferArrayBuffer
// actually detaches the buffer
return ReflectHas(O, isFakeDetached) ||
core.ops.op_arraybuffer_was_detached(O);
}
/**