Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Mon, 25 Jun 2012 00:01:59 -0400
changeset 754 6d697c85581b
parent 753 11dcd6b0cb8c
child 755 2fa76ad85133
child 758 c632e5e5302e
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Sun Jun 24 18:55:44 2012 -0700
+++ b/playground/jsonld.js	Mon Jun 25 00:01:59 2012 -0400
@@ -1072,8 +1072,10 @@
         if(!('@language' in ctx)) {
           return element['@value'];
         }
-        // return full element
-        return element;
+        // return full element, alias @value
+        var rval = {};
+        rval[_compactIri(ctx, '@value')] = element['@value'];
+        return rval;
       }
 
       // get type and language context rules
@@ -1083,18 +1085,27 @@
       // matching @type specified in context, compact element
       if(type !== null &&
         ('@type' in element) && element['@type'] === type) {
-        element = element['@value'];
+        return element['@value'];
       }
       // matching @language specified in context, compact element
       else if(language !== null &&
         ('@language' in element) && element['@language'] === language) {
-        element = element['@value'];
+        return element['@value'];
       }
-      // compact @type IRI
-      else if('@type' in element) {
-        element['@type'] = _compactIri(ctx, element['@type']);
+      else {
+        var rval = {};
+        // compact @type IRI
+        if('@type' in element) {
+          rval[_compactIri(ctx, '@type')] =
+            _compactIri(ctx, element['@type']);
+        }
+        // alias @language
+        else if('@language' in element) {
+          rval[_compactIri(ctx, '@language')] = element['@language'];
+        }
+        rval[_compactIri(ctx, '@value')] = element['@value'];
+        return rval;
       }
-      return element;
     }
 
     // compact subject references