@@ -97,38 +97,12 @@ api.process = async ({
97
97
if ( ctx === null ) {
98
98
// We can't nullify if there are protected terms and we're
99
99
// not allowing overrides (e.g. processing a property term scoped context)
100
- if ( ! overrideProtected &&
101
- Object . keys ( activeCtx . protected ) . length !== 0 ) {
102
- const protectedMode = ( options && options . protectedMode ) || 'error' ;
103
- if ( protectedMode === 'error' ) {
104
- throw new JsonLdError (
105
- 'Tried to nullify a context with protected terms outside of ' +
106
- 'a term definition.' ,
107
- 'jsonld.SyntaxError' ,
108
- { code : 'invalid context nullification' } ) ;
109
- } else if ( protectedMode === 'warn' ) {
110
- // FIXME: remove logging and use a handler
111
- console . warn ( 'WARNING: invalid context nullification' ) ;
112
- const oldActiveCtx = activeCtx ;
113
- // copy all protected term definitions to fresh initial context
114
- rval = activeCtx = api . getInitialContext ( options ) . clone ( ) ;
115
- for ( const [ term , _protected ] of
116
- Object . entries ( oldActiveCtx . protected ) ) {
117
- if ( _protected ) {
118
- activeCtx . mappings [ term ] =
119
- util . clone ( oldActiveCtx . mappings [ term ] ) ;
120
- }
121
- }
122
- activeCtx . protected = util . clone ( oldActiveCtx . protected ) ;
123
-
124
- // cache processed result
125
- resolvedContext . setProcessed ( oldActiveCtx , rval ) ;
126
- continue ;
127
- }
100
+ if ( ! overrideProtected && Object . keys ( activeCtx . protected ) . length !== 0 ) {
128
101
throw new JsonLdError (
129
- 'Invalid protectedMode.' ,
102
+ 'Tried to nullify a context with protected terms outside of ' +
103
+ 'a term definition.' ,
130
104
'jsonld.SyntaxError' ,
131
- { code : 'invalid protected mode' , context : localCtx , protectedMode } ) ;
105
+ { code : 'invalid context nullification' } ) ;
132
106
}
133
107
rval = activeCtx = api . getInitialContext ( options ) . clone ( ) ;
134
108
continue ;
@@ -371,9 +345,6 @@ api.process = async ({
371
345
* @param defined a map of defining/defined keys to detect cycles and prevent
372
346
* double definitions.
373
347
* @param {Object } [options] - creation options.
374
- * @param {string } [options.protectedMode="error"] - "error" to throw error
375
- * on `@protected` constraint violation, "warn" to allow violations and
376
- * signal a warning.
377
348
* @param overrideProtected `false` allows protected terms to be modified.
378
349
*/
379
350
api . createTermDefinition = ( {
@@ -859,22 +830,10 @@ api.createTermDefinition = ({
859
830
activeCtx . protected [ term ] = true ;
860
831
mapping . protected = true ;
861
832
if ( ! _deepCompare ( previousMapping , mapping ) ) {
862
- const protectedMode = ( options && options . protectedMode ) || 'error' ;
863
- if ( protectedMode === 'error' ) {
864
- throw new JsonLdError (
865
- 'Invalid JSON-LD syntax; tried to redefine a protected term.' ,
866
- 'jsonld.SyntaxError' ,
867
- { code : 'protected term redefinition' , context : localCtx , term} ) ;
868
- } else if ( protectedMode === 'warn' ) {
869
- // FIXME: remove logging and use a handler
870
- console . warn ( 'WARNING: protected term redefinition' , { term} ) ;
871
- return ;
872
- }
873
833
throw new JsonLdError (
874
- 'Invalid protectedMode .' ,
834
+ 'Invalid JSON-LD syntax; tried to redefine a protected term .' ,
875
835
'jsonld.SyntaxError' ,
876
- { code : 'invalid protected mode' , context : localCtx , term,
877
- protectedMode} ) ;
836
+ { code : 'protected term redefinition' , context : localCtx , term} ) ;
878
837
}
879
838
}
880
839
} ;
0 commit comments