made it so all comparisons against mxConstants values use === or !==

development
mcyph 2021-03-27 19:02:49 +11:00
parent 7b6f6156a3
commit 7eb02061b7
11 changed files with 60 additions and 62 deletions

View File

@ -867,7 +867,7 @@ class mxObjectCodec {
const tmp = child.nextSibling; const tmp = child.nextSibling;
if ( if (
child.nodeType == mxConstants.NODETYPE_ELEMENT && child.nodeType === mxConstants.NODETYPE_ELEMENT &&
!this.processInclude(dec, child, obj) !this.processInclude(dec, child, obj)
) { ) {
this.decodeChild(dec, child, obj); this.decodeChild(dec, child, obj);

View File

@ -82,13 +82,13 @@ class mxImageShape extends mxRectangleShape {
if (this.style != null) { if (this.style != null) {
this.preserveImageAspect = this.preserveImageAspect =
mxUtils.getNumber(this.style, mxConstants.STYLE_IMAGE_ASPECT, 1) === 1; mxUtils.getNumber(this.style, mxConstants.STYLE_IMAGE_ASPECT, 1) == 1;
// Legacy support for imageFlipH/V // Legacy support for imageFlipH/V
this.flipH = this.flipH =
this.flipH || mxUtils.getValue(this.style, 'imageFlipH', 0) === 1; this.flipH || mxUtils.getValue(this.style, 'imageFlipH', 0) == 1;
this.flipV = this.flipV =
this.flipV || mxUtils.getValue(this.style, 'imageFlipV', 0) === 1; this.flipV || mxUtils.getValue(this.style, 'imageFlipV', 0) == 1;
} }
} }

View File

@ -107,22 +107,20 @@ class mxPolyline extends mxShape {
const pt = pts[0]; const pt = pts[0];
const n = pts.length; const n = pts.length;
c.moveTo(pt.x, pt.y); c.moveTo(pt.x, pt.y);
for (let i = 1; i < n - 2; i += 1) { for (let i = 1; i < n - 2; i += 1) {
var p0 = pts[i]; const p0 = pts[i];
var p1 = pts[i + 1]; const p1 = pts[i + 1];
const ix = (p0.x + p1.x) / 2; const ix = (p0.x + p1.x) / 2;
const iy = (p0.y + p1.y) / 2; const iy = (p0.y + p1.y) / 2;
c.quadTo(p0.x, p0.y, ix, iy); c.quadTo(p0.x, p0.y, ix, iy);
} }
var p0 = pts[n - 2]; const p0 = pts[n - 2];
var p1 = pts[n - 1]; const p1 = pts[n - 1];
c.quadTo(p0.x, p0.y, p1.x, p1.y); c.quadTo(p0.x, p0.y, p1.x, p1.y);
c.stroke(); c.stroke();
} }
} }

View File

