Merge remote-tracking branch 'origin/master'
authorGregg Kellogg <gregg@kellogg-assoc.com>
Mon, 25 Jun 2012 11:25:06 -0700
changeset 758 c632e5e5302e
parent 757 a7008dce7c8e (current diff)
parent 754 6d697c85581b (diff)
child 759 8a4ea77d7964
Merge remote-tracking branch 'origin/master'
--- a/playground/jsonld.js	Mon Jun 25 11:24:57 2012 -0700
+++ b/playground/jsonld.js	Mon Jun 25 11:25:06 2012 -0700
@@ -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