diff --git a/boa_engine/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs index b4d59d1f4b..e36ddf7a7f 100644 --- a/boa_engine/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -128,7 +128,7 @@ impl ArrayBuffer { Ok(args .get_or_undefined(0) .as_object() - .map(|obj| obj.borrow().is_typed_array()) + .map(|obj| obj.borrow().has_viewed_array_buffer()) .unwrap_or_default() .into()) } diff --git a/boa_engine/src/object/mod.rs b/boa_engine/src/object/mod.rs index 9b33d425c4..206e7d2c10 100644 --- a/boa_engine/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -519,6 +519,23 @@ impl Object { } } + #[inline] + pub(crate) fn has_viewed_array_buffer(&self) -> bool { + self.is_typed_array() || self.is_data_view() + } + + /// Checks if it an `DataView` object. + #[inline] + pub fn is_data_view(&self) -> bool { + matches!( + self.data, + ObjectData { + kind: ObjectKind::DataView(_), + .. + } + ) + } + /// Checks if it an `ArrayBuffer` object. #[inline] pub fn is_array_buffer(&self) -> bool {