Update to latest jsonld.js.
--- a/playground/jsonld.js Thu Jul 11 12:27:54 2013 -0400
+++ b/playground/jsonld.js Tue Jul 16 15:10:24 2013 -0400
@@ -291,6 +291,15 @@
document: _clone(remoteDoc.document),
remoteContext: {'@context': remoteDoc.contextUrl}
};
+ if('expandContext' in options) {
+ if(typeof options.expandContext === 'object' &&
+ '@context' in options.expandContext) {
+ input.expandContext = _clone(options.expandContext);
+ }
+ else {
+ input.expandContext = {'@context': options.expandContext};
+ }
+ }
_retrieveContextUrls(input, options, function(err, input) {
if(err) {
return callback(err);
@@ -303,13 +312,15 @@
var remoteContext = input.remoteContext['@context'];
// process optional expandContext
- if('expandContext' in options) {
- processor.processContext(activeCtx, options.expandContext, options);
+ if(input.expandContext) {
+ activeCtx = processor.processContext(
+ activeCtx, input.expandContext, options);
}
// process remote context from HTTP Link Header
if(remoteContext) {
- processor.processContext(activeCtx, remoteContext, options);
+ activeCtx = processor.processContext(
+ activeCtx, remoteContext, options);
}
// expand document
@@ -1980,14 +1991,8 @@
activeCtx, activeProperty, element, options, insideList) {
var self = this;
- if(typeof element === 'undefined') {
- throw new JsonLdError(
- 'Invalid JSON-LD syntax; undefined element.',
- 'jsonld.SyntaxError');
- }
-
// nothing to expand
- if(element === null) {
+ if(element === null || element === undefined) {
return null;
}