- Linting (ESLint): Update polyfills to new compat rules of

eslint-config-ash-nazg and adhere to new rules (prefer `for-of`
  (or array methods) to `for`, catch preferred `includes` to `indexOf`);
  avoid `no-zero-fractions` rule for now
- npm: Update devDeps (removing one unneeded)
This commit is contained in:
Brett Zamir
2019-03-31 17:39:19 +08:00
parent 28c0c60bb8
commit 1ae6e91bb0
26 changed files with 2311 additions and 1863 deletions

View File

@@ -574,12 +574,11 @@ export class Drawing {
const group = layer.getGroup();
// Clone children
const children = currentGroup.childNodes;
for (let index = 0; index < children.length; index++) {
const ch = children[index];
if (ch.localName === 'title') { continue; }
group.append(this.copyElem(ch));
}
const children = [...currentGroup.childNodes];
children.forEach((child) => {
if (child.localName === 'title') { return; }
group.append(this.copyElem(child));
});
if (hrService) {
hrService.startBatchCommand('Duplicate Layer');

View File

@@ -83,13 +83,10 @@ export default {
// Calculate the main number interval
const rawM = 100 / uMulti;
let multi = 1;
for (let i = 0; i < intervals.length; i++) {
const num = intervals[i];
intervals.some((num) => {
multi = num;
if (rawM <= num) {
break;
}
}
return rawM <= num;
});
const bigInt = multi * uMulti;
// Set the canvas size to the width of the container

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -108,7 +108,7 @@ const ChildNode = {
},
remove () {
if (!this.parentNode) { return; }
this.parentNode.removeChild(this);
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
}
};

View File

@@ -1282,15 +1282,14 @@ export class Path {
*/
addPtsToSelection (indexes) {
if (!Array.isArray(indexes)) { indexes = [indexes]; }
for (let i = 0; i < indexes.length; i++) {
const index = indexes[i];
indexes.forEach((index) => {
const seg = this.segs[index];
if (seg.ptgrip) {
if (!this.selected_pts.includes(index) && index >= 0) {
this.selected_pts.push(index);
}
}
}
});
this.selected_pts.sort();
let i = this.selected_pts.length;
const grips = [];

View File

@@ -2622,9 +2622,7 @@ editor.init = function () {
setSelectMode();
}
for (let i = 0; i < elems.length; ++i) {
const elem = elems[i];
elems.forEach((elem) => {
const isSvgElem = (elem && elem.tagName === 'svg');
if (isSvgElem || isLayer(elem)) {
populateLayers();
@@ -2638,7 +2636,7 @@ editor.init = function () {
// || elem && elem.tagName == "path" && !multiselected) { // This was added in r1430, but not sure why
selectedElement = elem;
}
}
});
editor.showSaveWarning = true;

View File

@@ -2681,9 +2681,9 @@ const mouseUp = function (evt) {
const coords = element.getAttribute('points');
const commaIndex = coords.indexOf(',');
if (commaIndex >= 0) {
keep = coords.indexOf(',', commaIndex + 1) >= 0;
keep = coords.includes(',', commaIndex + 1);
} else {
keep = coords.indexOf(' ', coords.indexOf(' ') + 1) >= 0;
keep = coords.includes(' ', coords.indexOf(' ') + 1);
}
if (keep) {
element = pathActions.smoothPolylineIntoPath(element);
@@ -4736,8 +4736,7 @@ this.importSvgString = function (xmlString) {
symbol.append(first);
}
const attrs = svg.attributes;
for (let i = 0; i < attrs.length; i++) {
const attr = attrs[i];
for (const attr of attrs) { // Ok for `NamedNodeMap`
symbol.setAttribute(attr.nodeName, attr.value);
}
symbol.id = getNextId();

View File

@@ -6289,21 +6289,21 @@
}, {
key: "addPtsToSelection",
value: function addPtsToSelection(indexes) {
var _this = this;
if (!Array.isArray(indexes)) {
indexes = [indexes];
}
for (var _i4 = 0; _i4 < indexes.length; _i4++) {
var index = indexes[_i4];
var seg = this.segs[index];
indexes.forEach(function (index) {
var seg = _this.segs[index];
if (seg.ptgrip) {
if (!this.selected_pts.includes(index) && index >= 0) {
this.selected_pts.push(index);
if (!_this.selected_pts.includes(index) && index >= 0) {
_this.selected_pts.push(index);
}
}
}
});
this.selected_pts.sort();
var i = this.selected_pts.length;
var grips = [];
@@ -6311,11 +6311,9 @@
while (i--) {
var pt = this.selected_pts[i];
var _seg2 = this.segs[pt];
_seg2.select(true);
grips[i] = _seg2.ptgrip;
var seg = this.segs[pt];
seg.select(true);
grips[i] = seg.ptgrip;
}
var closedSubpath = Path.subpathIsClosed(this.selected_pts[0]);
@@ -10846,6 +10844,8 @@
}, {
key: "cloneLayer",
value: function cloneLayer(name, hrService) {
var _this = this;
if (!this.current_layer) {
return null;
}
@@ -10861,17 +10861,15 @@
var layer = new Layer(name, currentGroup, this.svgElem_);
var group = layer.getGroup(); // Clone children
var children = currentGroup.childNodes;
var children = _toConsumableArray(currentGroup.childNodes);
for (var _index = 0; _index < children.length; _index++) {
var ch = children[_index];
if (ch.localName === 'title') {
continue;
children.forEach(function (child) {
if (child.localName === 'title') {
return;
}
group.append(this.copyElem(ch));
}
group.append(_this.copyElem(child));
});
if (hrService) {
hrService.startBatchCommand('Duplicate Layer');
@@ -16460,9 +16458,9 @@
var commaIndex = coords.indexOf(',');
if (commaIndex >= 0) {
keep = coords.indexOf(',', commaIndex + 1) >= 0;
keep = coords.includes(',', commaIndex + 1);
} else {
keep = coords.indexOf(' ', coords.indexOf(' ') + 1) >= 0;
keep = coords.includes(' ', coords.indexOf(' ') + 1);
}
if (keep) {
@@ -18740,10 +18738,29 @@
}
var attrs = svg.attributes;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
symbol.setAttribute(attr.nodeName, attr.value);
try {
for (var _iterator = attrs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var attr = _step.value;
// Ok for `NamedNodeMap`
symbol.setAttribute(attr.nodeName, attr.value);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
symbol.id = getNextId(); // Store data
@@ -31401,8 +31418,7 @@
setSelectMode();
}
for (var _i = 0; _i < elems.length; ++_i) {
var elem = elems[_i];
elems.forEach(function (elem) {
var isSvgElem = elem && elem.tagName === 'svg';
if (isSvgElem || isLayer(elem)) {
@@ -31417,8 +31433,7 @@
// || elem && elem.tagName == "path" && !multiselected) { // This was added in r1430, but not sure why
selectedElement = elem;
}
}
});
editor.showSaveWarning = true; // we update the contextual panel with potentially new
// positional/sizing information (we DON'T want to update the
// toolbar here as that creates an infinite loop)
@@ -34238,10 +34253,10 @@
if (isMac() && !window.opera) {
var shortcutButtons = ['tool_clear', 'tool_save', 'tool_source', 'tool_undo', 'tool_redo', 'tool_clone'];
var _i2 = shortcutButtons.length;
var _i = shortcutButtons.length;
while (_i2--) {
var button = document.getElementById(shortcutButtons[_i2]);
while (_i--) {
var button = document.getElementById(shortcutButtons[_i]);
if (button) {
var title = button.title;
@@ -34366,11 +34381,11 @@
var childs = selectedElement.getElementsByTagName('*');
var gPaint = null;
for (var _i3 = 0, len = childs.length; _i3 < len; _i3++) {
var elem = childs[_i3];
for (var _i2 = 0, len = childs.length; _i2 < len; _i2++) {
var elem = childs[_i2];
var p = elem.getAttribute(type);
if (_i3 === 0) {
if (_i2 === 0) {
gPaint = p;
} else if (gPaint !== p) {
gPaint = null;