Skip to content
Snippets Groups Projects
Commit 880a1bd6 authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'fix-corpus-id-undefined' into 'master'

Prevent TypeErrors when looking for an element's corpusId

Closes #1004

See merge request !1286
parents 566b2fcf 3be9dc20
No related branches found
No related tags found
1 merge request!1286Prevent TypeErrors when looking for an element's corpusId
......@@ -144,10 +144,14 @@ export default {
element () {
return this.elements[this.id]
},
/**
* The corporaMixin requires a corpusId property to be defined to be able to retrieve the current corpus.
* It should either return a corpus ID, or null is there is no corpus.
* Returning `undefined` can cause a warning in the console, as the mixin thinks the property may not be defined.
* @returns {string | null}
*/
corpusId () {
// Corpus ID for the corpora mixin
if (!this.element) return null
return this.element.corpus.id
return this.element?.corpus?.id ?? null
},
elementType () {
return this.element && this.getType(this.element.type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment