KnockoutJS use Array.isArray

This commit is contained in:
the-djmaze 2024-03-03 17:12:35 +01:00
parent a40e6484a1
commit ee3aa16fcf
2 changed files with 2 additions and 2 deletions

View file

@ -63,7 +63,7 @@ ko.bindingHandlers['options'] = {
}
if (unwrappedArray) {
if (typeof unwrappedArray.length == "undefined") // Coerce single value into array
if (!Array.isArray(unwrappedArray)) // Coerce single value into array
unwrappedArray = [unwrappedArray];
// Filter out any entries marked as destroyed

View file

@ -47,7 +47,7 @@
ko.utils.setDomNodeChildrenFromArrayMapping = (domNode, array, mapping, options, callbackAfterAddingNodes, editScript) => {
array = array || [];
if (typeof array.length == "undefined") // Coerce single value into array
if (!Array.isArray(array)) // Coerce single value into array
array = [array];
options = options || {};