Browse Source

BufferSource: Align with TypedArray spec; don't modify ArrayBufferViews (#10475)

* Align with TypedArray spec: don't modify ArrayBufferViews

* js.lib.BufferSource: add common field byteLength
George Corney 3 years ago
parent
commit
3300dd1de8
1 changed files with 8 additions and 4 deletions
  1. 8 4
      std/js/lib/BufferSource.hx

+ 8 - 4
std/js/lib/BufferSource.hx

@@ -34,9 +34,13 @@ import haxe.extern.EitherType;
 
 
 	@see <https://developer.mozilla.org/en-US/docs/Web/API/BufferSource>
 	@see <https://developer.mozilla.org/en-US/docs/Web/API/BufferSource>
  */
  */
-@:forward
-abstract BufferSource(ArrayBuffer) to ArrayBuffer from ArrayBuffer {
-	@:from public static inline function fromBufferView(view:ArrayBufferView) {
-		return cast view.buffer;
+abstract BufferSource(Dynamic) from ArrayBuffer from ArrayBufferView {
+	
+	public var byteLength(get, never): Int;
+
+	@:pure
+	inline function get_byteLength(): Int {
+		return this.byteLength;
 	}
 	}
+	
 }
 }