Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Sat, 21 Apr 2012 00:14:02 -0400
changeset 558 2f2a2e100f78
parent 557 54d08e1f0d7c
child 559 dc6b0ba407b1
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Fri Apr 20 16:46:22 2012 -0700
+++ b/playground/jsonld.js	Sat Apr 21 00:14:02 2012 -0400
@@ -791,13 +791,13 @@
  * @return the value.
  */
 jsonld.getContextValue = function(ctx, key, type) {
+  var rval = null;
+
   // return null for invalid key
   if(key === null) {
-    return null;
+    return rval;
   }
 
-  var rval = null;
-
   // get default language
   if(type === '@language' && (type in ctx)) {
     rval = ctx[type];
@@ -812,7 +812,7 @@
       rval = entry;
     }
     // return entry value for type
-    if(type in entry) {
+    else if(type in entry) {
       rval = entry[type];
     }
   }
@@ -2927,12 +2927,10 @@
   }
 
   // split value into prefix:suffix
-  var prefix = value;
-  var suffix = '';
   var colon = value.indexOf(':');
   if(colon !== -1) {
-    prefix = value.substr(0, colon);
-    suffix = value.substr(colon + 1);
+    var prefix = value.substr(0, colon);
+    var suffix = value.substr(colon + 1);
 
     // a prefix of '_' indicates a blank node
     if(prefix === '_') {
@@ -3001,12 +2999,10 @@
   }
 
   // split term into prefix:suffix
-  var prefix = term;
-  var suffix = '';
   var colon = term.indexOf(':');
   if(colon !== -1) {
-    prefix = term.substr(0, colon);
-    suffix = term.substr(colon + 1);
+    var prefix = term.substr(0, colon);
+    var suffix = term.substr(colon + 1);
 
     // a prefix of '_' indicates a blank node
     if(prefix === '_') {