@@ -406,6 +406,7 @@ async function _expandObject({
406406} ) {
407407 const keys = Object . keys ( element ) . sort ( ) ;
408408 const nests = [ ] ;
409+ let unexpandedValue ;
409410 for ( const key of keys ) {
410411 let value = element [ key ] ;
411412 let expandedValue ;
@@ -513,6 +514,9 @@ async function _expandObject({
513514 }
514515
515516 if ( expandedProperty === '@value' ) {
517+ // capture value for later
518+ // "colliding keywords" check prevents this from being set twice
519+ unexpandedValue = value ;
516520 _addValue (
517521 expandedParent , '@value' , value , { propertyIsArray : options . isFrame } ) ;
518522 continue ;
@@ -770,16 +774,16 @@ async function _expandObject({
770774 // @value must not be an object or an array (unless framing) or if @type is
771775 // @json
772776 if ( '@value' in expandedParent ) {
773- const value = expandedParent [ '@value' ] ;
774777 if ( expandedParent [ '@type' ] === '@json' && _processingMode ( activeCtx , 1.1 ) ) {
775778 // allow any value, to be verified when the object is fully expanded and
776779 // the @type is @json.
777- } else if ( ( _isObject ( value ) || _isArray ( value ) ) && ! options . isFrame ) {
780+ } else if ( ( _isObject ( unexpandedValue ) || _isArray ( unexpandedValue ) ) &&
781+ ! options . isFrame ) {
778782 throw new JsonLdError (
779783 'Invalid JSON-LD syntax; "@value" value must not be an ' +
780784 'object or an array.' ,
781785 'jsonld.SyntaxError' ,
782- { code : 'invalid value object value' , value} ) ;
786+ { code : 'invalid value object value' , value : unexpandedValue } ) ;
783787 }
784788 }
785789
0 commit comments