Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Tue, 16 Jul 2013 15:10:24 -0400
changeset 1764 aa82137eef3d
parent 1763 f08a5ed6c78e
child 1765 f97908287e5d
Update to latest jsonld.js.
playground/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;
   }