@ -54,8 +54,8 @@ class mxRectangleShape extends mxShape {
return ( return (
!this.isRounded && !this.isRounded &&
!this.glass && !this.glass &&
this.rotation == 0 && this.rotation === 0 &&
(events || (this.fill != null && this.fill != mxConstants.NONE)) (events || (this.fill != null && this.fill !== mxConstants.NONE))
); );
} }
@ -138,7 +138,7 @@ class mxRectangleShape extends mxShape {
this.glass && this.glass &&
!this.outline && !this.outline &&
this.fill != null && this.fill != null &&
this.fill != mxConstants.NONE this.fill !== mxConstants.NONE
) { ) {
this.paintGlassEffect( this.paintGlassEffect(
c, c,

View File

@ -486,7 +486,7 @@ class mxStencil extends mxShape {
let tmp = node.firstChild; let tmp = node.firstChild;
while (tmp != null) { while (tmp != null) {
if (tmp.nodeType == mxConstants.NODETYPE_ELEMENT) { if (tmp.nodeType === mxConstants.NODETYPE_ELEMENT) {
this.drawNode(canvas, shape, tmp, aspect, disableShadow, paint); this.drawNode(canvas, shape, tmp, aspect, disableShadow, paint);
} }
@ -627,7 +627,7 @@ class mxStencil extends mxShape {
let childNode = node.firstChild; let childNode = node.firstChild;
while (childNode != null) { while (childNode != null) {
if (childNode.nodeType == mxConstants.NODETYPE_ELEMENT) { if (childNode.nodeType === mxConstants.NODETYPE_ELEMENT) {
this.drawNode( this.drawNode(
canvas, canvas,
shape, shape,

View File

@ -12,7 +12,7 @@
* *
* while (shape != null) * while (shape != null)
* { * {
* if (shape.nodeType == mxConstants.NODETYPE_ELEMENT) * if (shape.nodeType === mxConstants.NODETYPE_ELEMENT)
* { * {
* mxStencilRegistry.addStencil(shape.getAttribute('name'), new mxStencil(shape)); * mxStencilRegistry.addStencil(shape.getAttribute('name'), new mxStencil(shape));
* } * }

View File

@ -258,7 +258,7 @@ class mxSwimlane extends mxShape {
'1'; '1';
} }
if (!events && (this.fill == null || this.fill == mxConstants.NONE)) { if (!events && (this.fill == null || this.fill === mxConstants.NONE)) {
c.pointerEvents = false; c.pointerEvents = false;
} }
@ -270,11 +270,11 @@ class mxSwimlane extends mxShape {
c.fillAndStroke(); c.fillAndStroke();
if (start < h) { if (start < h) {
if (fill == mxConstants.NONE || !events) { if (fill === mxConstants.NONE || !events) {
c.pointerEvents = false; c.pointerEvents = false;
} }
if (fill != mxConstants.NONE) { if (fill !== mxConstants.NONE) {
c.setFillColor(fill); c.setFillColor(fill);
} }
@ -284,7 +284,7 @@ class mxSwimlane extends mxShape {
c.lineTo(w, h); c.lineTo(w, h);
c.lineTo(w, start); c.lineTo(w, start);
if (fill == mxConstants.NONE) { if (fill === mxConstants.NONE) {
c.stroke(); c.stroke();
} else { } else {
c.fillAndStroke(); c.fillAndStroke();
@ -298,11 +298,11 @@ class mxSwimlane extends mxShape {
c.fillAndStroke(); c.fillAndStroke();
if (start < w) { if (start < w) {
if (fill == mxConstants.NONE || !events) { if (fill === mxConstants.NONE || !events) {
c.pointerEvents = false; c.pointerEvents = false;
} }
if (fill != mxConstants.NONE) { if (fill !== mxConstants.NONE) {
c.setFillColor(fill); c.setFillColor(fill);
} }
@ -312,7 +312,7 @@ class mxSwimlane extends mxShape {
c.lineTo(w, h); c.lineTo(w, h);
c.lineTo(start, h); c.lineTo(start, h);
if (fill == mxConstants.NONE) { if (fill === mxConstants.NONE) {
c.stroke(); c.stroke();
} else { } else {
c.fillAndStroke(); c.fillAndStroke();
@ -321,7 +321,7 @@ class mxSwimlane extends mxShape {
} }
if (swimlaneLine) { if (swimlaneLine) {
this.paintDivider(c, x, y, w, h, start, fill == mxConstants.NONE); this.paintDivider(c, x, y, w, h, start, fill === mxConstants.NONE);
} }
} }
@ -341,7 +341,7 @@ class mxSwimlane extends mxShape {
'1'; '1';
} }
if (!events && (this.fill == null || this.fill == mxConstants.NONE)) { if (!events && (this.fill == null || this.fill === mxConstants.NONE)) {
c.pointerEvents = false; c.pointerEvents = false;
} }
@ -355,11 +355,11 @@ class mxSwimlane extends mxShape {
c.fillAndStroke(); c.fillAndStroke();
if (start < h) { if (start < h) {
if (fill == mxConstants.NONE || !events) { if (fill === mxConstants.NONE || !events) {
c.pointerEvents = false; c.pointerEvents = false;
} }
if (fill != mxConstants.NONE) { if (fill !== mxConstants.NONE) {
c.setFillColor(fill); c.setFillColor(fill);
} }
@ -371,7 +371,7 @@ class mxSwimlane extends mxShape {
c.quadTo(w, h, w, h - r); c.quadTo(w, h, w, h - r);
c.lineTo(w, start); c.lineTo(w, start);
if (fill == mxConstants.NONE) { if (fill === mxConstants.NONE) {
c.stroke(); c.stroke();
} else { } else {
c.fillAndStroke(); c.fillAndStroke();
@ -387,11 +387,11 @@ class mxSwimlane extends mxShape {
c.fillAndStroke(); c.fillAndStroke();
if (start < w) { if (start < w) {
if (fill == mxConstants.NONE || !events) { if (fill === mxConstants.NONE || !events) {
c.pointerEvents = false; c.pointerEvents = false;
} }
if (fill != mxConstants.NONE) { if (fill !== mxConstants.NONE) {
c.setFillColor(fill); c.setFillColor(fill);
} }
@ -403,7 +403,7 @@ class mxSwimlane extends mxShape {
c.quadTo(w, 0, w - r, 0); c.quadTo(w, 0, w - r, 0);
c.lineTo(start, 0); c.lineTo(start, 0);
if (fill == mxConstants.NONE) { if (fill === mxConstants.NONE) {
c.stroke(); c.stroke();
} else { } else {
c.fillAndStroke(); c.fillAndStroke();
@ -412,7 +412,7 @@ class mxSwimlane extends mxShape {
} }
if (swimlaneLine) { if (swimlaneLine) {
this.paintDivider(c, x, y, w, h, start, fill == mxConstants.NONE); this.paintDivider(c, x, y, w, h, start, fill === mxConstants.NONE);
} }
} }
@ -445,7 +445,7 @@ class mxSwimlane extends mxShape {
* Paints the vertical or horizontal separator line between swimlanes. * Paints the vertical or horizontal separator line between swimlanes.
*/ */
paintSeparator(c, x, y, w, h, start, color) { paintSeparator(c, x, y, w, h, start, color) {
if (color != mxConstants.NONE) { if (color !== mxConstants.NONE) {
c.setStrokeColor(color); c.setStrokeColor(color);
c.setDashed(true); c.setDashed(true);
c.begin(); c.begin();

View File

@ -1506,7 +1506,7 @@ const mxUtils = {
if (value == null) { if (value == null) {
value = defaultValue; value = defaultValue;
} else if (value == mxConstants.NONE) { } else if (value === mxConstants.NONE) {
value = null; value = null;
} }
@ -2089,10 +2089,10 @@ const mxUtils = {
if ( if (
(flipV && (flipV &&
(d == mxConstants.DIRECTION_SOUTH || (d === mxConstants.DIRECTION_SOUTH ||
d == mxConstants.DIRECTION_NORTH)) || d === mxConstants.DIRECTION_NORTH)) ||
(flipH && (flipH &&
(d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)) (d === mxConstants.DIRECTION_EAST || d === mxConstants.DIRECTION_WEST))
) { ) {
const tmp = m.x; const tmp = m.x;
m.x = m.width; m.x = m.width;
@ -2101,10 +2101,10 @@ const mxUtils = {
if ( if (
(flipH && (flipH &&
(d == mxConstants.DIRECTION_SOUTH || (d === mxConstants.DIRECTION_SOUTH ||
d == mxConstants.DIRECTION_NORTH)) || d === mxConstants.DIRECTION_NORTH)) ||
(flipV && (flipV &&
(d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)) (d === mxConstants.DIRECTION_EAST || d === mxConstants.DIRECTION_WEST))
) { ) {
const tmp = m.y; const tmp = m.y;
m.y = m.height; m.y = m.height;
@ -2113,17 +2113,17 @@ const mxUtils = {
const m2 = mxRectangle.fromRectangle(m); const m2 = mxRectangle.fromRectangle(m);
if (d == mxConstants.DIRECTION_SOUTH) { if (d === mxConstants.DIRECTION_SOUTH) {
m2.y = m.x; m2.y = m.x;
m2.x = m.height; m2.x = m.height;
m2.width = m.y; m2.width = m.y;
m2.height = m.width; m2.height = m.width;
} else if (d == mxConstants.DIRECTION_WEST) { } else if (d === mxConstants.DIRECTION_WEST) {
m2.y = m.height; m2.y = m.height;
m2.x = m.width; m2.x = m.width;
m2.width = m.x; m2.width = m.x;
m2.height = m.y; m2.height = m.y;
} else if (d == mxConstants.DIRECTION_NORTH) { } else if (d === mxConstants.DIRECTION_NORTH) {
m2.y = m.width; m2.y = m.width;
m2.x = m.y; m2.x = m.y;
m2.width = m.height; m2.width = m.height;
@ -3216,16 +3216,16 @@ const mxUtils = {
let dy = -0.5; let dy = -0.5;
// Horizontal alignment // Horizontal alignment
if (align == mxConstants.ALIGN_LEFT) { if (align === mxConstants.ALIGN_LEFT) {
dx = 0; dx = 0;
} else if (align == mxConstants.ALIGN_RIGHT) { } else if (align === mxConstants.ALIGN_RIGHT) {
dx = -1; dx = -1;
} }
// Vertical alignment // Vertical alignment
if (valign == mxConstants.ALIGN_TOP) { if (valign === mxConstants.ALIGN_TOP) {
dy = 0; dy = 0;
} else if (valign == mxConstants.ALIGN_BOTTOM) { } else if (valign === mxConstants.ALIGN_BOTTOM) {
dy = -1; dy = -1;
} }
@ -3272,11 +3272,11 @@ const mxUtils = {
// Sets the font style // Sets the font style
if (fontStyle != null) { if (fontStyle != null) {
if ((fontStyle & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD) { if ((fontStyle & mxConstants.FONT_BOLD) === mxConstants.FONT_BOLD) {
div.style.fontWeight = 'bold'; div.style.fontWeight = 'bold';
} }
if ((fontStyle & mxConstants.FONT_ITALIC) == mxConstants.FONT_ITALIC) { if ((fontStyle & mxConstants.FONT_ITALIC) === mxConstants.FONT_ITALIC) {
div.style.fontStyle = 'italic'; div.style.fontStyle = 'italic';
} }
@ -3350,7 +3350,7 @@ const mxUtils = {
const { drawPane } = view; const { drawPane } = view;
const { overlayPane } = view; const { overlayPane } = view;
if (graph.dialect == mxConstants.DIALECT_SVG) { if (graph.dialect === mxConstants.DIALECT_SVG) {
view.drawPane = document.createElementNS(mxConstants.NS_SVG, 'g'); view.drawPane = document.createElementNS(mxConstants.NS_SVG, 'g');
view.canvas.appendChild(view.drawPane); view.canvas.appendChild(view.drawPane);

View File

@ -539,7 +539,7 @@ class mxCellRenderer {
if ( if (
mxClient.IS_SVG && mxClient.IS_SVG &&
mxClient.NO_FO && mxClient.NO_FO &&
shape.dialect != mxConstants.DIALECT_SVG shape.dialect !== mxConstants.DIALECT_SVG
) { ) {
shape.init(state.view.graph.container); shape.init(state.view.graph.container);
} else { } else {

View File

@ -180,11 +180,11 @@ const mxEdgeStyle = {
); );
if ( if (
constraint != mxConstants.DIRECTION_MASK_NONE && constraint !== mxConstants.DIRECTION_MASK_NONE &&
constraint != constraint !=
mxConstants.DIRECTION_MASK_WEST + mxConstants.DIRECTION_MASK_EAST mxConstants.DIRECTION_MASK_WEST + mxConstants.DIRECTION_MASK_EAST
) { ) {
isTargetLeft = constraint == mxConstants.DIRECTION_MASK_WEST; isTargetLeft = constraint === mxConstants.DIRECTION_MASK_WEST;
} }
} }

View File

@ -1638,9 +1638,9 @@ class mxGraph extends mxEventSource {
if (mxClient.IS_SVG) { if (mxClient.IS_SVG) {
this.dialect = mxConstants.DIALECT_SVG; this.dialect = mxConstants.DIALECT_SVG;
} else if (renderHint == mxConstants.RENDERING_HINT_FASTEST) { } else if (renderHint === mxConstants.RENDERING_HINT_FASTEST) {
this.dialect = mxConstants.DIALECT_STRICTHTML; this.dialect = mxConstants.DIALECT_STRICTHTML;
} else if (renderHint == mxConstants.RENDERING_HINT_FASTER) { } else if (renderHint === mxConstants.RENDERING_HINT_FASTER) {
this.dialect = mxConstants.DIALECT_PREFERHTML; this.dialect = mxConstants.DIALECT_PREFERHTML;
} // default for VML } // default for VML
else { else {
@ -2833,7 +2833,7 @@ class mxGraph extends mxEventSource {
c.scrollTop += border - dy; c.scrollTop += border - dy;
if (old == c.scrollTop && extend) { if (old == c.scrollTop && extend) {
if (this.dialect == mxConstants.DIALECT_SVG) { if (this.dialect === mxConstants.DIALECT_SVG) {
const root = this.view.getDrawPane().ownerSVGElement; const root = this.view.getDrawPane().ownerSVGElement;
const height = this.container.scrollHeight + border - dy; const height = this.container.scrollHeight + border - dy;
@ -3140,7 +3140,7 @@ class mxGraph extends mxEventSource {
width = Math.ceil(width); width = Math.ceil(width);
height = Math.ceil(height); height = Math.ceil(height);
if (this.dialect == mxConstants.DIALECT_SVG) { if (this.dialect === mxConstants.DIALECT_SVG) {
const root = this.view.getDrawPane().ownerSVGElement; const root = this.view.getDrawPane().ownerSVGElement;
if (root != null) { if (root != null) {
@ -3665,7 +3665,7 @@ class mxGraph extends mxEventSource {
* let style = this.getCurrentCellStyle(edge); * let style = this.getCurrentCellStyle(edge);
* let elbow = mxUtils.getValue(style, mxConstants.STYLE_ELBOW, * let elbow = mxUtils.getValue(style, mxConstants.STYLE_ELBOW,
* mxConstants.ELBOW_HORIZONTAL); * mxConstants.ELBOW_HORIZONTAL);
* let value = (elbow == mxConstants.ELBOW_HORIZONTAL) ? * let value = (elbow === mxConstants.ELBOW_HORIZONTAL) ?
* mxConstants.ELBOW_VERTICAL : mxConstants.ELBOW_HORIZONTAL; * mxConstants.ELBOW_VERTICAL : mxConstants.ELBOW_HORIZONTAL;
* this.setCellStyles(mxConstants.STYLE_ELBOW, value, [edge]); * this.setCellStyles(mxConstants.STYLE_ELBOW, value, [edge]);
* } * }
@ -6888,11 +6888,11 @@ class mxGraph extends mxEventSource {
1 1
) == 1 ) == 1
) { ) {
if (direction == mxConstants.DIRECTION_NORTH) { if (direction === mxConstants.DIRECTION_NORTH) {
r1 += 270; r1 += 270;
} else if (direction == mxConstants.DIRECTION_WEST) { } else if (direction === mxConstants.DIRECTION_WEST) {
r1 += 180; r1 += 180;
} else if (direction == mxConstants.DIRECTION_SOUTH) { } else if (direction === mxConstants.DIRECTION_SOUTH) {
r1 += 90; r1 += 90;
} }