@@ -42,10 +42,13 @@ api.cache = new ActiveContextCache();
42
42
* @param activeCtx the current active context.
43
43
* @param localCtx the local context to process.
44
44
* @param options the context processing options.
45
+ * @param isPropertyTermScopedContext `true` if `localCtx` is a scoped context
46
+ * from a property term.
45
47
*
46
48
* @return the new active context.
47
49
*/
48
- api . process = ( { activeCtx, localCtx, options} ) => {
50
+ api . process = (
51
+ { activeCtx, localCtx, options, isPropertyTermScopedContext = false } ) => {
49
52
// normalize local context to an array of @context objects
50
53
if ( _isObject ( localCtx ) && '@context' in localCtx &&
51
54
_isArray ( localCtx [ '@context' ] ) ) {
@@ -80,7 +83,7 @@ api.process = ({activeCtx, localCtx, options}) => {
80
83
if ( ctx === null ) {
81
84
// We can't nullify if there are protected terms and we're
82
85
// not processing a property term scoped context
83
- if ( ! options . isPropertyTermScopedContext &&
86
+ if ( ! isPropertyTermScopedContext &&
84
87
Object . keys ( activeCtx . protected ) . length !== 0 ) {
85
88
const protectedMode = ( options && options . protectedMode ) || 'error' ;
86
89
if ( protectedMode === 'error' ) {
@@ -229,7 +232,8 @@ api.process = ({activeCtx, localCtx, options}) => {
229
232
230
233
// process all other keys
231
234
for ( const key in ctx ) {
232
- api . createTermDefinition ( rval , ctx , key , defined , options ) ;
235
+ api . createTermDefinition (
236
+ rval , ctx , key , defined , options , isPropertyTermScopedContext ) ;
233
237
}
234
238
235
239
// cache result
@@ -253,8 +257,12 @@ api.process = ({activeCtx, localCtx, options}) => {
253
257
* @param {string } [options.protectedMode="error"] - "error" to throw error
254
258
* on `@protected` constraint violation, "warn" to allow violations and
255
259
* signal a warning.
260
+ * @param isPropertyTermScopedContext `true` if `localCtx` is a scoped context
261
+ * from a property term.
256
262
*/
257
- api . createTermDefinition = ( activeCtx , localCtx , term , defined , options ) => {
263
+ api . createTermDefinition = (
264
+ activeCtx , localCtx , term , defined , options ,
265
+ isPropertyTermScopedContext = false ) => {
258
266
if ( term in defined ) {
259
267
// term already defined
260
268
if ( defined [ term ] ) {
@@ -285,7 +293,7 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined, options) => {
285
293
}
286
294
287
295
// FIXME if(1.1) ... ?
288
- if ( term in activeCtx . protected && ! options . isPropertyTermScopedContext ) {
296
+ if ( term in activeCtx . protected && ! isPropertyTermScopedContext ) {
289
297
const protectedMode = ( options && options . protectedMode ) || 'error' ;
290
298
if ( protectedMode === 'error' ) {
291
299
throw new JsonLdError (
0 commit comments