nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: maxGraph/maxGraph
Pull request #389 (2024-04-10 14:59:35)

refactor: GraphDataModel.isLayer signature accepts `null` Cell
This complements the fix that manages `null` Cell in the implementation.

## Notes

Complements #365





Patch:
diff --git a/packages/core/src/view/GraphDataModel.ts b/packages/core/src/view/GraphDataModel.ts
index ce87146e6..d0bd77f29 100644
--- a/packages/core/src/view/GraphDataModel.ts
+++ b/packages/core/src/view/GraphDataModel.ts
@@ -396,9 +396,9 @@ export class GraphDataModel extends EventSource {
   /**
    * Returns true if {@link isRoot} returns true for the parent of the given cell.
    *
-   * @param {Cell} cell  that represents the possible layer.
+   * @param cell  that represents the possible layer.
    */
-  isLayer(cell: Cell) {
+  isLayer(cell: Cell | null) {
     return cell ? this.isRoot(cell.getParent()) : false;
   }
 
diff --git a/packages/core/src/view/mixins/SwimlaneMixin.ts b/packages/core/src/view/mixins/SwimlaneMixin.ts
index 100421fcb..77431687b 100644
--- a/packages/core/src/view/mixins/SwimlaneMixin.ts
+++ b/packages/core/src/view/mixins/SwimlaneMixin.ts
@@ -379,7 +379,7 @@ const SwimlaneMixin: PartialType = {
       }
     }
 
-    return !this.getDataModel().isLayer(<Cell>cell) && !parent ? cell : null;
+    return !this.getDataModel().isLayer(cell) && !parent ? cell : null;
   },
 
   /**


Test patch:
diff --git a/packages/core/__tests__/GraphDataModel.test.ts b/packages/core/__tests__/GraphDataModel.test.ts
index 56832a27b..5527f4b48 100644
--- a/packages/core/__tests__/GraphDataModel.test.ts
+++ b/packages/core/__tests__/GraphDataModel.test.ts
@@ -23,18 +23,15 @@ describe('isLayer', () => {
   dm.setRoot(root);
 
   test('Child is null', () => {
-    // @ts-ignore
-    const child: Cell = null;
-    expect(dm.isLayer(child)).toBe(false);
+    expect(dm.isLayer(null)).toBe(false);
   });
 
   test('Child is not null and is not layer', () => {
-    const child: Cell = new Cell();
-    expect(dm.isLayer(child)).toBe(false);
+    expect(dm.isLayer(new Cell())).toBe(false);
   });
 
   test('Child is not null and is layer', () => {
-    const child: Cell = new Cell();
+    const child = new Cell();
     root.children.push(child);
     child.setParent(root);
     expect(dm.isLayer(child)).toBe(true);