- 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

@@ -149,7 +149,7 @@
return;
}
this.parentNode.removeChild(this);
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
}
};
mixin(DocumentType, ChildNode);

View File

@@ -73,16 +73,10 @@ var svgEditorExtension_grid = (function () {
var rawM = 100 / uMulti;
var multi = 1;
for (var i = 0; i < intervals.length; i++) {
var num = intervals[i];
intervals.some(function (num) {
multi = num;
if (rawM <= num) {
break;
}
}
return rawM <= num;
});
var bigInt = multi * uMulti; // Set the canvas size to the width of the container
hcanvas.width = bigInt;
@@ -93,8 +87,8 @@ var svgEditorExtension_grid = (function () {
ctx.globalAlpha = 0.2;
ctx.strokeStyle = svgEditor.curConfig.gridColor;
for (var _i = 1; _i < 10; _i++) {
var subD = Math.round(part * _i) + 0.5; // const lineNum = (i % 2)?12:10;
for (var i = 1; i < 10; i++) {
var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10;
var lineNum = 0;
ctx.moveTo(subD, bigInt);

85
dist/index-es.js vendored
View File

@@ -6286,21 +6286,21 @@ function () {
}, {
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 = [];
@@ -6308,11 +6308,9 @@ function () {
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]);
@@ -10843,6 +10841,8 @@ function () {
}, {
key: "cloneLayer",
value: function cloneLayer(name, hrService) {
var _this = this;
if (!this.current_layer) {
return null;
}
@@ -10858,17 +10858,15 @@ function () {
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');
@@ -16457,9 +16455,9 @@ function SvgCanvas(container, config) {
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) {
@@ -18737,10 +18735,29 @@ function SvgCanvas(container, config) {
}
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
@@ -31398,8 +31415,7 @@ editor.init = function () {
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)) {
@@ -31414,8 +31430,7 @@ editor.init = function () {
// || 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)
@@ -34235,10 +34250,10 @@ editor.init = function () {
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;
@@ -34363,11 +34378,11 @@ editor.init = function () {
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;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

85
dist/index-umd.js vendored
View File

@@ -6292,21 +6292,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 = [];
@@ -6314,11 +6314,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]);
@@ -10849,6 +10847,8 @@
}, {
key: "cloneLayer",
value: function cloneLayer(name, hrService) {
var _this = this;
if (!this.current_layer) {
return null;
}
@@ -10864,17 +10864,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');
@@ -16463,9 +16461,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) {
@@ -18743,10 +18741,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
@@ -31404,8 +31421,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)) {
@@ -31420,8 +31436,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)
@@ -34241,10 +34256,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;
@@ -34369,11 +34384,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;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6348,21 +6348,21 @@ var SvgCanvas = (function () {
}, {
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 = [];
@@ -6370,11 +6370,9 @@ var SvgCanvas = (function () {
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]);
@@ -10410,6 +10408,8 @@ var SvgCanvas = (function () {
}, {
key: "cloneLayer",
value: function cloneLayer(name, hrService) {
var _this = this;
if (!this.current_layer) {
return null;
}
@@ -10425,17 +10425,15 @@ var SvgCanvas = (function () {
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');
@@ -16235,9 +16233,9 @@ var SvgCanvas = (function () {
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) {
@@ -18515,10 +18513,29 @@ var SvgCanvas = (function () {
}
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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long