Skip to content

Commit 5fc1f00

Browse files
davidlehndlongley
authored andcommitted
Change from "sealed" to "protected".
1 parent e306d48 commit 5fc1f00

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

lib/context.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ api.process = ({activeCtx, localCtx, options,
6767

6868
// reset to initial context
6969
if(ctx === null) {
70-
// We can't nullify if there are sealed terms and we're
70+
// We can't nullify if there are protected terms and we're
7171
// not in a term definition
7272
if(!propertyTermDefinition &&
73-
Object.keys(activeCtx.sealed).length !== 0) {
73+
Object.keys(activeCtx.protected).length !== 0) {
7474
throw new JsonLdError(
75-
'Tried to nullify a context with sealed terms outside of ' +
75+
'Tried to nullify a context with protected terms outside of ' +
7676
'a term definition.',
7777
'jsonld.SyntaxError',
7878
{code: 'invalid context nullification'});
@@ -193,10 +193,10 @@ api.process = ({activeCtx, localCtx, options,
193193
defined['@language'] = true;
194194
}
195195

196-
// handle @sealed; determine whether this sub-context is declaring
197-
// all its terms to be "sealed" (exceptions can be made on a
196+
// handle @protected; determine whether this sub-context is declaring
197+
// all its terms to be "protected" (exceptions can be made on a
198198
// per-definition basis)
199-
defined['@sealed'] = ctx['@sealed'] || false;
199+
defined['@protected'] = ctx['@protected'] || false;
200200

201201
// process all other keys
202202
for(const key in ctx) {
@@ -251,13 +251,11 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
251251
{code: 'invalid term definition', context: localCtx});
252252
}
253253

254-
// Is this term currently sealed?
255-
// Then redefining it here is an error!
256-
if(activeCtx.sealed[term]) {
254+
if(activeCtx.protected[term]) {
257255
throw new JsonLdError(
258-
'Invalid JSON-LD syntax; tried to redefine a sealed term.',
256+
'Invalid JSON-LD syntax; tried to redefine a protected term.',
259257
'jsonld.SyntaxError',
260-
{code: 'sealed term redefinition', context: localCtx, term});
258+
{code: 'protected term redefinition', context: localCtx, term});
261259
}
262260

263261
// remove old mapping
@@ -299,7 +297,7 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
299297

300298
// JSON-LD 1.1 support
301299
if(api.processingMode(activeCtx, 1.1)) {
302-
validKeys.push('@context', '@nest', '@prefix', '@sealed');
300+
validKeys.push('@context', '@nest', '@prefix', '@protected');
303301
}
304302

305303
for(const kw in value) {
@@ -404,14 +402,14 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
404402
}
405403
}
406404

407-
// Handle term sealing
408-
if('@sealed' in value) {
409-
if(value['@sealed']) {
410-
activeCtx.sealed[term] = true;
405+
// Handle term protection
406+
if('@protected' in value) {
407+
if(value['@protected']) {
408+
activeCtx.protected[term] = true;
411409
}
412-
} else if('@sealed' in defined) {
413-
if(defined['@sealed']) {
414-
activeCtx.sealed[term] = true;
410+
} else if('@protected' in defined) {
411+
if(defined['@protected']) {
412+
activeCtx.protected[term] = true;
415413
}
416414
}
417415

@@ -687,7 +685,7 @@ api.getInitialContext = options => {
687685
inverse: null,
688686
getInverse: _createInverseContext,
689687
clone: _cloneActiveContext,
690-
sealed: {}
688+
protected: {}
691689
};
692690
// TODO: consider using LRU cache instead
693691
if(INITIAL_CONTEXT_CACHE.size === INITIAL_CONTEXT_CACHE_MAX_SIZE) {
@@ -863,7 +861,7 @@ api.getInitialContext = options => {
863861
child.clone = this.clone;
864862
child.inverse = null;
865863
child.getInverse = this.getInverse;
866-
child.sealed = util.clone(this.sealed);
864+
child.protected = util.clone(this.protected);
867865
if('@language' in this) {
868866
child['@language'] = this['@language'];
869867
}
@@ -973,9 +971,9 @@ api.isKeyword = v => {
973971
case '@omitDefault':
974972
case '@prefix':
975973
case '@preserve':
974+
case '@protected':
976975
case '@requireAll':
977976
case '@reverse':
978-
case '@sealed':
979977
case '@set':
980978
case '@type':
981979
case '@value':

0 commit comments

Comments
 (0)