@@ -1106,35 +1106,29 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
1106
1106
if ( relativeTo . vocab && '@vocab' in activeCtx ) {
1107
1107
// prepend vocab
1108
1108
const prependedResult = activeCtx [ '@vocab' ] + value ;
1109
- let expansionMapResult = undefined ;
1110
- if ( options && options . expansionMap ) {
1111
- // if we are about to expand the value by prepending
1112
- // @vocab then call the expansion map to inform
1113
- // interested callers that this is occurring
1114
-
1115
- // TODO: use `await` to support async
1116
- expansionMapResult = options . expansionMap ( {
1117
- prependedIri : {
1118
- type : '@vocab' ,
1119
- vocab : activeCtx [ '@vocab' ] ,
1120
- value ,
1121
- result : prependedResult ,
1122
- typeExpansion ,
1109
+ if ( options && options . eventHandler ) {
1110
+ _handleEvent ( {
1111
+ event : {
1112
+ type : [ 'JsonLdEvent' ] ,
1113
+ code : 'prepending @vocab during expansion' ,
1114
+ level : 'info' ,
1115
+ message : 'Prepending @vocab during expansion.' ,
1116
+ details : {
1117
+ type : '@vocab' ,
1118
+ vocab : activeCtx [ '@vocab' ] ,
1119
+ value ,
1120
+ result : prependedResult ,
1121
+ typeExpansion
1122
+ }
1123
1123
} ,
1124
- activeCtx,
1125
1124
options
1126
1125
} ) ;
1127
1126
}
1128
- if ( expansionMapResult !== undefined ) {
1129
- value = expansionMapResult ;
1130
- } else {
1131
- // the null case preserves value as potentially relative
1132
- value = prependedResult ;
1133
- }
1127
+ // the null case preserves value as potentially relative
1128
+ value = prependedResult ;
1134
1129
} else if ( relativeTo . base ) {
1135
1130
// prepend base
1136
1131
let prependedResult ;
1137
- let expansionMapResult ;
1138
1132
let base ;
1139
1133
if ( '@base' in activeCtx ) {
1140
1134
if ( activeCtx [ '@base' ] ) {
@@ -1148,50 +1142,50 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
1148
1142
base = options . base ;
1149
1143
prependedResult = prependBase ( options . base , value ) ;
1150
1144
}
1151
- if ( options && options . expansionMap ) {
1152
- // if we are about to expand the value by pre-pending
1153
- // @base then call the expansion map to inform
1154
- // interested callers that this is occurring
1155
-
1156
- // TODO: use `await` to support async
1157
- expansionMapResult = options . expansionMap ( {
1158
- prependedIri : {
1159
- type : '@base' ,
1160
- base,
1161
- value,
1162
- result : prependedResult ,
1163
- typeExpansion,
1145
+ if ( options && options . eventHandler ) {
1146
+ _handleEvent ( {
1147
+ event : {
1148
+ type : [ 'JsonLdEvent' ] ,
1149
+ code : 'prepending @base during expansion' ,
1150
+ level : 'info' ,
1151
+ message : 'Prepending @base during expansion.' ,
1152
+ details : {
1153
+ type : '@base' ,
1154
+ base,
1155
+ value,
1156
+ result : prependedResult ,
1157
+ typeExpansion
1158
+ }
1164
1159
} ,
1165
- activeCtx,
1166
1160
options
1167
1161
} ) ;
1168
1162
}
1169
- if ( expansionMapResult !== undefined ) {
1170
- value = expansionMapResult ;
1171
- } else {
1172
- // the null case preserves value as potentially relative
1173
- value = prependedResult ;
1174
- }
1163
+ // the null case preserves value as potentially relative
1164
+ value = prependedResult ;
1175
1165
}
1176
1166
1177
- if ( ! _isAbsoluteIri ( value ) && options && options . expansionMap ) {
1178
- // if the result of the expansion is not an absolute iri then
1179
- // call the expansion map to inform interested callers that
1180
- // the resulting value is a relative iri, which can result in
1181
- // it being dropped when converting to other RDF representations
1182
-
1183
- // TODO: use `await` to support async
1184
- const expandedResult = options . expansionMap ( {
1185
- relativeIri : value ,
1186
- activeCtx,
1187
- typeExpansion,
1167
+ // FIXME: duplicate? needed? maybe just enable in a verbose debug mode
1168
+ /*
1169
+ if(!_isAbsoluteIri(value) && options && options.eventHandler) {
1170
+ // emit event indicating a relative IRI was found, which can result in it
1171
+ // being dropped when converting to other RDF representations
1172
+ _handleEvent({
1173
+ event: {
1174
+ type: ['JsonLdEvent'],
1175
+ code: 'relative IRI after expansion',
1176
+ // FIXME: what level?
1177
+ level: 'warning',
1178
+ message: 'Relative IRI after expansion.',
1179
+ details: {
1180
+ relativeIri: value,
1181
+ typeExpansion
1182
+ }
1183
+ },
1188
1184
options
1189
1185
});
1190
- if ( expandedResult !== undefined ) {
1191
- value = expandedResult ;
1192
- }
1193
1186
// NOTE: relative reference events emitted at calling sites as needed
1194
1187
}
1188
+ */
1195
1189
1196
1190
return value ;
1197
1191
}
0 commit comments