archives

« Bugzilla Issues Index

#2023 — 22.2.2.4, %TypedArray%[@@create](): TypedArrays no longer subclassable out-of-the-box


TypedArray constructors are no longer subclassable out of the box after the rev16 changes, because subclasses of concrete TypedArray constructor (e.g. `class MyInt8Array extends Int8Array`) do not have the [[TypedArrayConstructor]] internal data property. This limitation should probably be noted in the 22.2.4 preamble.

Correct way to subclass a concrete TypedArray constructor:
---
class MyInt8Array extends Int8Array {
static [Symbol.create]() {
return Int8Array[Symbol.create].call(Int8Array);
}
}
---


Duh, "correct way" should also include fixing the [[Prototype]]:
---
static [Symbol.create]() {
return Object.setPrototypeOf(Int8Array[Symbol.create].call(Int8Array), this.prototype);
}
---


You're correct, but it wasn't my intent to require this manually effort to create subclasses. I will have to do s0ome rework on the Typed Array spec. To make this work.

It will probably mean defining a unique @@create method for each built-in Typed Array constructor


(In reply to comment #2)

> It will probably mean defining a unique @@create method for each built-in Typed
> Array constructor

There already is a unique constructor function for each kind of TypedArray so I'll have those constructors set the [[TypeArrayName]] of the instances instead of added a unique @@create for each constructor.


fixed in rev20 editor's draft

each typed array constructor sets the [[TypeArrayName]] of the instance it is initialize and then does a super.comstructor call to process the arguments.

Elimianted the [[TypedArrayConstructor]] internal data property of typed array constructor functions.


fixed in rev20 draft, Oct. 28, 2013