- Linting (ESLint): Stricter rules (or switch to warning)

- Breaking internal API change: `updateGripCursor` moved to be class method of Selector rather than instance method
- Breaking internal API change: `subpathIsClosed` moved to be class method of `Path` rather than instance method
- Refactoring: Reuse utilities base64 encoder for SVG icons plugin
- Docs (JSDoc): Fix return of the `mouseUp` (can also be an object) and `mouseDown` (may also be a boolean) of `pathActions`; other JSDoc additions/improvements
This commit is contained in:
Brett Zamir
2018-11-07 14:51:50 +08:00
parent 901c9547fe
commit 7c470e9909
126 changed files with 2081 additions and 1373 deletions

View File

@@ -12,7 +12,11 @@ import {supportsNativeTransformLists} from './browser.js';
const svgroot = document.createElementNS(NS.SVG, 'svg');
// Helper function.
/**
* Helper function to convert `SVGTransform` to a string.
* @param {SVGTransform} xform
* @returns {string}
*/
function transformToString (xform) {
const m = xform.matrix;
let text = '';
@@ -114,8 +118,9 @@ let listMap_ = {};
* These methods do not currently raise any exceptions.
* These methods also do not check that transforms are being inserted. This is basically
* implementing as much of SVGTransformList that we need to get the job done.
* @implements {module:SVGTransformList.SVGEditTransformList}
*/
export class SVGTransformList {
export class SVGTransformList {// eslint-disable-line no-shadow
/**
* @param {Element} elem
*/
@@ -170,7 +175,7 @@ export class SVGTransformList {
} else if (name === 'rotate' && values.length === 1) {
values.push(0, 0);
}
xform[fname].apply(xform, values);
xform[fname](...values);
this._list.appendItem(xform);
}
}
@@ -179,20 +184,15 @@ export class SVGTransformList {
if (item) {
// Check if this transform is already in a transformlist, and
// remove it if so.
let found = false;
for (const id in listMap_) {
const tl = listMap_[id];
Object.values(listMap_).some((tl) => {
for (let i = 0, len = tl._xforms.length; i < len; ++i) {
if (tl._xforms[i] === item) {
found = true;
tl.removeItem(i);
break;
return true;
}
}
if (found) {
break;
}
}
return false;
});
}
};
@@ -330,7 +330,7 @@ export const resetListMap = function () {
* @param {Element} elem - a DOM Element
* @returns {undefined}
*/
export let removeElementFromListMap = function (elem) {
export let removeElementFromListMap = function (elem) { // eslint-disable-line import/no-mutable-exports
if (elem.id && listMap_[elem.id]) {
delete listMap_[elem.id];
}
@@ -377,6 +377,7 @@ export const getTransformList = function (elem) {
* @param {module:SVGTransformList.removeElementFromListMap} cb Passed a single argument `elem`
* @returns {undefined}
*/
export const changeRemoveElementFromListMap = function (cb) {
export const changeRemoveElementFromListMap = function (cb) { // eslint-disable-line promise/prefer-await-to-callbacks
removeElementFromListMap = cb;
};