From 7c0a26946e59b519e108273246718082a4c72fff Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Thu, 27 Feb 2020 12:24:23 -0500 Subject: [PATCH] Handle term definition on `@type` with empty map. --- CHANGELOG.md | 1 + lib/context.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 769d2466..1a1b5e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Terms of the form of a relative IRI may not be used as prefixes. - Match spec error code "invalid context entry" vs "invalid context member". - Keywords may not be used as prefixes. +- Handle term definition on `@type` with empty map. ### Changed - Keep term definitions mapping to null so they may be protected. diff --git a/lib/context.js b/lib/context.js index 30077d9a..09d903f0 100644 --- a/lib/context.js +++ b/lib/context.js @@ -411,7 +411,8 @@ api.createTermDefinition = ({ api.processingMode(activeCtx, 1.1)) { const validKeys = ['@container', '@id', '@protected']; - if(Object.keys(value).some(k => !validKeys.includes(k))) { + const keys = Object.keys(value); + if(keys.length === 0 || keys.some(k => !validKeys.includes(k))) { throw new JsonLdError( 'Invalid JSON-LD syntax; keywords cannot be overridden.', 'jsonld.SyntaxError',