Updated to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Sat, 06 Aug 2011 23:19:33 -0400
changeset 131 0fd96623fa8e
parent 130 f02bcf7b5762
child 135 b8ef51a2ab60
Updated to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Sat Aug 06 19:09:13 2011 -0400
+++ b/playground/jsonld.js	Sat Aug 06 23:19:33 2011 -0400
@@ -1029,19 +1029,23 @@
             // drop null values
             if(v !== null)
             {
-               if(v.constructor === Array)
+               if(key in subject)
                {
-                  subject[key] = [];
-                  _flatten(subject[key], null, v, subjects);
-                  if(subject[key].length === 1)
+                  if(subject[key].constructor !== Array)
                   {
-                     // convert subject[key] to object if it has only 1
-                     subject[key] = subject[key][0];
+                     subject[key] = [subject[key]];
                   }
                }
                else
                {
-                  _flatten(subject, key, v, subjects);
+                  subject[key] = [];
+               }
+               
+               _flatten(subject[key], null, v, subjects);
+               if(subject[key].length === 1)
+               {
+                  // convert subject[key] to object if it has only 1
+                  subject[key] = subject[key][0];
                }
             }
          }
@@ -2184,15 +2188,8 @@
       values[i] = [];
       for(var n = 0; n < input.length && limit !== 0; ++n)
       {
-         // dereference input if it refers to a subject
+         // add input to list if it matches frame specific type or duck-type
          var next = input[n];
-         if(next.constructor === Object && '@iri' in next &&
-            next['@iri'] in subjects)
-         {
-            next = subjects[next['@iri']];
-         }
-         
-         // add input to list if it matches frame specific type or duck-type
          if(_isType(next, frame) || _isDuckType(next, frame))
          {
             values[i].push(next);