Closed ninevra closed 3 years ago
Should we ignore these? We already ignore non-enumerable properties.
That makes sense to me. These properties certainly aren't enumerable, which seems close enough to non-enumerable to similarly ignore.
Please can we have a release that includes this fix?
compare()
,format()
,serialize()
, anddiff()
throw an error when called on objects which have own properties with no property descriptors. (As far as I know, the only such objects areProxy
s.)concordance
assumes that, ifObject.getOwnPropertyNames(input)
returns e.g.['name']
, thenObject.getOwnPropertyDescriptor(input, 'name')
will return a property descriptor. This is true for non-Proxy
inputs, but can be false forProxy
s, which in most cases don't have to respect any relation between theownKeys
andownPropertyDescriptor
operations.This can lead to throwing
at https://github.com/concordancejs/concordance/blob/b30e7c8bdb19463b3a7e11d1dc8725affce7b059/lib/getObjectKeys.js#L20
I encountered this when I accidentally tried to snapshot a jsdom Window object, which apparently has some ownKeys that lack descriptors.
I'm not sure whether there's a better way to handle this. The "value" of the property can still be retrieved with e.g.
Reflect.get()
, so that could be used for comparison; but enumerability and other property attributes are strange.As far as I can tell, undescribed properties do not behave identically to any valid property descriptor, nor to the absence of a property. They are not themselves listed in enumerations, but neither do they mask the presence of enumerable prototype properties, as truly unenumerable properties do. They may or may not satisfy
Reflect.has(object, property)
.