Skip to content
Snippets Groups Projects
Commit 3953668e authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Fixed some bugs caused by unbound this

parent b8a6f60a
No related branches found
No related tags found
No related merge requests found
Pipeline #56958 passed
...@@ -9,6 +9,8 @@ export class GraphElement<JSONType, HistoryType> extends SerializableItem< ...@@ -9,6 +9,8 @@ export class GraphElement<JSONType, HistoryType> extends SerializableItem<
constructor(id = -1, graph: Graph = undefined) { constructor(id = -1, graph: Graph = undefined) {
super(id); super(id);
this.equals = this.equals.bind(this);
this.graph = graph; this.graph = graph;
} }
...@@ -33,6 +35,10 @@ export class GraphElement<JSONType, HistoryType> extends SerializableItem< ...@@ -33,6 +35,10 @@ export class GraphElement<JSONType, HistoryType> extends SerializableItem<
* @returns True, if given object is identical. * @returns True, if given object is identical.
*/ */
public equals(other: GraphElement<JSONType, HistoryType>): boolean { public equals(other: GraphElement<JSONType, HistoryType>): boolean {
if (other == undefined) {
return false;
}
return other.constructor == this.constructor && other.id == this.id; return other.constructor == this.constructor && other.id == this.id;
} }
} }
...@@ -37,6 +37,9 @@ export class Link ...@@ -37,6 +37,9 @@ export class Link
constructor(source?: Node, target?: Node, graph?: Graph) { constructor(source?: Node, target?: Node, graph?: Graph) {
super(0, graph); super(0, graph);
this.equals = this.equals.bind(this);
this.source = source; this.source = source;
this.target = target; this.target = target;
} }
...@@ -94,6 +97,10 @@ export class Link ...@@ -94,6 +97,10 @@ export class Link
} }
public equals(other: GraphElement<LinkData, SimLinkData>): boolean { public equals(other: GraphElement<LinkData, SimLinkData>): boolean {
if (other == undefined) {
return false;
}
if (other.constructor != this.constructor) { if (other.constructor != this.constructor) {
return false; return false;
} }
......
...@@ -15,6 +15,10 @@ export class DynamicGraph extends Common.Graph { ...@@ -15,6 +15,10 @@ export class DynamicGraph extends Common.Graph {
super(data); super(data);
this.onChangeCallbacks = []; this.onChangeCallbacks = [];
super.deleteNode = super.deleteNode.bind(this);
super.deleteLink = super.deleteLink.bind(this);
super.deleteNodeType = super.deleteNodeType.bind(this);
if (data != undefined) { if (data != undefined) {
this.history = new History<SimGraphData>( this.history = new History<SimGraphData>(
this, this,
...@@ -116,7 +120,7 @@ export class DynamicGraph extends Common.Graph { ...@@ -116,7 +120,7 @@ export class DynamicGraph extends Common.Graph {
} }
public deleteLink(id: number): boolean { public deleteLink(id: number): boolean {
return this.delete(id, super.deleteNode); return this.delete(id, super.deleteLink);
} }
getLink( getLink(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment