Updated to latest version of jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Tue, 08 Nov 2011 20:53:14 -0500
changeset 255 f554baf959da
parent 254 730bd58bef2d
child 267 ade0f4b6c245
Updated to latest version of jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Tue Nov 01 14:32:31 2011 -0400
+++ b/playground/jsonld.js	Tue Nov 08 20:53:14 2011 -0500
@@ -2968,10 +2968,26 @@
    if('@context' in frame)
    {
       ctx = _clone(frame['@context']);
+      
+      // remove context from frame
+      frame = jsonld.expand(frame);
    }
-   
-   // remove context from frame
-   frame = jsonld.expand(frame);
+   else if(frame.constructor === Array)
+   {
+      // save first context
+      if(frame.length > 0 && '@context' in frame[0])
+      {
+         ctx = _clone(frame[0]['@context']);
+         
+         // expand all elements in the array
+         var tmp = [];
+         for(var i in frame)
+         {
+            tmp.push(jsonld.expand(frame[i]));
+         }
+         frame = tmp;
+      }
+   }
    
    // create framing options
    // TODO: merge in options from function parameter