From 47020fd795021c4fdeb931639b31fd6ac4850e06 Mon Sep 17 00:00:00 2001 From: smessie Date: Wed, 24 Aug 2022 17:40:10 +0200 Subject: [PATCH] Set a default value for `context.form` instead of throwing an error --- src/core/FormDefinition.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/FormDefinition.ts b/src/core/FormDefinition.ts index 44bae51..d685c48 100644 --- a/src/core/FormDefinition.ts +++ b/src/core/FormDefinition.ts @@ -18,7 +18,7 @@ export class FormDefinition extends EventTarget implements CoreComponent { private formAsTextOrUrl: string private sourceDefinitionCompacted: object = {} private sourceDefinitionExpanded: Array - public context = { form: null } + public context = { form: '' } public ready: boolean = false public chain = new Map() public chainReferences = new Map() @@ -54,7 +54,9 @@ export class FormDefinition extends EventTarget implements CoreComponent { this.sourceDefinitionCompacted = ttl2jsonld(definitionTurtle) Object.assign(this.context, this.sourceDefinitionCompacted['@context']) - if (!this.context.form) throw new Error('The prefix form was not found in the form definition.') + if (!this.context.form) { + this.context.form = 'http://rdf.danielbeeke.nl/form/form-dev.ttl#'; + } if (!this.sourceDefinitionCompacted['@graph']) throw new Error('Missing fields inside form definition') this.sourceDefinitionExpanded = JsonLdProxy(await JsonLdExpand(this.sourceDefinitionCompacted), this.context, { '_': (value) => Language.multilingualValue(value, 'ui') @@ -180,4 +182,4 @@ export class FormDefinition extends EventTarget implements CoreComponent { } return bindings } -} \ No newline at end of file +}