- Allow all TypedArrays

- Validator should not crash when TypedArray is not available
This commit is contained in:
Tim de Koning 2022-08-08 15:55:43 +02:00
parent 01134dcf2a
commit f6d077b3ec
2 changed files with 5 additions and 2 deletions

View File

@ -142,7 +142,10 @@ export function getFunctionValidator() {
export function getNumberArrayValidator() {
if (Konva.isUnminified) {
return function (val: any, attr: string) {
if (val instanceof Uint8Array || val instanceof Uint16Array || val instanceof Uint32Array || val instanceof Uint8ClampedArray) {
// Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
if (TypedArray && val instanceof TypedArray) {
return val
}
if (!Util._isArray(val)) {

View File

@ -51,7 +51,7 @@ function expandPoints(p, tension) {
}
export interface LineConfig extends ShapeConfig {
points?: number[] | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray;
points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
tension?: number;
closed?: boolean;
bezier?: boolean;