浏览代码

Add a void check for json equality

Steven Silvester 8 年之前
父节点
当前提交
53e56e715d
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      src/common/observablejson.ts

+ 12 - 1
src/common/observablejson.ts

@@ -92,7 +92,7 @@ class ObservableJSON extends ObservableMap<JSONValue> {
    */
    */
   constructor(options: ObservableJSON.IOptions = {}) {
   constructor(options: ObservableJSON.IOptions = {}) {
     super({
     super({
-      itemCmp: JSONExt.deepEqual,
+      itemCmp: Private.itemCmp,
       values: options.values
       values: options.values
     });
     });
   }
   }
@@ -448,4 +448,15 @@ namespace Private {
         h.div({ className: HOST_CLASS }))
         h.div({ className: HOST_CLASS }))
     );
     );
   }
   }
+
+  /**
+   * Compare two objects for JSON equality.
+   */
+  export
+  function itemCmp(a: JSONValue, b: JSONValue): boolean {
+    if (a === void 0 || b === void 0) {
+      return false;
+    }
+    return JSONExt.deepEqual(a, b);
+  }
 }
 }