Skip to content

Commit 1a01734

Browse files
committed
fix(live preview): check undefined entry
1 parent 32b950f commit 1a01734

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/entry-editable.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { EntryModel } from ".";
22

3-
export function addTags(entry: EntryModel, contentTypeUid: string, tagsAsObject: boolean, locale: string = 'en-us') : void {
4-
entry["$"] = getTag(entry, `${contentTypeUid}.${entry.uid}.${locale}`, tagsAsObject, locale)
3+
export function addTags(entry: EntryModel, contentTypeUid: string, tagsAsObject: boolean, locale: string = 'en-us') : void {
4+
if (entry)
5+
entry["$"] = getTag(entry, `${contentTypeUid}.${entry.uid}.${locale}`, tagsAsObject, locale)
56
}
67

78
function getTag(content: object, prefix: string, tagsAsObject: boolean, locale: string): object {
@@ -11,7 +12,7 @@ function getTag(content: object, prefix: string, tagsAsObject: boolean, locale:
1112
case "object":
1213
if (Array.isArray(value)) {
1314
value.forEach((obj, index) => {
14-
if (obj._content_type_uid !== undefined && obj.uid !== undefined) {
15+
if ((typeof obj !== 'undefined' || obj !== null) && obj._content_type_uid !== undefined && obj.uid !== undefined) {
1516
value[index]['$'] = getTag(obj, `${obj._content_type_uid}.${obj.uid}.${obj.locale || locale}`, tagsAsObject, locale)
1617
}else {
1718
if (typeof obj === "object") {

0 commit comments

Comments
 (0)