@@ -168,6 +168,15 @@ api.frame = (state, subjects, frame, parent, property = null) => {
168
168
// copy keywords to output
169
169
if ( isKeyword ( prop ) ) {
170
170
output [ prop ] = util . clone ( subject [ prop ] ) ;
171
+
172
+ if ( prop === '@type' ) {
173
+ // count bnode values of @type
174
+ for ( const type of subject [ '@type' ] ) {
175
+ if ( type . indexOf ( '_:' ) === 0 ) {
176
+ util . addValue ( state . bnodeMap , type , output , { propertyIsArray : true } ) ;
177
+ }
178
+ }
179
+ }
171
180
continue ;
172
181
}
173
182
@@ -206,7 +215,7 @@ api.frame = (state, subjects, frame, parent, property = null) => {
206
215
if ( graphTypes . isSubjectReference ( o ) ) {
207
216
// recurse into subject reference
208
217
api . frame ( state , [ o [ '@id' ] ] , subframe , output , prop ) ;
209
- } else if ( _valueMatch ( subframe , o ) ) {
218
+ } else if ( _valueMatch ( subframe [ 0 ] , o ) ) {
210
219
// include other values, if they match
211
220
_addFrameOutput ( output , prop , util . clone ( o ) ) ;
212
221
}
@@ -594,20 +603,20 @@ function _valueMatch(pattern, value) {
594
603
const v1 = value [ '@value' ] ;
595
604
const t1 = value [ '@type' ] ;
596
605
const l1 = value [ '@language' ] ;
597
- const v2 = [ ] . concat ( value [ '@value' ] ) ;
598
- const t2 = [ ] . concat ( value [ '@type' ] ) ;
599
- const l2 = [ ] . concat ( value [ '@language' ] ) ;
606
+ const v2 = pattern [ '@value' ] || [ ] ;
607
+ const t2 = pattern [ '@type' ] || [ ] ;
608
+ const l2 = pattern [ '@language' ] || [ ] ;
600
609
601
610
if ( v2 . length === 0 && t2 . length === 0 && l2 . length === 0 ) {
602
611
return true ;
603
612
}
604
- if ( ! v2 . includes ( v1 ) && ! graphTypes . isEmptyObject ( v2 ) ) {
613
+ if ( ! ( v2 . includes ( v1 ) || types . isEmptyObject ( v2 [ 0 ] ) ) ) {
605
614
return false ;
606
615
}
607
- if ( ! t2 . includes ( t1 ) && ! graphTypes . isEmptyObject ( t2 ) ) {
616
+ if ( ! ( ! t1 && t2 . length === 0 || t2 . includes ( t1 ) || t1 && types . isEmptyObject ( t2 [ 0 ] ) ) ) {
608
617
return false ;
609
618
}
610
- if ( ! l2 . includes ( l1 ) && ! graphTypes . isEmptyObjectl2 ) {
619
+ if ( ! ( ! l1 && l2 . length === 0 || l2 . includes ( l1 ) || l1 && types . isEmptyObject ( l2 [ 0 ] ) ) ) {
611
620
return false ;
612
621
}
613
622
return true ;
0 commit comments