@@ -406,6 +406,7 @@ async function _expandObject({
406
406
} ) {
407
407
const keys = Object . keys ( element ) . sort ( ) ;
408
408
const nests = [ ] ;
409
+ let unexpandedValue ;
409
410
for ( const key of keys ) {
410
411
let value = element [ key ] ;
411
412
let expandedValue ;
@@ -513,6 +514,9 @@ async function _expandObject({
513
514
}
514
515
515
516
if ( expandedProperty === '@value' ) {
517
+ // capture value for later
518
+ // "colliding keywords" check prevents this from being set twice
519
+ unexpandedValue = value ;
516
520
_addValue (
517
521
expandedParent , '@value' , value , { propertyIsArray : options . isFrame } ) ;
518
522
continue ;
@@ -770,16 +774,16 @@ async function _expandObject({
770
774
// @value must not be an object or an array (unless framing) or if @type is
771
775
// @json
772
776
if ( '@value' in expandedParent ) {
773
- const value = expandedParent [ '@value' ] ;
774
777
if ( expandedParent [ '@type' ] === '@json' && _processingMode ( activeCtx , 1.1 ) ) {
775
778
// allow any value, to be verified when the object is fully expanded and
776
779
// the @type is @json.
777
- } else if ( ( _isObject ( value ) || _isArray ( value ) ) && ! options . isFrame ) {
780
+ } else if ( ( _isObject ( unexpandedValue ) || _isArray ( unexpandedValue ) ) &&
781
+ ! options . isFrame ) {
778
782
throw new JsonLdError (
779
783
'Invalid JSON-LD syntax; "@value" value must not be an ' +
780
784
'object or an array.' ,
781
785
'jsonld.SyntaxError' ,
782
- { code : 'invalid value object value' , value} ) ;
786
+ { code : 'invalid value object value' , value : unexpandedValue } ) ;
783
787
}
784
788
}
785
789
0 commit comments