@@ -486,23 +486,32 @@ api.compactIri = ({
486
486
487
487
// prefer @index if available in value
488
488
const containers = [ ] ;
489
- if ( _isObject ( value ) && '@index' in value ) {
490
- containers . push ( '@index' ) ;
489
+ if ( _isObject ( value ) && '@index' in value && ! ( '@graph' in value ) ) {
490
+ containers . push ( '@index' , '@index@set' ) ;
491
491
}
492
492
493
493
// prefer most specific container including @graph , prefering @set variations
494
494
if ( _isGraph ( value ) ) {
495
- containers . push ( '@graph@index@set' ) ;
496
- containers . push ( '@graph@index' ) ;
497
- containers . push ( '@graph@id@set' ) ;
498
- containers . push ( '@graph@id' ) ;
499
- containers . push ( '@graph@set' ) ;
500
- containers . push ( '@graph' ) ;
495
+ // favor indexmap if the graph is indexed
496
+ if ( '@index' in value ) {
497
+ containers . push ( '@graph@index' , '@graph@index@set' , '@index' , '@index@set' ) ;
498
+ }
499
+ // favor idmap if the graph is has an @id
500
+ if ( '@id' in value ) {
501
+ containers . push (
502
+ '@graph@id' , '@graph@id@set' ) ;
503
+ }
504
+ containers . push ( '@graph' , '@graph@set' ) ;
505
+ // allow indexmap if the graph is not indexed
506
+ if ( ! ( '@index' in value ) ) {
507
+ containers . push ( '@graph@index' , '@graph@index@set' , '@index' , '@index@set' ) ;
508
+ }
509
+ // allow idmap if the graph does not have an @id
510
+ if ( ! ( '@id' in value ) ) {
511
+ containers . push ( '@graph@id' , '@graph@id@set' ) ;
512
+ }
501
513
} else if ( _isObject ( value ) && ! _isValue ( value ) ) {
502
- containers . push ( '@id@set' ) ;
503
- containers . push ( '@id' ) ;
504
- containers . push ( '@type@set' ) ;
505
- containers . push ( '@type' ) ;
514
+ containers . push ( '@id' , '@id@set' , '@type' , '@set@type' ) ;
506
515
}
507
516
508
517
// defaults for term selection based on type/language
@@ -572,16 +581,23 @@ api.compactIri = ({
572
581
} else {
573
582
if ( _isValue ( value ) ) {
574
583
if ( '@language' in value && ! ( '@index' in value ) ) {
575
- containers . push ( '@language' ) ;
584
+ containers . push ( '@language' , '@language@set' ) ;
576
585
typeOrLanguageValue = value [ '@language' ] ;
577
586
} else if ( '@type' in value ) {
578
587
typeOrLanguage = '@type' ;
579
588
typeOrLanguageValue = value [ '@type' ] ;
589
+ } else if ( ! ( '@index' in value ) ) {
590
+ // allw indexing by language even if no language present
591
+ containers . push ( '@language' , '@language@set' ) ;
580
592
}
581
593
} else {
582
594
typeOrLanguage = '@type' ;
583
595
typeOrLanguageValue = '@id' ;
584
596
}
597
+ if ( _isObject ( value ) && ! ( '@index' in value ) ) {
598
+ // allow indexing even if no @index present
599
+ containers . push ( '@index' , '@index@set' ) ;
600
+ }
585
601
containers . push ( '@set' ) ;
586
602
}
587
603
0 commit comments