Skip to content

Handle term definition on @type with empty map. #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion lib/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down