Comparing version 8.2.17 to 8.2.18
{ | ||
"name": "hybrids", | ||
"version": "8.2.17", | ||
"version": "8.2.18", | ||
"description": "A JavaScript framework for creating fully-featured web applications, components libraries, and single web components with unique declarative and functional architecture", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1509,2 +1509,6 @@ import * as cache from "./cache.js"; | ||
function resolveId(value) { | ||
return typeof value === "object" ? value?.id : value ?? undefined; | ||
} | ||
function store(Model, options = {}) { | ||
@@ -1524,14 +1528,2 @@ const config = bootstrap(Model); | ||
const resolveId = options.id | ||
? (host) => { | ||
const id = options.id(host); | ||
return id !== undefined && id !== null ? String(id) : undefined; | ||
} | ||
: (host, value) => { | ||
if (value !== null && value !== undefined) { | ||
return typeof value === "object" ? value.id : String(value); | ||
} | ||
return undefined; | ||
}; | ||
let draft; | ||
@@ -1563,12 +1555,17 @@ if (options.draft) { | ||
get(host, value) { | ||
let id = resolveId(host, value) || (value ? value.id : undefined); | ||
let id = | ||
(options.id ? options.id(host) : resolveId(value)) ?? undefined; | ||
if (!id && (value === undefined || value === null)) { | ||
if (config.enumerable) { | ||
const draftModel = draft.create({}); | ||
id = draftModel.id; | ||
if (id === undefined || id === "") { | ||
id = value?.id ?? undefined; | ||
syncCache(draft, draftModel.id, draftModel, false); | ||
} else { | ||
clear(draft.model); | ||
if (value === undefined || value === null) { | ||
if (config.enumerable) { | ||
const draftModel = draft.create({}); | ||
id = draftModel.id; | ||
syncCache(draft, draftModel.id, draftModel, false); | ||
} else { | ||
clear(draft.model); | ||
} | ||
} | ||
@@ -1591,4 +1588,7 @@ } | ||
get(host, value) { | ||
const id = resolveId(host); | ||
const nextValue = config.list || id ? get(Model, id) : undefined; | ||
const id = options.id(host) ?? undefined; | ||
const nextValue = | ||
config.list || (id !== "" && id !== undefined) | ||
? get(Model, id) | ||
: undefined; | ||
@@ -1608,5 +1608,6 @@ if (nextValue !== value && ready(value) && !ready(nextValue)) { | ||
get(host, value) { | ||
const id = resolveId(host, value); | ||
return !config.enumerable || config.list || value | ||
? get(Model, id) | ||
return !config.enumerable || | ||
config.list || | ||
(value !== "" && (value ?? undefined)) | ||
? get(Model, resolveId(value)) | ||
: undefined; | ||
@@ -1613,0 +1614,0 @@ }, |
205406