@@ -168,6 +168,15 @@ api.frame = (state, subjects, frame, parent, property = null) => {
168168 // copy keywords to output
169169 if ( isKeyword ( prop ) ) {
170170 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+ }
171180 continue ;
172181 }
173182
@@ -206,7 +215,7 @@ api.frame = (state, subjects, frame, parent, property = null) => {
206215 if ( graphTypes . isSubjectReference ( o ) ) {
207216 // recurse into subject reference
208217 api . frame ( state , [ o [ '@id' ] ] , subframe , output , prop ) ;
209- } else if ( _valueMatch ( subframe , o ) ) {
218+ } else if ( _valueMatch ( subframe [ 0 ] , o ) ) {
210219 // include other values, if they match
211220 _addFrameOutput ( output , prop , util . clone ( o ) ) ;
212221 }
@@ -594,20 +603,20 @@ function _valueMatch(pattern, value) {
594603 const v1 = value [ '@value' ] ;
595604 const t1 = value [ '@type' ] ;
596605 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' ] || [ ] ;
600609
601610 if ( v2 . length === 0 && t2 . length === 0 && l2 . length === 0 ) {
602611 return true ;
603612 }
604- if ( ! v2 . includes ( v1 ) && ! graphTypes . isEmptyObject ( v2 ) ) {
613+ if ( ! ( v2 . includes ( v1 ) || types . isEmptyObject ( v2 [ 0 ] ) ) ) {
605614 return false ;
606615 }
607- if ( ! t2 . includes ( t1 ) && ! graphTypes . isEmptyObject ( t2 ) ) {
616+ if ( ! ( ! t1 && t2 . length === 0 || t2 . includes ( t1 ) || t1 && types . isEmptyObject ( t2 [ 0 ] ) ) ) {
608617 return false ;
609618 }
610- if ( ! l2 . includes ( l1 ) && ! graphTypes . isEmptyObjectl2 ) {
619+ if ( ! ( ! l1 && l2 . length === 0 || l2 . includes ( l1 ) || l1 && types . isEmptyObject ( l2 [ 0 ] ) ) ) {
611620 return false ;
612621 }
613622 return true ;
0 commit comments