Updated to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Tue, 17 Apr 2012 00:24:51 -0400
changeset 531 735a98612a98
parent 530 481a8a3b67af
child 532 5afe57e01f8e
Updated to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Mon Apr 16 16:48:31 2012 -0700
+++ b/playground/jsonld.js	Tue Apr 17 00:24:51 2012 -0400
@@ -279,7 +279,7 @@
             'jsonld.FrameError', {cause: err}));
         }
         // get graph alias
-        var graph;
+        var graph = '@graph';
         for(var key in compacted) {
           if(key !== '@context') {
             graph = key;
@@ -750,7 +750,7 @@
  * @param key the context key.
  * @param [type] the type of value to get (eg: '@id', '@type'), if not
  *          specified gets the entire entry for a key, null if not found.
- * @param [expand] true to expand the key, false not to (default: false).
+ * @param [expand] true to expand the key, false not to (default: true).
  *
  * @return the value.
  */
@@ -1118,7 +1118,7 @@
       var prop = _expandTerm(ctx, key);
 
       // drop non-absolute IRI keys that aren't keywords
-      if(!_isAbsoluteIri(prop) && !_isKeyword(keywords, prop)) {
+      if(!_isAbsoluteIri(prop) && !_isKeyword(prop, keywords)) {
         continue;
       }
 
@@ -1568,7 +1568,7 @@
     rval = _expandTerm(ctx, value);
   }
   else {
-    // compact property to look for its type definition in the context
+    // get type definition from context
     var type = jsonld.getContextValue(ctx, property, '@type');
 
     // do @id expansion
@@ -2055,7 +2055,7 @@
       }
 
       // copy keywords
-      if(_isKeyword(null, prop)) {
+      if(_isKeyword(prop)) {
         subject[prop] = input[prop];
         continue;
       }
@@ -2175,7 +2175,7 @@
       var subject = matches[id];
       for(var prop in subject) {
         // copy keywords to output
-        if(_isKeyword(null, prop)) {
+        if(_isKeyword(prop)) {
           output[prop] = _clone(subject[prop]);
           continue;
         }
@@ -2234,7 +2234,7 @@
       // handle defaults
       for(var prop in frame) {
         // skip keywords
-        if(_isKeyword(null, prop)) {
+        if(_isKeyword(prop)) {
           continue;
         }
 
@@ -2331,7 +2331,7 @@
   // check ducktype
   for(var key in frame) {
     // only not a duck if @id or non-keyword isn't in subject
-    if((key === '@id' || !_isKeyword(null, key)) && !(key in subject)) {
+    if((key === '@id' || !_isKeyword(key)) && !(key in subject)) {
       return false;
     }
   }
@@ -2375,7 +2375,7 @@
         var s = state.subjects[id];
         for(var prop in s) {
           // copy keywords
-          if(_isKeyword(null, prop)) {
+          if(_isKeyword(prop)) {
             o[prop] = _clone(s[prop]);
             continue;
           }
@@ -2615,7 +2615,7 @@
   }
 
   // if term is a keyword, use alias
-  if(_isKeyword(null, iri)) {
+  if(_isKeyword(iri)) {
     // pick shortest, least alias
     var keywords = _getKeywords(ctx);
     aliases = keywords[iri];
@@ -2808,20 +2808,19 @@
 /**
  * Returns whether or not the given value is a keyword (or a keyword alias).
  *
- * @param keywords the keyword alias map to check against, null for default.
  * @param value the value to check.
- * @param [specific] the specific keyword to check against.
+ * @param keywords the custom keyword alias map to check against.
  *
  * @return true if the value is a keyword, false if not.
  */
-function _isKeyword(keywords, value, specific) {
+function _isKeyword(value, keywords) {
   if(keywords) {
     if(value in keywords) {
-      return _isUndefined(specific) ? true : (value === specific);
+      return true;
     }
     for(var key in keywords) {
       if(keywords[key].indexOf(value) !== -1) {
-        return _isUndefined(specific) ? true : (key === specific);
+        return true;
       }
     }
   }