Skip to content

Commit 6e10d86

Browse files
gkelloggdavidlehn
authored andcommitted
Put processingMode on the context, rather than the API.
1 parent 53f0fb4 commit 6e10d86

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/context.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ api.process = ({activeCtx, localCtx, options}) => {
9696
'Unsupported JSON-LD version: ' + ctx['@version'],
9797
'jsonld.UnsupportedVersion',
9898
{code: 'invalid @version value', context: ctx});
99-
} else if(api.processingMode && api.processingMode.indexOf('json-ld-1.1') !== 0) {
99+
} else if(activeCtx.processingMode && activeCtx.processingMode.indexOf('json-ld-1.1') !== 0) {
100100
throw new JsonLdError(
101-
'@version: ' + ctx['@version'] + ' not compatible with ' + api.processingMode,
101+
'@version: ' + ctx['@version'] + ' not compatible with ' + activeCtx.processingMode,
102102
'jsonld.ProcessingModeConflict',
103103
{code: 'processing mode conflict', context: ctx});
104104
}
105-
api.processingMode = api.processingMode || 'json-ld-1.1';
105+
rval.processingMode = 'json-ld-1.1';
106106
rval['@version'] = ctx['@version'];
107107
defined['@version'] = true;
108108
}
109109

110110
// If not set explicitly, set processingMode to "json-ld-1.0"
111-
api.processingMode = api.processingMode || 'json-ld-1.0';
111+
rval.processingMode = rval.processingMode || activeCtx.processingMode || 'json-ld-1.0';
112112

113113
// handle @base
114114
if('@base' in ctx) {
@@ -386,7 +386,7 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
386386
let hasSet = container.includes('@set');
387387

388388
// JSON-LD 1.1 support
389-
if(api.processingMode.indexOf('json-ld-1.1') === 0) {
389+
if(activeCtx.processingMode && activeCtx.processingMode.indexOf('json-ld-1.1') === 0) {
390390
// TODO: @id and @type
391391
validContainers.push('@graph');
392392

@@ -536,9 +536,6 @@ api.expandIri = (activeCtx, value, relativeTo, localCtx, defined) => {
536536
return value;
537537
};
538538

539-
// If not set in options, determined in first context which is an object.
540-
api.processingMode = null;
541-
542539
/**
543540
* Gets the initial context.
544541
*
@@ -549,9 +546,9 @@ api.processingMode = null;
549546
*/
550547
api.getInitialContext = (options) => {
551548
const base = parseUrl(options.base || '');
552-
if(options.processingMode) api.processingMode = options.processingMode;
553549
return {
554550
'@base': base,
551+
processingMode: options.processingMode,
555552
mappings: {},
556553
inverse: null,
557554
getInverse: _createInverseContext,

0 commit comments

Comments
 (0)