Skip to content

Commit fd04107

Browse files
committed
fix: ensure key checks in setData and filterData handle undefined values correctly
1 parent 7eb421d commit fd04107

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ async function setData(element, data) {
430430
data[type][0] = { ...data[type][0], ...$update };
431431
} else if (key === "$data") {
432432
value = data;
433-
} else if (key.startsWith("$data")) {
433+
} else if (key && key.startsWith("$data")) {
434434
value = CRUD.getValueFromObject(data, key.slice(1));
435435
} else if (key === `$${type}`) {
436436
value = data[type];
437-
} else if (key.startsWith(`$${type}`)) {
437+
} else if (key && key.startsWith(`$${type}`)) {
438438
value = CRUD.getValueFromObject(data, key.slice(1));
439439
} else if (key === "{}") {
440440
value = data[type][0];
@@ -562,11 +562,11 @@ async function filterData(element, data, type, key) {
562562
element.setValue(value.length);
563563
} else if (key === "$data") {
564564
value = data;
565-
} else if (key.startsWith("$data")) {
565+
} else if (key && key.startsWith("$data")) {
566566
value = CRUD.getValueFromObject(data, key.slice(1));
567567
} else if (key === `$${type}`) {
568568
value = data[type];
569-
} else if (key.startsWith(`$${type}`)) {
569+
} else if (key && key.startsWith(`$${type}`)) {
570570
value = CRUD.getValueFromObject(data, key.slice(1));
571571
} else if (key === "{}") {
572572
value = data[type][0];

0 commit comments

Comments
 (0)