Let Annotation._collectActions return null when no actions are present

Rather than returning an *empty* Object[1] we should be returning `null` instead, since that's consistent with existing API-functionality.
To avoid having to *manually* track if the Object is empty, this patch also introduces a small helper function to check its size.
This commit is contained in:
Jonas Jenwald 2020-10-29 14:17:32 +01:00
parent 8540b4cc76
commit a1e5581a0b
2 changed files with 18 additions and 10 deletions

View file

@ -585,6 +585,10 @@ function string32(value) {
);
}
function objectSize(obj) {
return Object.keys(obj).length;
}
// Ensures that the returned Object has a `null` prototype.
function objectFromEntries(iterable) {
return Object.assign(Object.create(null), Object.fromEntries(iterable));
@ -1040,6 +1044,7 @@ export {
isString,
isSameOrigin,
createValidAbsoluteUrl,
objectSize,
objectFromEntries,
IsLittleEndianCached,
IsEvalSupportedCached,