- Removed mxUtils.indexOf().

development
Junsik Shim 2021-04-27 21:40:09 +09:00
parent 654736d23d
commit c5899e0955
12 changed files with 26 additions and 71 deletions

View File

@ -8,7 +8,6 @@
import mxDictionary from '../../../util/datatypes/mxDictionary';
import mxGraphHierarchyNode from './mxGraphHierarchyNode';
import mxGraphHierarchyEdge from './mxGraphHierarchyEdge';
import mxUtils from '../../../util/mxUtils';
/**
* Class: mxGraphHierarchyModel
@ -94,12 +93,7 @@ class mxGraphHierarchyModel {
internalTargetCell.connectsAsTarget = [];
}
if (
mxUtils.indexOf(
internalTargetCell.connectsAsTarget,
internalEdge
) < 0
) {
if (internalTargetCell.connectsAsTarget.indexOf(internalEdge) < 0) {
internalTargetCell.connectsAsTarget.push(internalEdge);
}
}
@ -259,12 +253,7 @@ class mxGraphHierarchyModel {
internalEdge.source = internalVertices[i];
if (
mxUtils.indexOf(
internalVertices[i].connectsAsSource,
internalEdge
) < 0
) {
if (internalVertices[i].connectsAsSource.indexOf(internalEdge) < 0) {
internalVertices[i].connectsAsSource.push(internalEdge);
}
}

View File

@ -93,12 +93,7 @@ class mxSwimlaneModel {
internalTargetCell.connectsAsTarget = [];
}
if (
mxUtils.indexOf(
internalTargetCell.connectsAsTarget,
internalEdge
) < 0
) {
if (internalTargetCell.connectsAsTarget.indexOf(internalEdge) < 0) {
internalTargetCell.connectsAsTarget.push(internalEdge);
}
}
@ -274,12 +269,7 @@ class mxSwimlaneModel {
internalEdge.source = internalVertices[i];
if (
mxUtils.indexOf(
internalVertices[i].connectsAsSource,
internalEdge
) < 0
) {
if (internalVertices[i].connectsAsSource.indexOf(internalEdge) < 0) {
internalVertices[i].connectsAsSource.push(internalEdge);
}
}

View File

@ -8,7 +8,6 @@
import mxChildChange from '../atomic_changes/mxChildChange';
import mxObjectCodec from './mxObjectCodec';
import mxCodecRegistry from './mxCodecRegistry';
import mxUtils from '../util/mxUtils';
import mxConstants from '../util/mxConstants';
/**
@ -50,7 +49,7 @@ class mxChildChangeCodec extends mxObjectCodec {
if (attr === 'child' && (!isWrite || obj.model.contains(obj.previous))) {
return true;
}
return mxUtils.indexOf(this.idrefs, attr) >= 0;
return this.idrefs.indexOf(attr) >= 0;
}
/**

View File

@ -314,7 +314,7 @@ class mxObjectCodec {
isExcluded(obj, attr, value, write) {
return (
attr == mxObjectIdentity.FIELD_NAME ||
mxUtils.indexOf(this.exclude, attr) >= 0
this.exclude.indexOf(attr) >= 0
);
}
@ -331,7 +331,7 @@ class mxObjectCodec {
*/
// isReference(obj: any, attr: string, value: any, write?: boolean): boolean;
isReference(obj, attr, value, write) {
return mxUtils.indexOf(this.idrefs, attr) >= 0;
return this.idrefs.indexOf(attr) >= 0;
}
/**

View File

@ -1045,7 +1045,7 @@ class mxShape {
if (
rounded &&
(dx !== 0 || dy !== 0) &&
(exclude == null || mxUtils.indexOf(exclude, i - 1) < 0)
(exclude == null || exclude.indexOf(i - 1) < 0)
) {
// Draws a line from the last point to the current
// point with a spacing of size off the current point

View File

@ -109,7 +109,7 @@ const mxResources = {
*/
isLanguageSupported: lan => {
if (mxClient.languages != null) {
return mxUtils.indexOf(mxClient.languages, lan) >= 0;
return mxClient.languages.indexOf(lan) >= 0;
}
return true;

View File

@ -189,29 +189,6 @@ const mxUtils = {
return null;
},
/**
* Function: indexOf
*
* Returns the index of obj in array or -1 if the array does not contain
* the given object.
*
* Parameters:
*
* array - Array to check for the given obj.
* obj - Object to find in the given array.
*/
indexOf: (array, obj) => {
if (array != null && obj != null) {
for (let i = 0; i < array.length; i += 1) {
if (array[i] == obj) {
return i;
}
}
}
return -1;
},
/**
* Function: forEach
*
@ -254,12 +231,12 @@ const mxUtils = {
let result = null;
if (typeof array === 'object') {
let index = mxUtils.indexOf(array, obj);
let index = array.indexOf(obj);
while (index >= 0) {
array.splice(index, 1);
result = obj;
index = mxUtils.indexOf(array, obj);
index = array.indexOf(obj);
}
}

View File

@ -438,7 +438,8 @@ class mxCell {
*/
// getIndex(child: mxCell): number;
getIndex(child: mxCell | null): number {
return mxUtils.indexOf(this.children, child);
if (child === null || !this.children) return -1;
return this.children.indexOf(child);
}
/**
@ -540,7 +541,8 @@ class mxCell {
*/
// getEdgeIndex(edge: mxCell): number;
getEdgeIndex(edge: mxCell): number {
return mxUtils.indexOf(this.edges, edge);
if (!this.edges) return -1;
return this.edges.indexOf(edge);
}
/**
@ -573,7 +575,7 @@ class mxCell {
if (
this.edges == null ||
edge.getTerminal(!isOutgoing) !== this ||
mxUtils.indexOf(this.edges, edge) < 0
this.edges.indexOf(edge) < 0
) {
if (this.edges == null) {
this.edges = [];

View File

@ -316,7 +316,7 @@ class mxCellRenderer {
];
for (let i = 0; i < styles.length; i += 1) {
if (mxUtils.indexOf(values, state.style[styles[i]]) >= 0) {
if (values.indexOf(state.style[styles[i]]) >= 0) {
return true;
}
}

View File

@ -1511,7 +1511,7 @@ class mxGraph extends mxEventSource {
if (overlay == null) {
this.removeCellOverlays(cell);
} else {
const index = mxUtils.indexOf(cell.overlays, overlay);
const index = cell.overlays ? cell.overlays.indexOf(overlay) : -1;
if (index >= 0) {
(<mxCellOverlay[]>cell.overlays).splice(index, 1);
@ -6708,7 +6708,7 @@ class mxGraph extends mxEventSource {
geo.height
);
if (mxUtils.indexOf(cells, parent) >= 0) {
if (cells.indexOf(parent) >= 0) {
bbox.x += tmp.x;
bbox.y += tmp.y;
}
@ -6719,7 +6719,7 @@ class mxGraph extends mxEventSource {
if (
parent.isVertex() &&
mxUtils.indexOf(cells, parent) >= 0
cells.indexOf(parent) >= 0
) {
tmp = this.getBoundingBoxFromGeometry([parent], false);
@ -9766,7 +9766,7 @@ class mxGraph extends mxEventSource {
// Checks if parent is dropped into child if not cloning
if (!clone) {
let parent = cell;
while (parent != null && mxUtils.indexOf(cells, parent) < 0) {
while (parent != null && cells.indexOf(parent) < 0) {
parent = parent.getParent();
}
}

View File

@ -113,7 +113,7 @@ class mxGraphSelectionModel extends mxEventSource {
// isSelected(cell: mxCell): boolean;
isSelected(cell: mxCell): boolean {
if (cell != null) {
return mxUtils.indexOf(this.cells, cell) >= 0;
return this.cells.indexOf(cell) >= 0;
}
return false;
}
@ -302,7 +302,7 @@ class mxGraphSelectionModel extends mxEventSource {
// cellRemoved(cell: mxCell): void;
cellRemoved(cell: mxCell): void {
if (cell != null) {
const index = mxUtils.indexOf(this.cells, cell);
const index = this.cells.indexOf(cell);
if (index >= 0) {
this.cells.splice(index, 1);
}

View File

@ -282,15 +282,13 @@ const Template = ({ label, ...args }) => {
if (provider != null) {
data =
mxUtils.indexOf(provider.types, 'text/html') >= 0
provider.types.indexOf('text/html') >= 0
? provider.getData('text/html')
: null;
if (
mxUtils.indexOf(
provider.types,
'text/plain' && (data == null || data.length === 0)
)
provider.types.indexOf('text/plain')
&& (data == null || data.length === 0)
) {
data = provider.getData('text/plain');
}