linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
565 stars 143 forks source link

isRDFlibObject check for hasOwnProperty does not work with es6 classes #480

Open angelo-v opened 3 years ago

angelo-v commented 3 years ago

Some RDF/JS compatible libraries like comunica return instances of es6 classes. For those the type guard using hasOwnProperty in isRDFlibObject fails, althought the object has a getter for termType. Therefore Quads containting those objects cannot be imported to an rdflibjs store, although they are compliant to RDF/JS.

Why is the hasOwnProperty check needed, instead of just checking whether obj.termType is present?

Sources:

However, hasOwnProperty() will return false for ES6 class getters and methods, like ES6 getters. https://masteringjs.io/tutorials/fundamentals/hasownproperty