removed references to `arguments` object in various files

development
mcyph 2021-03-21 16:01:26 +11:00
parent 452ba705ea
commit 1f778c7869
2 changed files with 115 additions and 112 deletions

View File

@ -538,87 +538,90 @@ class mxConnectionHandler extends mxEventSource {
* Creates and returns the <mxCellMarker> used in <marker>. * Creates and returns the <mxCellMarker> used in <marker>.
*/ */
createMarker = () => { createMarker = () => {
let marker = new mxCellMarker(this.graph); let self = this;
marker.hotspotEnabled = true;
class MyCellMarker extends mxCellMarker {
hotspotEnabled = true;
// Overrides to return cell at location only if valid (so that // Overrides to return cell at location only if valid (so that
// there is no highlight for invalid cells) // there is no highlight for invalid cells)
marker.getCell = mxUtils.bind(this, (me) => { getCell = (me) => {
let cell = getCell.apply(marker, arguments); let cell = super.getCell(me);
this.error = null; self.error = null;
// Checks for cell at preview point (with grid) // Checks for cell at preview point (with grid)
if (cell == null && this.currentPoint != null) { if (cell == null && self.currentPoint != null) {
cell = this.graph.getCellAt(this.currentPoint.x, this.currentPoint.y); cell = self.graph.getCellAt(self.currentPoint.x, self.currentPoint.y);
} }
// Uses connectable parent vertex if one exists // Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell)) { if (cell != null && !self.graph.isCellConnectable(cell)) {
let parent = this.graph.getModel().getParent(cell); let parent = self.graph.getModel().getParent(cell);
if (this.graph.getModel().isVertex(parent) && this.graph.isCellConnectable(parent)) { if (self.graph.getModel().isVertex(parent) && self.graph.isCellConnectable(parent)) {
cell = parent; cell = parent;
} }
} }
if ((this.graph.isSwimlane(cell) && this.currentPoint != null && if ((self.graph.isSwimlane(cell) && self.currentPoint != null &&
this.graph.hitsSwimlaneContent(cell, this.currentPoint.x, this.currentPoint.y)) || self.graph.hitsSwimlaneContent(cell, self.currentPoint.x, self.currentPoint.y)) ||
!this.isConnectableCell(cell)) { !self.isConnectableCell(cell)) {
cell = null; cell = null;
} }
if (cell != null) { if (cell != null) {
if (this.isConnecting()) { if (self.isConnecting()) {
if (this.previous != null) { if (self.previous != null) {
this.error = this.validateConnection(this.previous.cell, cell); self.error = self.validateConnection(self.previous.cell, cell);
if (this.error != null && this.error.length === 0) { if (self.error != null && self.error.length === 0) {
cell = null; cell = null;
// Enables create target inside groups // Enables create target inside groups
if (this.isCreateTarget(me.getEvent())) { if (self.isCreateTarget(me.getEvent())) {
this.error = null; self.error = null;
} }
} }
} }
} else if (!this.isValidSource(cell, me)) { } else if (!self.isValidSource(cell, me)) {
cell = null; cell = null;
} }
} else if (this.isConnecting() && !this.isCreateTarget(me.getEvent()) && } else if (self.isConnecting() && !self.isCreateTarget(me.getEvent()) &&
!this.graph.allowDanglingEdges) { !self.graph.allowDanglingEdges) {
this.error = ''; self.error = '';
} }
return cell; return cell;
}); };
// Sets the highlight color according to validateConnection // Sets the highlight color according to validateConnection
marker.isValidState = (state) => { isValidState = (state) => {
if (this.isConnecting()) { if (self.isConnecting()) {
return this.error == null; return self.error == null;
} else { } else {
return this.isValidState.apply(marker, arguments); return super.isValidState(state);
} }
}; };
// Overrides to use marker color only in highlight mode or for // Overrides to use marker color only in highlight mode or for
// target selection // target selection
marker.getMarkerColor = mxUtils.bind(this, (evt, state, isValid) => { getMarkerColor = (evt, state, isValid) => {
return (this.connectImage == null || this.isConnecting()) ? return (self.connectImage == null || self.isConnecting()) ?
super.getMarkerColor(evt, state, isValid) : super.getMarkerColor(evt, state, isValid) :
null; null;
}); };
// Overrides to use hotspot only for source selection otherwise // Overrides to use hotspot only for source selection otherwise
// intersects always returns true when over a cell // intersects always returns true when over a cell
marker.intersects = (state, evt) => { intersects = (state, evt) => {
if (this.connectImage != null || this.isConnecting()) { if (self.connectImage != null || self.isConnecting()) {
return true; return true;
} }
return super.intersects(state, evt); return super.intersects(state, evt);
}; };
}
return marker; return new MyCellMarker(this.graph);
}; };
/** /**
@ -1883,7 +1886,7 @@ class mxConnectionHandler extends mxEventSource {
} }
let clone = this.graph.cloneCell(source); let clone = this.graph.cloneCell(source);
let geo = this.graph.getModel().getGeometry(clone); geo = this.graph.getModel().getGeometry(clone);
if (geo != null) { if (geo != null) {
let t = this.graph.view.translate; let t = this.graph.view.translate;

View File

@ -473,13 +473,13 @@ class mxEdgeHandler {
* Creates and returns the <mxCellMarker> used in <marker>. * Creates and returns the <mxCellMarker> used in <marker>.
*/ */
createMarker = () => { createMarker = () => {
let marker = new mxCellMarker(this.graph);
let self = this; // closure let self = this; // closure
class MyMarker extends mxCellMarker {
// Only returns edges if they are connectable and never returns // Only returns edges if they are connectable and never returns
// the edge that is currently being modified // the edge that is currently being modified
marker.getCell = (me) => { getCell = (me) => {
let cell = getCell.apply(this, arguments); let cell = super.getCell(me);
// Checks for cell at preview point (with grid) // Checks for cell at preview point (with grid)
if ((cell === self.state.cell || cell == null) && self.currentPoint != null) { if ((cell === self.state.cell || cell == null) && self.currentPoint != null) {
@ -508,12 +508,11 @@ class mxEdgeHandler {
if (!this.graph.isCellConnectable(cell)) { if (!this.graph.isCellConnectable(cell)) {
cell = null; cell = null;
} }
return cell; return cell;
}; };
// Sets the highlight color according to validateConnection // Sets the highlight color according to validateConnection
marker.isValidState = (state) => { isValidState = (state) => {
let model = self.graph.getModel(); let model = self.graph.getModel();
let other = self.graph.view.getTerminalPort(state, let other = self.graph.view.getTerminalPort(state,
self.graph.view.getState(model.getTerminal(self.state.cell, self.graph.view.getState(model.getTerminal(self.state.cell,
@ -527,8 +526,9 @@ class mxEdgeHandler {
return self.error == null; return self.error == null;
}; };
}
return marker; return new MyMarker(this.graph);
}; };
/** /**