Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Thu, 07 Feb 2013 01:22:34 -0500
changeset 1193 ef71a98c2b3a
parent 1192 07a1f5841486
child 1194 6596badacb35
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Wed Feb 06 22:58:51 2013 -0500
+++ b/playground/jsonld.js	Thu Feb 07 01:22:34 2013 -0500
@@ -1359,7 +1359,7 @@
  * must be in expanded form before this method is called.
  *
  * @param activeCtx the active context to use.
- * @param activeProperty the compacted property assoicated with the element
+ * @param activeProperty the compacted property associated with the element
  *          to compact, null for none.
  * @param element the element to compact.
  * @param options the compaction options.
@@ -1662,7 +1662,7 @@
       if(expandedProperty === null ||
         !(_isArray(expandedProperty) ||
         _isAbsoluteIri(expandedProperty) ||
-        _isKeyword(expandedProperty, activeCtx))) {
+        _isKeyword(expandedProperty))) {
         continue;
       }
 
@@ -1704,7 +1704,7 @@
             'jsonld.SyntaxError', {value: value});
         }
         // ensure language value is lowercase
-        expandedValue = value.toLowerCase();
+        value = value.toLowerCase();
       }
 
       // preserve @index
@@ -4480,7 +4480,6 @@
     '@base': base,
     mappings: {},
     keywords: {
-      '@index': [],
       '@context': [],
       '@container': [],
       '@default': [],
@@ -4488,6 +4487,7 @@
       '@explicit': [],
       '@graph': [],
       '@id': [],
+      '@index': [],
       '@language': [],
       '@list': [],
       '@omitDefault': [],
@@ -4508,14 +4508,11 @@
    * Generates an inverse context for use in the compaction algorithm, if
    * not already generated for the given active context.
    *
-   * @param activeCtx the active context to create the inverse context from.
-   *
    * @return the inverse context.
    */
-  function _createInverseContext(activeCtx) {
-    if(!activeCtx) {
-      activeCtx = this;
-    }
+  function _createInverseContext() {
+    var activeCtx = this;
+
     // lazily create inverse
     if(activeCtx.inverse) {
       return activeCtx.inverse;
@@ -4618,7 +4615,7 @@
    *
    * @return a clone (child) of the active context.
    */
-  function _cloneActiveContext(shallow) {
+  function _cloneActiveContext() {
     var child = {};
     child['@base'] = this['@base'];
     child.keywords = _clone(this.keywords);
@@ -4643,7 +4640,10 @@
     rval['@base'] = this['@base'];
     rval.keywords = this.keywords;
     rval.mappings = this.mappings;
-    rval.namer = this.namer.clone();
+    rval.namer = null;
+    if(this.namer) {
+      rval.namer = this.namer.clone();
+    }
     rval.clone = this.clone;
     rval.share = this.share;
     rval.inverse = this.inverse;
@@ -4653,48 +4653,34 @@
 }
 
 /**
- * Returns whether or not the given value is a keyword (or a keyword alias).
+ * Returns whether or not the given value is a keyword.
  *
  * @param v the value to check.
- * @param [ctx] the active context to check against.
  *
  * @return true if the value is a keyword, false if not.
  */
-function _isKeyword(v, ctx) {
+function _isKeyword(v) {
   if(!_isString(v)) {
     return false;
   }
-  if(ctx) {
-    if(v in ctx.keywords) {
-      return true;
-    }
-    for(var key in ctx.keywords) {
-      var aliases = ctx.keywords[key];
-      if(aliases.indexOf(v) !== -1) {
-        return true;
-      }
-    }
-  }
-  else {
-    switch(v) {
-    case '@index':
-    case '@context':
-    case '@container':
-    case '@default':
-    case '@embed':
-    case '@explicit':
-    case '@graph':
-    case '@id':
-    case '@language':
-    case '@list':
-    case '@omitDefault':
-    case '@preserve':
-    case '@set':
-    case '@type':
-    case '@value':
-    case '@vocab':
-      return true;
-    }
+  switch(v) {
+  case '@context':
+  case '@container':
+  case '@default':
+  case '@embed':
+  case '@explicit':
+  case '@graph':
+  case '@id':
+  case '@index':
+  case '@language':
+  case '@list':
+  case '@omitDefault':
+  case '@preserve':
+  case '@set':
+  case '@type':
+  case '@value':
+  case '@vocab':
+    return true;
   }
   return false;
 }