File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,21 @@ api.compact = ({
216
216
continue ;
217
217
}
218
218
219
+ if ( expandedProperty === '@preserve' ) {
220
+ // compact using activeProperty
221
+ const compactedValue = api . compact ( {
222
+ activeCtx,
223
+ activeProperty,
224
+ element : expandedValue ,
225
+ options,
226
+ compactionMap} ) ;
227
+
228
+ if ( ! ( _isArray ( compactedValue ) && compactedValue . length === 0 ) ) {
229
+ _addValue ( rval , expandedProperty , compactedValue ) ;
230
+ }
231
+ continue ;
232
+ }
233
+
219
234
// handle @index property
220
235
if ( expandedProperty === '@index' ) {
221
236
// drop @index if inside an @index container
@@ -511,6 +526,11 @@ api.compactIri = ({
511
526
containers . push ( '@index' , '@index@set' ) ;
512
527
}
513
528
529
+ // if value is a preserve object, use its value
530
+ if ( _isObject ( value ) && '@preserve' in value ) {
531
+ value = value [ '@preserve' ] [ 0 ] ;
532
+ }
533
+
514
534
// prefer most specific container including @graph , prefering @set variations
515
535
if ( _isGraph ( value ) ) {
516
536
// favor indexmap if the graph is indexed
You can’t perform that action at this time.
0 commit comments