From df5dd8206b473aeda20f5d7c20c34150631c37cc Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 12 Dec 2024 10:22:46 +0100 Subject: [PATCH] Ignore instead of fail when rendering BlankNode with no subject --- .changeset/witty-moose-mate.md | 5 +++++ addon/core/schema.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/witty-moose-mate.md diff --git a/.changeset/witty-moose-mate.md b/.changeset/witty-moose-mate.md new file mode 100644 index 000000000..9c1abac4d --- /dev/null +++ b/.changeset/witty-moose-mate.md @@ -0,0 +1,5 @@ +--- +'@lblod/ember-rdfa-editor': patch +--- + +If trying to render a BlankNode with no subject, ignore it instead of crashing diff --git a/addon/core/schema.ts b/addon/core/schema.ts index 6279a3702..b3fa0479d 100644 --- a/addon/core/schema.ts +++ b/addon/core/schema.ts @@ -289,6 +289,13 @@ export function renderInvisibleRdfa( case 'BlankNode': { // the triple refers to a URI which does not have a corresponding // resource node + if (!isSome(nodeOrMark.attrs['subject'])) { + console.warn( + 'Trying to render a BlankNode with no subject, ignoring', + nodeOrMark.attrs, + ); + break; + } const subject: string = unwrap(nodeOrMark.attrs['subject'] as string); propElements.push(namedNodeSpan(subject, predicate, object.value)); break;