Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Thu, 14 Feb 2013 13:34:43 -0500
changeset 1261 2f544d1a2a59
parent 1260 8c245815f440
child 1262 608a0ec02b17
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Thu Feb 14 13:33:21 2013 -0500
+++ b/playground/jsonld.js	Thu Feb 14 13:34:43 2013 -0500
@@ -3805,11 +3805,10 @@
   }
   relativeTo = relativeTo || {};
 
-  // use inverse context to pick a term
-  var inverseCtx = activeCtx.getInverse();
-  var defaultLanguage = activeCtx['@language'] || '@none';
-
-  if(iri in inverseCtx) {
+  // use inverse context to pick a term if iri is relative to vocab
+  if(relativeTo.vocab && iri in activeCtx.getInverse()) {
+    var defaultLanguage = activeCtx['@language'] || '@none';
+
     // prefer @index if available in value
     var containers = [];
     if(_isObject(value) && '@index' in value) {
@@ -4030,7 +4029,11 @@
   // value is a subject reference
   var expandedProperty = _expandIri(activeCtx, activeProperty);
   var type = jsonld.getContextValue(activeCtx, activeProperty, '@type');
-  var term = _compactIri(activeCtx, value['@id'], null, {base: true});
+  var term = _compactIri(
+    activeCtx, value['@id'], null, {
+      vocab: type === '@vocab',
+      base: true
+    });
 
   // compact to scalar
   if(type === '@id' || type === '@vocab' || expandedProperty === '@graph') {