Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Mon, 12 Nov 2012 12:55:44 -0500
changeset 945 5481f2608046
parent 944 529b48bcc2e1
child 958 d921922105e9
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Sun Nov 11 20:30:30 2012 +0100
+++ b/playground/jsonld.js	Mon Nov 12 12:55:44 2012 -0500
@@ -1910,12 +1910,9 @@
 
   // special-case expand @id and @type (skips '@id' expansion)
   var prop = _expandTerm(ctx, property);
-  if(prop === '@id') {
+  if(prop === '@id' || prop === '@type') {
     rval = _expandTerm(ctx, value, base);
   }
-  else if(prop === '@type') {
-    rval = _expandTerm(ctx, value);
-  }
   else {
     // get type definition from context
     var type = jsonld.getContextValue(ctx, property, '@type');
@@ -1983,12 +1980,11 @@
 
       var object = {
         nominalValue: value,
-        interfaceName: 'LiteralNode'
-      };
-
-      object.datatype = {
-        nominalValue: datatype,
-        interfaceName: 'IRI'
+        interfaceName: 'LiteralNode',
+        datatype: {
+          nominalValue: datatype,
+          interfaceName: 'IRI'
+        }
       };
       if('@language' in element && datatype === XSD_STRING) {
         object.language = element['@language'];
@@ -2127,7 +2123,7 @@
   if('datatype' in o) {
     var type = o.datatype.nominalValue;
     if(useNativeTypes) {
-      // use native datatypes for certain xsd types
+      // use native types for certain xsd types
       if(type === XSD_BOOLEAN) {
         if(rval['@value'] === 'true') {
           rval['@value'] = true;
@@ -3181,9 +3177,8 @@
     }
   }
 
-  // no matching terms,
+  // no matching terms, use iri
   if(terms.length === 0) {
-    // use iri
     return iri;
   }