KnockoutJS use more Array.isArray

This commit is contained in:
the-djmaze 2024-03-03 22:33:29 +01:00
parent 1357a696be
commit b07bf3ad12
2 changed files with 2 additions and 2 deletions

View file

@ -1,7 +1,7 @@
ko['observableArray'] = initialValues => {
initialValues = initialValues || [];
if (typeof initialValues != 'object' || !('length' in initialValues))
if (!Array.isArray(initialValues))
throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.");
return Object.setPrototypeOf(ko.observable(initialValues), ko['observableArray']['fn']).extend({'trackArrayChanges':true});