Skip to content

Commit c9a0940

Browse files
committed
Fix term mapping of @reverse.
1 parent 6d7a453 commit c9a0940

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Match spec error code "invalid context entry" vs "invalid context member".
1616
- Keywords may not be used as prefixes.
1717
- Handle term definition on `@type` with empty map.
18+
- Term mapping of `@reverse`.
1819

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

lib/context.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,10 @@ api.createTermDefinition = ({
506506
'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});
507507
}
508508

509+
if(!api.isKeyword(reverse) && reverse.match(KEYWORD_PATTERN)) {
510+
return;
511+
}
512+
509513
// expand and add @id mapping
510514
const id = _expandIri(
511515
activeCtx, reverse, {vocab: true, base: false}, localCtx, defined,
@@ -517,18 +521,6 @@ api.createTermDefinition = ({
517521
'jsonld.SyntaxError', {code: 'invalid IRI mapping', context: localCtx});
518522
}
519523

520-
if(reverse.match(KEYWORD_PATTERN)) {
521-
// FIXME: remove logging and use a handler
522-
console.warn('WARNING: values beginning with "@" are reserved' +
523-
' for future use and ignored', {reverse});
524-
if(previousMapping) {
525-
activeCtx.mappings.set(term, previousMapping);
526-
} else {
527-
activeCtx.mappings.delete(term);
528-
}
529-
return;
530-
}
531-
532524
mapping['@id'] = id;
533525
mapping.reverse = true;
534526
} else if('@id' in value) {

0 commit comments

Comments
 (0)