rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
715 stars 132 forks source link

Custom data factories are incorrectly handled #466

Open rubensworks opened 6 days ago

rubensworks commented 6 days ago

When injecting a custom factory into the StreamParser (possibly other places as well), the factory methods are being used as standalone functions instead of methods on the factory object. This makes it so that custom factories (such as rdf-data-factory) that rely on an internal this state will start failing, which causes issues such as https://github.com/rubensworks/rdf-dereference.js/issues/55.

I suspect the solution may be as simple as just bind-ing the extracted factory functions to factory here.

RubenVerborgh commented 5 days ago

Interesting; I always assumed that they were a series of functions just held together by an arbitrary object, but the spec does not say that: https://rdf.js.org/data-model-spec/#datafactory-interface Hence, they must indeed be called as instance methods.

(It does say default values of the instance properties, but that is an error IMHO; I think they mean default arguments for the member functions.)