Closed michielbdejong closed 4 years ago
I was able to replace the failing code with a call to kb.each
, but just to be sure, wanted to ask @megoth if he's aware of whether the return type of IndexedFormula#any
has changed recently?
AFAIK IndexedFormula.each
returns all triples that matches your query, while IndexedFormula.any
will simply return the first match. It might be that the code was initially written with the naive assumption that the first match would always be a collection. Of course, with all things Linked Data, assumptions are dangerous and you should test them.
Another solution would be in line 77 to do if (parts && parts.elements) {
.
Ah I found the explanation, it was a bug in my RDF.
https://solid.github.io/solid-ui/Documentation/forms-intro.html clearly says that (form, ns.ui('parts'), ?)
should be Collection.
So I'll improve my example and also add the check you suggested so that the code outputs a useful warning if the RDF is incorrect.
The call to
kb.any
in https://github.com/solid/solid-ui/blob/49165b4/src/widgets/forms.js#L75 will return aTerm
and soparts.elements
will be undefined.It looks like this code incorrectly assumes that
kb.any
will return aCollection
?