Skip to content

Commit 6d7a453

Browse files
committed
Handle term definition on @type with empty map.
1 parent 3da84bd commit 6d7a453

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Terms of the form of a relative IRI may not be used as prefixes.
1515
- Match spec error code "invalid context entry" vs "invalid context member".
1616
- Keywords may not be used as prefixes.
17+
- Handle term definition on `@type` with empty map.
1718

1819
### Changed
1920
- Keep term definitions mapping to null so they may be protected.

lib/context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ api.createTermDefinition = ({
411411
api.processingMode(activeCtx, 1.1)) {
412412

413413
const validKeys = ['@container', '@id', '@protected'];
414-
if(Object.keys(value).some(k => !validKeys.includes(k))) {
414+
const keys = Object.keys(value);
415+
if(keys.length === 0 || keys.some(k => !validKeys.includes(k))) {
415416
throw new JsonLdError(
416417
'Invalid JSON-LD syntax; keywords cannot be overridden.',
417418
'jsonld.SyntaxError',

0 commit comments

Comments
 (0)