@@ -471,23 +471,32 @@ api.compactIri = ({
471
471
472
472
// prefer @index if available in value
473
473
const containers = [ ] ;
474
- if ( _isObject ( value ) && '@index' in value ) {
475
- containers . push ( '@index' ) ;
474
+ if ( _isObject ( value ) && '@index' in value && ! ( '@graph' in value ) ) {
475
+ containers . push ( '@index' , '@index@set' ) ;
476
476
}
477
477
478
478
// prefer most specific container including @graph , prefering @set variations
479
479
if ( _isGraph ( value ) ) {
480
- containers . push ( '@graph@index@set' ) ;
481
- containers . push ( '@graph@index' ) ;
482
- containers . push ( '@graph@id@set' ) ;
483
- containers . push ( '@graph@id' ) ;
484
- containers . push ( '@graph@set' ) ;
485
- containers . push ( '@graph' ) ;
480
+ // favor indexmap if the graph is indexed
481
+ if ( '@index' in value ) {
482
+ containers . push ( '@graph@index' , '@graph@index@set' , '@index' , '@index@set' ) ;
483
+ }
484
+ // favor idmap if the graph is has an @id
485
+ if ( '@id' in value ) {
486
+ containers . push (
487
+ '@graph@id' , '@graph@id@set' ) ;
488
+ }
489
+ containers . push ( '@graph' , '@graph@set' ) ;
490
+ // allow indexmap if the graph is not indexed
491
+ if ( ! ( '@index' in value ) ) {
492
+ containers . push ( '@graph@index' , '@graph@index@set' , '@index' , '@index@set' ) ;
493
+ }
494
+ // allow idmap if the graph does not have an @id
495
+ if ( ! ( '@id' in value ) ) {
496
+ containers . push ( '@graph@id' , '@graph@id@set' ) ;
497
+ }
486
498
} else if ( _isObject ( value ) && ! _isValue ( value ) ) {
487
- containers . push ( '@id@set' ) ;
488
- containers . push ( '@id' ) ;
489
- containers . push ( '@type@set' ) ;
490
- containers . push ( '@type' ) ;
499
+ containers . push ( '@id' , '@id@set' , '@type' , '@set@type' ) ;
491
500
}
492
501
493
502
// defaults for term selection based on type/language
@@ -557,16 +566,23 @@ api.compactIri = ({
557
566
} else {
558
567
if ( _isValue ( value ) ) {
559
568
if ( '@language' in value && ! ( '@index' in value ) ) {
560
- containers . push ( '@language' ) ;
569
+ containers . push ( '@language' , '@language@set' ) ;
561
570
typeOrLanguageValue = value [ '@language' ] ;
562
571
} else if ( '@type' in value ) {
563
572
typeOrLanguage = '@type' ;
564
573
typeOrLanguageValue = value [ '@type' ] ;
574
+ } else if ( ! ( '@index' in value ) ) {
575
+ // allw indexing by language even if no language present
576
+ containers . push ( '@language' , '@language@set' ) ;
565
577
}
566
578
} else {
567
579
typeOrLanguage = '@type' ;
568
580
typeOrLanguageValue = '@id' ;
569
581
}
582
+ if ( _isObject ( value ) && ! ( '@index' in value ) ) {
583
+ // allow indexing even if no @index present
584
+ containers . push ( '@index' , '@index@set' ) ;
585
+ }
570
586
containers . push ( '@set' ) ;
571
587
}
572
588
0 commit comments