diff --git a/cypress/support/assert-close.js b/cypress/support/assert-close.js index e0639480..f5947f2d 100644 --- a/cypress/support/assert-close.js +++ b/cypress/support/assert-close.js @@ -1,4 +1,3 @@ -/* eslint-disable jsdoc/check-examples */ import assertionWrapper from './assertion-wrapper.js'; /** diff --git a/src/editor/xdomain-svgedit-config-iife.js b/src/editor/xdomain-svgedit-config-iife.js index e3e8d804..a2ca06a8 100644 --- a/src/editor/xdomain-svgedit-config-iife.js +++ b/src/editor/xdomain-svgedit-config-iife.js @@ -20866,14 +20866,10 @@ * @returns {void} */ + if (elem.children) elem.children.forEach(child => checkIDs(child)); + } - this.pasteElements = function (type, x, y) { - var clipb = JSON.parse(sessionStorage.getItem(CLIPBOARD_ID)); - if (!clipb) return; - var len = clipb.length; - if (!len) return; - var pasted = []; - var batchCmd = new BatchCommand$1('Paste elements'); // const drawing = getCurrentDrawing(); + clipb.forEach(elem => checkIDs(elem)); // Give extensions like the connector extension a chance to reflect new IDs and remove invalid elements /** * @typedef {PlainObject} module:svgcanvas.ChangedIDs diff --git a/src/external/dom-polyfill/dom-polyfill.js b/src/external/dom-polyfill/dom-polyfill.js index 839e4968..73a8e002 100644 --- a/src/external/dom-polyfill/dom-polyfill.js +++ b/src/external/dom-polyfill/dom-polyfill.js @@ -42,6 +42,7 @@ function convertNodesIntoANode (nodes) { } const node = document.createDocumentFragment(); nodes.forEach((n) => { + // // eslint-disable-next-line unicorn/prefer-node-append node.appendChild(n); }); return node; @@ -54,6 +55,7 @@ const ParentNode = { }, append (...nodes) { nodes = convertNodesIntoANode(nodes); + // // eslint-disable-next-line unicorn/prefer-node-append this.appendChild(nodes); } }; diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index 1c746614..ec0926eb 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -6443,9 +6443,9 @@ this.pasteElements = function (type, x, y) { changedIDs[elem.attr.id] = getNextId(); elem.attr.id = changedIDs[elem.attr.id]; } - if (elem.children) elem.children.forEach(checkIDs); + if (elem.children) elem.children.forEach((child) => checkIDs(child)); } - clipb.forEach(checkIDs); + clipb.forEach((elem) => checkIDs(elem)); // Give extensions like the connector extension a chance to reflect new IDs and remove invalid elements /** diff --git a/svgedit-config-iife.js b/svgedit-config-iife.js index cb4a6e87..182527cd 100644 --- a/svgedit-config-iife.js +++ b/svgedit-config-iife.js @@ -1,336 +1,6 @@ (function () { 'use strict'; - function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } - } - - function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - - _next(undefined); - }); - }; - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); - } - - function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; - } - - function _possibleConstructorReturn(self, call) { - if (call && (typeof call === "object" || typeof call === "function")) { - return call; - } - - return _assertThisInitialized(self); - } - - function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - - return _possibleConstructorReturn(this, result); - }; - } - - function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = _getPrototypeOf(object); - if (object === null) break; - } - - return object; - } - - function _get(target, property, receiver) { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get; - } else { - _get = function _get(target, property, receiver) { - var base = _superPropBase(target, property); - - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - - if (desc.get) { - return desc.get.call(receiver); - } - - return desc.value; - }; - } - - return _get(target, property, receiver || target); - } - - function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); - } - - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); - } - - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) return _arrayLikeToArray(arr); - } - - function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; - } - - function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); - } - - function _iterableToArrayLimit(arr, i) { - if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); - } - - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; - } - - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - function _createForOfIteratorHelper(o, allowArrayLike) { - var it; - - if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { - if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { - if (it) o = it; - var i = 0; - - var F = function () {}; - - return { - s: F, - n: function () { - if (i >= o.length) return { - done: true - }; - return { - done: false, - value: o[i++] - }; - }, - e: function (e) { - throw e; - }, - f: F - }; - } - - throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - var normalCompletion = true, - didErr = false, - err; - return { - s: function () { - it = o[Symbol.iterator](); - }, - n: function () { - var step = it.next(); - normalCompletion = step.done; - return step; - }, - e: function (e) { - didErr = true; - err = e; - }, - f: function () { - try { - if (!normalCompletion && it.return != null) it.return(); - } finally { - if (didErr) throw err; - } - } - }; - } - // http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript/ /** @@ -339,9 +9,11 @@ * @returns {void} */ function touchHandler(ev) { - var changedTouches = ev.changedTouches, - first = changedTouches[0]; - var type = ''; + const { + changedTouches + } = ev, + first = changedTouches[0]; + let type = ''; switch (ev.type) { case 'touchstart': @@ -360,12 +32,14 @@ return; } - var screenX = first.screenX, - screenY = first.screenY, - clientX = first.clientX, - clientY = first.clientY; // eslint-disable-line no-shadow + const { + screenX, + screenY, + clientX, + clientY + } = first; // eslint-disable-line no-shadow - var simulatedEvent = new MouseEvent(type, { + const simulatedEvent = new MouseEvent(type, { // Event interface bubbles: true, cancelable: true, @@ -374,10 +48,10 @@ detail: 1, // click count // MouseEvent interface (customized) - screenX: screenX, - screenY: screenY, - clientX: clientX, - clientY: clientY, + screenX, + screenY, + clientX, + clientY, // MouseEvent interface (defaults) - these could be removed ctrlKey: false, altKey: false, @@ -411,7 +85,7 @@ * @type {PlainObject} * @memberof module:namespaces */ - var NS = { + const NS = { HTML: 'http://www.w3.org/1999/xhtml', MATH: 'http://www.w3.org/1998/Math/MathML', SE: 'http://svg-edit.googlecode.com', @@ -426,19 +100,15 @@ * @returns {string} The NS with key values switched and lowercase */ - var getReverseNS = function getReverseNS() { - var reverseNS = {}; - Object.entries(NS).forEach(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - name = _ref2[0], - URI = _ref2[1]; - + const getReverseNS = function () { + const reverseNS = {}; + Object.entries(NS).forEach(([name, URI]) => { reverseNS[URI] = name.toLowerCase(); }); return reverseNS; }; - /* eslint-disable import/unambiguous, max-len */ + /* eslint-disable import/unambiguous */ /* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs, SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs, @@ -464,1513 +134,1341 @@ // Linting: We avoid `no-shadow` as ESLint thinks these are still available globals // Linting: We avoid `class-methods-use-this` as this is a polyfill that must // follow the conventions - (function () { + (() => { if (!('SVGPathSeg' in window)) { // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg - var _SVGPathSeg = /*#__PURE__*/function () { - function _SVGPathSeg(type, typeAsLetter, owningPathSegList) { - _classCallCheck(this, _SVGPathSeg); - + class SVGPathSeg { + constructor(type, typeAsLetter, owningPathSegList) { this.pathSegType = type; this.pathSegTypeAsLetter = typeAsLetter; this._owningPathSegList = owningPathSegList; } // Notify owning PathSegList on any changes so they can be synchronized back to the path element. - _createClass(_SVGPathSeg, [{ - key: "_segmentChanged", - value: function _segmentChanged() { - if (this._owningPathSegList) { - this._owningPathSegList.segmentChanged(this); - } + _segmentChanged() { + if (this._owningPathSegList) { + this._owningPathSegList.segmentChanged(this); } - }]); - - return _SVGPathSeg; - }(); - - _SVGPathSeg.prototype.classname = 'SVGPathSeg'; - _SVGPathSeg.PATHSEG_UNKNOWN = 0; - _SVGPathSeg.PATHSEG_CLOSEPATH = 1; - _SVGPathSeg.PATHSEG_MOVETO_ABS = 2; - _SVGPathSeg.PATHSEG_MOVETO_REL = 3; - _SVGPathSeg.PATHSEG_LINETO_ABS = 4; - _SVGPathSeg.PATHSEG_LINETO_REL = 5; - _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; - _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; - _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; - _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; - _SVGPathSeg.PATHSEG_ARC_ABS = 10; - _SVGPathSeg.PATHSEG_ARC_REL = 11; - _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; - _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; - _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; - _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; - _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; - _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; - _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; - _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; - - var _SVGPathSegClosePath = /*#__PURE__*/function (_SVGPathSeg2) { - _inherits(_SVGPathSegClosePath, _SVGPathSeg2); - - var _super = _createSuper(_SVGPathSegClosePath); - - function _SVGPathSegClosePath(owningPathSegList) { - _classCallCheck(this, _SVGPathSegClosePath); - - return _super.call(this, _SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); } - _createClass(_SVGPathSegClosePath, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegClosePath]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegClosePath(undefined); - } - }]); + } - return _SVGPathSegClosePath; - }(_SVGPathSeg); + SVGPathSeg.prototype.classname = 'SVGPathSeg'; + SVGPathSeg.PATHSEG_UNKNOWN = 0; + SVGPathSeg.PATHSEG_CLOSEPATH = 1; + SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + SVGPathSeg.PATHSEG_MOVETO_REL = 3; + SVGPathSeg.PATHSEG_LINETO_ABS = 4; + SVGPathSeg.PATHSEG_LINETO_REL = 5; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + SVGPathSeg.PATHSEG_ARC_ABS = 10; + SVGPathSeg.PATHSEG_ARC_REL = 11; + SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; - var _SVGPathSegMovetoAbs = /*#__PURE__*/function (_SVGPathSeg3) { - _inherits(_SVGPathSegMovetoAbs, _SVGPathSeg3); - - var _super2 = _createSuper(_SVGPathSegMovetoAbs); - - function _SVGPathSegMovetoAbs(owningPathSegList, x, y) { - var _this; - - _classCallCheck(this, _SVGPathSegMovetoAbs); - - _this = _super2.call(this, _SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); - _this._x = x; - _this._y = y; - return _this; + class SVGPathSegClosePath extends SVGPathSeg { + constructor(owningPathSegList) { + super(SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); } - _createClass(_SVGPathSegMovetoAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegMovetoAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegMovetoAbs(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegClosePath]'; + } - return _SVGPathSegMovetoAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter; + } - Object.defineProperties(_SVGPathSegMovetoAbs.prototype, { + clone() { + return new SVGPathSegClosePath(undefined); + } + + } + + class SVGPathSegMovetoAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + this._x = x; + this._y = y; + } + + toString() { + return '[object SVGPathSegMovetoAbs]'; + } + + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } + + clone() { + return new SVGPathSegMovetoAbs(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegMovetoAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegMovetoRel = /*#__PURE__*/function (_SVGPathSeg4) { - _inherits(_SVGPathSegMovetoRel, _SVGPathSeg4); - - var _super3 = _createSuper(_SVGPathSegMovetoRel); - - function _SVGPathSegMovetoRel(owningPathSegList, x, y) { - var _this2; - - _classCallCheck(this, _SVGPathSegMovetoRel); - - _this2 = _super3.call(this, _SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); - _this2._x = x; - _this2._y = y; - return _this2; + class SVGPathSegMovetoRel extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + this._x = x; + this._y = y; } - _createClass(_SVGPathSegMovetoRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegMovetoRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegMovetoRel(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegMovetoRel]'; + } - return _SVGPathSegMovetoRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegMovetoRel.prototype, { + clone() { + return new SVGPathSegMovetoRel(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegMovetoRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegLinetoAbs = /*#__PURE__*/function (_SVGPathSeg5) { - _inherits(_SVGPathSegLinetoAbs, _SVGPathSeg5); - - var _super4 = _createSuper(_SVGPathSegLinetoAbs); - - function _SVGPathSegLinetoAbs(owningPathSegList, x, y) { - var _this3; - - _classCallCheck(this, _SVGPathSegLinetoAbs); - - _this3 = _super4.call(this, _SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); - _this3._x = x; - _this3._y = y; - return _this3; + class SVGPathSegLinetoAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + this._x = x; + this._y = y; } - _createClass(_SVGPathSegLinetoAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoAbs(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegLinetoAbs]'; + } - return _SVGPathSegLinetoAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegLinetoAbs.prototype, { + clone() { + return new SVGPathSegLinetoAbs(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegLinetoAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegLinetoRel = /*#__PURE__*/function (_SVGPathSeg6) { - _inherits(_SVGPathSegLinetoRel, _SVGPathSeg6); - - var _super5 = _createSuper(_SVGPathSegLinetoRel); - - function _SVGPathSegLinetoRel(owningPathSegList, x, y) { - var _this4; - - _classCallCheck(this, _SVGPathSegLinetoRel); - - _this4 = _super5.call(this, _SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); - _this4._x = x; - _this4._y = y; - return _this4; + class SVGPathSegLinetoRel extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + this._x = x; + this._y = y; } - _createClass(_SVGPathSegLinetoRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoRel(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegLinetoRel]'; + } - return _SVGPathSegLinetoRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegLinetoRel.prototype, { + clone() { + return new SVGPathSegLinetoRel(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegLinetoRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoCubicAbs = /*#__PURE__*/function (_SVGPathSeg7) { - _inherits(_SVGPathSegCurvetoCubicAbs, _SVGPathSeg7); - - var _super6 = _createSuper(_SVGPathSegCurvetoCubicAbs); - - function _SVGPathSegCurvetoCubicAbs(owningPathSegList, x, y, x1, y1, x2, y2) { - var _this5; - - _classCallCheck(this, _SVGPathSegCurvetoCubicAbs); - - _this5 = _super6.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); - _this5._x = x; - _this5._y = y; - _this5._x1 = x1; - _this5._y1 = y1; - _this5._x2 = x2; - _this5._y2 = y2; - return _this5; + class SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y, x1, y1, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; } - _createClass(_SVGPathSegCurvetoCubicAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoCubicAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); - } - }]); + toString() { + return '[object SVGPathSegCurvetoCubicAbs]'; + } - return _SVGPathSegCurvetoCubicAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoCubicAbs.prototype, { + clone() { + return new SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + + } + + Object.defineProperties(SVGPathSegCurvetoCubicAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x1: { - get: function get() { + get() { return this._x1; }, - set: function set(x1) { + + set(x1) { this._x1 = x1; this._segmentChanged(); }, + enumerable: true }, y1: { - get: function get() { + get() { return this._y1; }, - set: function set(y1) { + + set(y1) { this._y1 = y1; this._segmentChanged(); }, + enumerable: true }, x2: { - get: function get() { + get() { return this._x2; }, - set: function set(x2) { + + set(x2) { this._x2 = x2; this._segmentChanged(); }, + enumerable: true }, y2: { - get: function get() { + get() { return this._y2; }, - set: function set(y2) { + + set(y2) { this._y2 = y2; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoCubicRel = /*#__PURE__*/function (_SVGPathSeg8) { - _inherits(_SVGPathSegCurvetoCubicRel, _SVGPathSeg8); - - var _super7 = _createSuper(_SVGPathSegCurvetoCubicRel); - - function _SVGPathSegCurvetoCubicRel(owningPathSegList, x, y, x1, y1, x2, y2) { - var _this6; - - _classCallCheck(this, _SVGPathSegCurvetoCubicRel); - - _this6 = _super7.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); - _this6._x = x; - _this6._y = y; - _this6._x1 = x1; - _this6._y1 = y1; - _this6._x2 = x2; - _this6._y2 = y2; - return _this6; + class SVGPathSegCurvetoCubicRel extends SVGPathSeg { + constructor(owningPathSegList, x, y, x1, y1, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; } - _createClass(_SVGPathSegCurvetoCubicRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoCubicRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); - } - }]); + toString() { + return '[object SVGPathSegCurvetoCubicRel]'; + } - return _SVGPathSegCurvetoCubicRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoCubicRel.prototype, { + clone() { + return new SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + } + + } + + Object.defineProperties(SVGPathSegCurvetoCubicRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x1: { - get: function get() { + get() { return this._x1; }, - set: function set(x1) { + + set(x1) { this._x1 = x1; this._segmentChanged(); }, + enumerable: true }, y1: { - get: function get() { + get() { return this._y1; }, - set: function set(y1) { + + set(y1) { this._y1 = y1; this._segmentChanged(); }, + enumerable: true }, x2: { - get: function get() { + get() { return this._x2; }, - set: function set(x2) { + + set(x2) { this._x2 = x2; this._segmentChanged(); }, + enumerable: true }, y2: { - get: function get() { + get() { return this._y2; }, - set: function set(y2) { + + set(y2) { this._y2 = y2; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoQuadraticAbs = /*#__PURE__*/function (_SVGPathSeg9) { - _inherits(_SVGPathSegCurvetoQuadraticAbs, _SVGPathSeg9); - - var _super8 = _createSuper(_SVGPathSegCurvetoQuadraticAbs); - - function _SVGPathSegCurvetoQuadraticAbs(owningPathSegList, x, y, x1, y1) { - var _this7; - - _classCallCheck(this, _SVGPathSegCurvetoQuadraticAbs); - - _this7 = _super8.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); - _this7._x = x; - _this7._y = y; - _this7._x1 = x1; - _this7._y1 = y1; - return _this7; + class SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y, x1, y1) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; } - _createClass(_SVGPathSegCurvetoQuadraticAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoQuadraticAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); - } - }]); + toString() { + return '[object SVGPathSegCurvetoQuadraticAbs]'; + } - return _SVGPathSegCurvetoQuadraticAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoQuadraticAbs.prototype, { + clone() { + return new SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); + } + + } + + Object.defineProperties(SVGPathSegCurvetoQuadraticAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x1: { - get: function get() { + get() { return this._x1; }, - set: function set(x1) { + + set(x1) { this._x1 = x1; this._segmentChanged(); }, + enumerable: true }, y1: { - get: function get() { + get() { return this._y1; }, - set: function set(y1) { + + set(y1) { this._y1 = y1; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoQuadraticRel = /*#__PURE__*/function (_SVGPathSeg10) { - _inherits(_SVGPathSegCurvetoQuadraticRel, _SVGPathSeg10); - - var _super9 = _createSuper(_SVGPathSegCurvetoQuadraticRel); - - function _SVGPathSegCurvetoQuadraticRel(owningPathSegList, x, y, x1, y1) { - var _this8; - - _classCallCheck(this, _SVGPathSegCurvetoQuadraticRel); - - _this8 = _super9.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); - _this8._x = x; - _this8._y = y; - _this8._x1 = x1; - _this8._y1 = y1; - return _this8; + class SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + constructor(owningPathSegList, x, y, x1, y1) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; } - _createClass(_SVGPathSegCurvetoQuadraticRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoQuadraticRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); - } - }]); + toString() { + return '[object SVGPathSegCurvetoQuadraticRel]'; + } - return _SVGPathSegCurvetoQuadraticRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoQuadraticRel.prototype, { + clone() { + return new SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); + } + + } + + Object.defineProperties(SVGPathSegCurvetoQuadraticRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x1: { - get: function get() { + get() { return this._x1; }, - set: function set(x1) { + + set(x1) { this._x1 = x1; this._segmentChanged(); }, + enumerable: true }, y1: { - get: function get() { + get() { return this._y1; }, - set: function set(y1) { + + set(y1) { this._y1 = y1; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegArcAbs = /*#__PURE__*/function (_SVGPathSeg11) { - _inherits(_SVGPathSegArcAbs, _SVGPathSeg11); - - var _super10 = _createSuper(_SVGPathSegArcAbs); - - function _SVGPathSegArcAbs(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { - var _this9; - - _classCallCheck(this, _SVGPathSegArcAbs); - - _this9 = _super10.call(this, _SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); - _this9._x = x; - _this9._y = y; - _this9._r1 = r1; - _this9._r2 = r2; - _this9._angle = angle; - _this9._largeArcFlag = largeArcFlag; - _this9._sweepFlag = sweepFlag; - return _this9; + class SVGPathSegArcAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + super(SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; } - _createClass(_SVGPathSegArcAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegArcAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); - } - }]); + toString() { + return '[object SVGPathSegArcAbs]'; + } - return _SVGPathSegArcAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegArcAbs.prototype, { + clone() { + return new SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + + } + + Object.defineProperties(SVGPathSegArcAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, r1: { - get: function get() { + get() { return this._r1; }, - set: function set(r1) { + + set(r1) { this._r1 = r1; this._segmentChanged(); }, + enumerable: true }, r2: { - get: function get() { + get() { return this._r2; }, - set: function set(r2) { + + set(r2) { this._r2 = r2; this._segmentChanged(); }, + enumerable: true }, angle: { - get: function get() { + get() { return this._angle; }, - set: function set(angle) { + + set(angle) { this._angle = angle; this._segmentChanged(); }, + enumerable: true }, largeArcFlag: { - get: function get() { + get() { return this._largeArcFlag; }, - set: function set(largeArcFlag) { + + set(largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, + enumerable: true }, sweepFlag: { - get: function get() { + get() { return this._sweepFlag; }, - set: function set(sweepFlag) { + + set(sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegArcRel = /*#__PURE__*/function (_SVGPathSeg12) { - _inherits(_SVGPathSegArcRel, _SVGPathSeg12); - - var _super11 = _createSuper(_SVGPathSegArcRel); - - function _SVGPathSegArcRel(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { - var _this10; - - _classCallCheck(this, _SVGPathSegArcRel); - - _this10 = _super11.call(this, _SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); - _this10._x = x; - _this10._y = y; - _this10._r1 = r1; - _this10._r2 = r2; - _this10._angle = angle; - _this10._largeArcFlag = largeArcFlag; - _this10._sweepFlag = sweepFlag; - return _this10; + class SVGPathSegArcRel extends SVGPathSeg { + constructor(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + super(SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; } - _createClass(_SVGPathSegArcRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegArcRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); - } - }]); + toString() { + return '[object SVGPathSegArcRel]'; + } - return _SVGPathSegArcRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegArcRel.prototype, { + clone() { + return new SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + } + + } + + Object.defineProperties(SVGPathSegArcRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, r1: { - get: function get() { + get() { return this._r1; }, - set: function set(r1) { + + set(r1) { this._r1 = r1; this._segmentChanged(); }, + enumerable: true }, r2: { - get: function get() { + get() { return this._r2; }, - set: function set(r2) { + + set(r2) { this._r2 = r2; this._segmentChanged(); }, + enumerable: true }, angle: { - get: function get() { + get() { return this._angle; }, - set: function set(angle) { + + set(angle) { this._angle = angle; this._segmentChanged(); }, + enumerable: true }, largeArcFlag: { - get: function get() { + get() { return this._largeArcFlag; }, - set: function set(largeArcFlag) { + + set(largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, + enumerable: true }, sweepFlag: { - get: function get() { + get() { return this._sweepFlag; }, - set: function set(sweepFlag) { + + set(sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegLinetoHorizontalAbs = /*#__PURE__*/function (_SVGPathSeg13) { - _inherits(_SVGPathSegLinetoHorizontalAbs, _SVGPathSeg13); - - var _super12 = _createSuper(_SVGPathSegLinetoHorizontalAbs); - - function _SVGPathSegLinetoHorizontalAbs(owningPathSegList, x) { - var _this11; - - _classCallCheck(this, _SVGPathSegLinetoHorizontalAbs); - - _this11 = _super12.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); - _this11._x = x; - return _this11; + class SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + constructor(owningPathSegList, x) { + super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + this._x = x; } - _createClass(_SVGPathSegLinetoHorizontalAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoHorizontalAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoHorizontalAbs(undefined, this._x); - } - }]); + toString() { + return '[object SVGPathSegLinetoHorizontalAbs]'; + } - return _SVGPathSegLinetoHorizontalAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } - Object.defineProperty(_SVGPathSegLinetoHorizontalAbs.prototype, 'x', { - get: function get() { + clone() { + return new SVGPathSegLinetoHorizontalAbs(undefined, this._x); + } + + } + + Object.defineProperty(SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }); - var _SVGPathSegLinetoHorizontalRel = /*#__PURE__*/function (_SVGPathSeg14) { - _inherits(_SVGPathSegLinetoHorizontalRel, _SVGPathSeg14); - - var _super13 = _createSuper(_SVGPathSegLinetoHorizontalRel); - - function _SVGPathSegLinetoHorizontalRel(owningPathSegList, x) { - var _this12; - - _classCallCheck(this, _SVGPathSegLinetoHorizontalRel); - - _this12 = _super13.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); - _this12._x = x; - return _this12; + class SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + constructor(owningPathSegList, x) { + super(SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + this._x = x; } - _createClass(_SVGPathSegLinetoHorizontalRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoHorizontalRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoHorizontalRel(undefined, this._x); - } - }]); + toString() { + return '[object SVGPathSegLinetoHorizontalRel]'; + } - return _SVGPathSegLinetoHorizontalRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x; + } - Object.defineProperty(_SVGPathSegLinetoHorizontalRel.prototype, 'x', { - get: function get() { + clone() { + return new SVGPathSegLinetoHorizontalRel(undefined, this._x); + } + + } + + Object.defineProperty(SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }); - var _SVGPathSegLinetoVerticalAbs = /*#__PURE__*/function (_SVGPathSeg15) { - _inherits(_SVGPathSegLinetoVerticalAbs, _SVGPathSeg15); - - var _super14 = _createSuper(_SVGPathSegLinetoVerticalAbs); - - function _SVGPathSegLinetoVerticalAbs(owningPathSegList, y) { - var _this13; - - _classCallCheck(this, _SVGPathSegLinetoVerticalAbs); - - _this13 = _super14.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); - _this13._y = y; - return _this13; + class SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + constructor(owningPathSegList, y) { + super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + this._y = y; } - _createClass(_SVGPathSegLinetoVerticalAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoVerticalAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoVerticalAbs(undefined, this._y); - } - }]); + toString() { + return '[object SVGPathSegLinetoVerticalAbs]'; + } - return _SVGPathSegLinetoVerticalAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } - Object.defineProperty(_SVGPathSegLinetoVerticalAbs.prototype, 'y', { - get: function get() { + clone() { + return new SVGPathSegLinetoVerticalAbs(undefined, this._y); + } + + } + + Object.defineProperty(SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }); - var _SVGPathSegLinetoVerticalRel = /*#__PURE__*/function (_SVGPathSeg16) { - _inherits(_SVGPathSegLinetoVerticalRel, _SVGPathSeg16); - - var _super15 = _createSuper(_SVGPathSegLinetoVerticalRel); - - function _SVGPathSegLinetoVerticalRel(owningPathSegList, y) { - var _this14; - - _classCallCheck(this, _SVGPathSegLinetoVerticalRel); - - _this14 = _super15.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); - _this14._y = y; - return _this14; + class SVGPathSegLinetoVerticalRel extends SVGPathSeg { + constructor(owningPathSegList, y) { + super(SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + this._y = y; } - _createClass(_SVGPathSegLinetoVerticalRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegLinetoVerticalRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegLinetoVerticalRel(undefined, this._y); - } - }]); + toString() { + return '[object SVGPathSegLinetoVerticalRel]'; + } - return _SVGPathSegLinetoVerticalRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._y; + } - Object.defineProperty(_SVGPathSegLinetoVerticalRel.prototype, 'y', { - get: function get() { + clone() { + return new SVGPathSegLinetoVerticalRel(undefined, this._y); + } + + } + + Object.defineProperty(SVGPathSegLinetoVerticalRel.prototype, 'y', { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }); - var _SVGPathSegCurvetoCubicSmoothAbs = /*#__PURE__*/function (_SVGPathSeg17) { - _inherits(_SVGPathSegCurvetoCubicSmoothAbs, _SVGPathSeg17); - - var _super16 = _createSuper(_SVGPathSegCurvetoCubicSmoothAbs); - - function _SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, x, y, x2, y2) { - var _this15; - - _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothAbs); - - _this15 = _super16.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); - _this15._x = x; - _this15._y = y; - _this15._x2 = x2; - _this15._y2 = y2; - return _this15; + class SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; } - _createClass(_SVGPathSegCurvetoCubicSmoothAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoCubicSmoothAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); - } - }]); + toString() { + return '[object SVGPathSegCurvetoCubicSmoothAbs]'; + } - return _SVGPathSegCurvetoCubicSmoothAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoCubicSmoothAbs.prototype, { + clone() { + return new SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); + } + + } + + Object.defineProperties(SVGPathSegCurvetoCubicSmoothAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x2: { - get: function get() { + get() { return this._x2; }, - set: function set(x2) { + + set(x2) { this._x2 = x2; this._segmentChanged(); }, + enumerable: true }, y2: { - get: function get() { + get() { return this._y2; }, - set: function set(y2) { + + set(y2) { this._y2 = y2; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoCubicSmoothRel = /*#__PURE__*/function (_SVGPathSeg18) { - _inherits(_SVGPathSegCurvetoCubicSmoothRel, _SVGPathSeg18); - - var _super17 = _createSuper(_SVGPathSegCurvetoCubicSmoothRel); - - function _SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, x, y, x2, y2) { - var _this16; - - _classCallCheck(this, _SVGPathSegCurvetoCubicSmoothRel); - - _this16 = _super17.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); - _this16._x = x; - _this16._y = y; - _this16._x2 = x2; - _this16._y2 = y2; - return _this16; + class SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + constructor(owningPathSegList, x, y, x2, y2) { + super(SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; } - _createClass(_SVGPathSegCurvetoCubicSmoothRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoCubicSmoothRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); - } - }]); + toString() { + return '[object SVGPathSegCurvetoCubicSmoothRel]'; + } - return _SVGPathSegCurvetoCubicSmoothRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoCubicSmoothRel.prototype, { + clone() { + return new SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); + } + + } + + Object.defineProperties(SVGPathSegCurvetoCubicSmoothRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true }, x2: { - get: function get() { + get() { return this._x2; }, - set: function set(x2) { + + set(x2) { this._x2 = x2; this._segmentChanged(); }, + enumerable: true }, y2: { - get: function get() { + get() { return this._y2; }, - set: function set(y2) { + + set(y2) { this._y2 = y2; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoQuadraticSmoothAbs = /*#__PURE__*/function (_SVGPathSeg19) { - _inherits(_SVGPathSegCurvetoQuadraticSmoothAbs, _SVGPathSeg19); - - var _super18 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothAbs); - - function _SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, x, y) { - var _this17; - - _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothAbs); - - _this17 = _super18.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); - _this17._x = x; - _this17._y = y; - return _this17; + class SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + this._x = x; + this._y = y; } - _createClass(_SVGPathSegCurvetoQuadraticSmoothAbs, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; + } - return _SVGPathSegCurvetoQuadraticSmoothAbs; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothAbs.prototype, { + clone() { + return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); - var _SVGPathSegCurvetoQuadraticSmoothRel = /*#__PURE__*/function (_SVGPathSeg20) { - _inherits(_SVGPathSegCurvetoQuadraticSmoothRel, _SVGPathSeg20); - - var _super19 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothRel); - - function _SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, x, y) { - var _this18; - - _classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothRel); - - _this18 = _super19.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); - _this18._x = x; - _this18._y = y; - return _this18; + class SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + constructor(owningPathSegList, x, y) { + super(SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + this._x = x; + this._y = y; } - _createClass(_SVGPathSegCurvetoQuadraticSmoothRel, [{ - key: "toString", - value: function toString() { - return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; - } - }, { - key: "_asPathString", - value: function _asPathString() { - return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; - } - }, { - key: "clone", - value: function clone() { - return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); - } - }]); + toString() { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; + } - return _SVGPathSegCurvetoQuadraticSmoothRel; - }(_SVGPathSeg); + _asPathString() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + } - Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothRel.prototype, { + clone() { + return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); + } + + } + + Object.defineProperties(SVGPathSegCurvetoQuadraticSmoothRel.prototype, { x: { - get: function get() { + get() { return this._x; }, - set: function set(x) { + + set(x) { this._x = x; this._segmentChanged(); }, + enumerable: true }, y: { - get: function get() { + get() { return this._y; }, - set: function set(y) { + + set(y) { this._y = y; this._segmentChanged(); }, + enumerable: true } }); // Add createSVGPathSeg* functions to SVGPathElement. // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement. SVGPathElement.prototype.createSVGPathSegClosePath = function () { - return new _SVGPathSegClosePath(undefined); + return new SVGPathSegClosePath(undefined); }; SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { - return new _SVGPathSegMovetoAbs(undefined, x, y); + return new SVGPathSegMovetoAbs(undefined, x, y); }; SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { - return new _SVGPathSegMovetoRel(undefined, x, y); + return new SVGPathSegMovetoRel(undefined, x, y); }; SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { - return new _SVGPathSegLinetoAbs(undefined, x, y); + return new SVGPathSegLinetoAbs(undefined, x, y); }; SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { - return new _SVGPathSegLinetoRel(undefined, x, y); + return new SVGPathSegLinetoRel(undefined, x, y); }; SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { - return new _SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); + return new SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); }; SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { - return new _SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); + return new SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); }; SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { - return new _SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); + return new SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); }; SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { - return new _SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); + return new SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); }; SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { - return new _SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return new SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); }; SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { - return new _SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + return new SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); }; SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { - return new _SVGPathSegLinetoHorizontalAbs(undefined, x); + return new SVGPathSegLinetoHorizontalAbs(undefined, x); }; SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { - return new _SVGPathSegLinetoHorizontalRel(undefined, x); + return new SVGPathSegLinetoHorizontalRel(undefined, x); }; SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { - return new _SVGPathSegLinetoVerticalAbs(undefined, y); + return new SVGPathSegLinetoVerticalAbs(undefined, y); }; SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { - return new _SVGPathSegLinetoVerticalRel(undefined, y); + return new SVGPathSegLinetoVerticalRel(undefined, y); }; SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { - return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); + return new SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); }; SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { - return new _SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); + return new SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); }; SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { - return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); + return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); }; SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { - return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); + return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); }; if (!('getPathSegAtLength' in SVGPathElement.prototype)) { @@ -1982,9 +1480,9 @@ throw new Error('Invalid arguments.'); } - var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + const measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); measurementElement.setAttribute('d', this.getAttribute('d')); - var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; // If the path is empty, return 0. + let lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; // If the path is empty, return 0. if (lastPathSegment <= 0) { return 0; @@ -2004,26 +1502,26 @@ }; } - window.SVGPathSeg = _SVGPathSeg; - window.SVGPathSegClosePath = _SVGPathSegClosePath; - window.SVGPathSegMovetoAbs = _SVGPathSegMovetoAbs; - window.SVGPathSegMovetoRel = _SVGPathSegMovetoRel; - window.SVGPathSegLinetoAbs = _SVGPathSegLinetoAbs; - window.SVGPathSegLinetoRel = _SVGPathSegLinetoRel; - window.SVGPathSegCurvetoCubicAbs = _SVGPathSegCurvetoCubicAbs; - window.SVGPathSegCurvetoCubicRel = _SVGPathSegCurvetoCubicRel; - window.SVGPathSegCurvetoQuadraticAbs = _SVGPathSegCurvetoQuadraticAbs; - window.SVGPathSegCurvetoQuadraticRel = _SVGPathSegCurvetoQuadraticRel; - window.SVGPathSegArcAbs = _SVGPathSegArcAbs; - window.SVGPathSegArcRel = _SVGPathSegArcRel; - window.SVGPathSegLinetoHorizontalAbs = _SVGPathSegLinetoHorizontalAbs; - window.SVGPathSegLinetoHorizontalRel = _SVGPathSegLinetoHorizontalRel; - window.SVGPathSegLinetoVerticalAbs = _SVGPathSegLinetoVerticalAbs; - window.SVGPathSegLinetoVerticalRel = _SVGPathSegLinetoVerticalRel; - window.SVGPathSegCurvetoCubicSmoothAbs = _SVGPathSegCurvetoCubicSmoothAbs; - window.SVGPathSegCurvetoCubicSmoothRel = _SVGPathSegCurvetoCubicSmoothRel; - window.SVGPathSegCurvetoQuadraticSmoothAbs = _SVGPathSegCurvetoQuadraticSmoothAbs; - window.SVGPathSegCurvetoQuadraticSmoothRel = _SVGPathSegCurvetoQuadraticSmoothRel; + window.SVGPathSeg = SVGPathSeg; + window.SVGPathSegClosePath = SVGPathSegClosePath; + window.SVGPathSegMovetoAbs = SVGPathSegMovetoAbs; + window.SVGPathSegMovetoRel = SVGPathSegMovetoRel; + window.SVGPathSegLinetoAbs = SVGPathSegLinetoAbs; + window.SVGPathSegLinetoRel = SVGPathSegLinetoRel; + window.SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs; + window.SVGPathSegCurvetoCubicRel = SVGPathSegCurvetoCubicRel; + window.SVGPathSegCurvetoQuadraticAbs = SVGPathSegCurvetoQuadraticAbs; + window.SVGPathSegCurvetoQuadraticRel = SVGPathSegCurvetoQuadraticRel; + window.SVGPathSegArcAbs = SVGPathSegArcAbs; + window.SVGPathSegArcRel = SVGPathSegArcRel; + window.SVGPathSegLinetoHorizontalAbs = SVGPathSegLinetoHorizontalAbs; + window.SVGPathSegLinetoHorizontalRel = SVGPathSegLinetoHorizontalRel; + window.SVGPathSegLinetoVerticalAbs = SVGPathSegLinetoVerticalAbs; + window.SVGPathSegLinetoVerticalRel = SVGPathSegLinetoVerticalRel; + window.SVGPathSegCurvetoCubicSmoothAbs = SVGPathSegCurvetoCubicSmoothAbs; + window.SVGPathSegCurvetoCubicSmoothRel = SVGPathSegCurvetoCubicSmoothRel; + window.SVGPathSegCurvetoQuadraticSmoothAbs = SVGPathSegCurvetoQuadraticSmoothAbs; + window.SVGPathSegCurvetoQuadraticSmoothRel = SVGPathSegCurvetoQuadraticSmoothRel; } // Checking for SVGPathSegList in window checks for the case of an implementation without the // SVGPathSegList API. // The second check for appendItem is specific to Firefox 59+ which removed only parts of the @@ -2033,10 +1531,8 @@ if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) { // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList - var SVGPathSegList = /*#__PURE__*/function () { - function SVGPathSegList(pathElement) { - _classCallCheck(this, SVGPathSegList); - + class SVGPathSegList { + constructor(pathElement) { this._pathElement = pathElement; this._list = this._parsePath(this._pathElement.getAttribute('d')); // Use a MutationObserver to catch changes to the path's "d" attribute. @@ -2052,706 +1548,672 @@ // MutationObservers are not synchronous so we can have pending asynchronous mutations. - _createClass(SVGPathSegList, [{ - key: "_checkPathSynchronizedToList", - value: function _checkPathSynchronizedToList() { - this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + _checkPathSynchronizedToList() { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + } + + _updateListFromPathMutations(mutationRecords) { + if (!this._pathElement) { + return; } - }, { - key: "_updateListFromPathMutations", - value: function _updateListFromPathMutations(mutationRecords) { - if (!this._pathElement) { - return; + + let hasPathMutations = false; + mutationRecords.forEach(record => { + if (record.attributeName === 'd') { + hasPathMutations = true; + } + }); + + if (hasPathMutations) { + this._list = this._parsePath(this._pathElement.getAttribute('d')); + } + } // Serialize the list and update the path's 'd' attribute. + + + _writeListToPath() { + this._pathElementMutationObserver.disconnect(); + + this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); + + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + } // When a path segment changes the list needs to be synchronized back to the path element. + + + segmentChanged(pathSeg) { + this._writeListToPath(); + } + + clear() { + this._checkPathSynchronizedToList(); + + this._list.forEach(pathSeg => { + pathSeg._owningPathSegList = null; + }); + + this._list = []; + + this._writeListToPath(); + } + + initialize(newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + + _checkValidIndex(index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) { + throw new Error('INDEX_SIZE_ERR'); + } + } + + getItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + return this._list[index]; + } + + insertItemBefore(newItem, index) { + this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + + + if (index > this.numberOfItems) { + index = this.numberOfItems; + } + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.splice(index, 0, newItem); + + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + + replaceItem(newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._checkValidIndex(index); + + this._list[index] = newItem; + newItem._owningPathSegList = this; + + this._writeListToPath(); + + return newItem; + } + + removeItem(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + + const item = this._list[index]; + + this._list.splice(index, 1); + + this._writeListToPath(); + + return item; + } + + appendItem(newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + + this._list.push(newItem); + + newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute. + + this._writeListToPath(); + + return newItem; + } // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + + + _parsePath(string) { + if (!string || !string.length) { + return []; + } + + const owningPathSegList = this; // eslint-disable-line consistent-this + + class Builder { + constructor() { + this.pathSegList = []; } - var hasPathMutations = false; - mutationRecords.forEach(function (record) { - if (record.attributeName === 'd') { - hasPathMutations = true; - } - }); - - if (hasPathMutations) { - this._list = this._parsePath(this._pathElement.getAttribute('d')); - } - } // Serialize the list and update the path's 'd' attribute. - - }, { - key: "_writeListToPath", - value: function _writeListToPath() { - this._pathElementMutationObserver.disconnect(); - - this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list)); - - this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); - } // When a path segment changes the list needs to be synchronized back to the path element. - - }, { - key: "segmentChanged", - value: function segmentChanged(pathSeg) { - this._writeListToPath(); - } - }, { - key: "clear", - value: function clear() { - this._checkPathSynchronizedToList(); - - this._list.forEach(function (pathSeg) { - pathSeg._owningPathSegList = null; - }); - - this._list = []; - - this._writeListToPath(); - } - }, { - key: "initialize", - value: function initialize(newItem) { - this._checkPathSynchronizedToList(); - - this._list = [newItem]; - newItem._owningPathSegList = this; - - this._writeListToPath(); - - return newItem; - } - }, { - key: "_checkValidIndex", - value: function _checkValidIndex(index) { - if (isNaN(index) || index < 0 || index >= this.numberOfItems) { - throw new Error('INDEX_SIZE_ERR'); - } - } - }, { - key: "getItem", - value: function getItem(index) { - this._checkPathSynchronizedToList(); - - this._checkValidIndex(index); - - return this._list[index]; - } - }, { - key: "insertItemBefore", - value: function insertItemBefore(newItem, index) { - this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. - - - if (index > this.numberOfItems) { - index = this.numberOfItems; + appendSegment(pathSeg) { + this.pathSegList.push(pathSeg); } - if (newItem._owningPathSegList) { - // SVG2 spec says to make a copy. - newItem = newItem.clone(); - } - - this._list.splice(index, 0, newItem); - - newItem._owningPathSegList = this; - - this._writeListToPath(); - - return newItem; } - }, { - key: "replaceItem", - value: function replaceItem(newItem, index) { - this._checkPathSynchronizedToList(); - if (newItem._owningPathSegList) { - // SVG2 spec says to make a copy. - newItem = newItem.clone(); + class Source { + constructor(string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); } - this._checkValidIndex(index); - - this._list[index] = newItem; - newItem._owningPathSegList = this; - - this._writeListToPath(); - - return newItem; - } - }, { - key: "removeItem", - value: function removeItem(index) { - this._checkPathSynchronizedToList(); - - this._checkValidIndex(index); - - var item = this._list[index]; - - this._list.splice(index, 1); - - this._writeListToPath(); - - return item; - } - }, { - key: "appendItem", - value: function appendItem(newItem) { - this._checkPathSynchronizedToList(); - - if (newItem._owningPathSegList) { - // SVG2 spec says to make a copy. - newItem = newItem.clone(); + _isCurrentSpace() { + const character = this._string[this._currentIndex]; + return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f'); } - this._list.push(newItem); - - newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute. - - this._writeListToPath(); - - return newItem; - } // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. - - }, { - key: "_parsePath", - value: function _parsePath(string) { - if (!string || !string.length) { - return []; - } - - var owningPathSegList = this; - - var Builder = /*#__PURE__*/function () { - function Builder() { - _classCallCheck(this, Builder); - - this.pathSegList = []; + _skipOptionalSpaces() { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) { + this._currentIndex++; } - _createClass(Builder, [{ - key: "appendSegment", - value: function appendSegment(pathSeg) { - this.pathSegList.push(pathSeg); - } - }]); + return this._currentIndex < this._endIndex; + } - return Builder; - }(); - - var Source = /*#__PURE__*/function () { - function Source(string) { - _classCallCheck(this, Source); - - this._string = string; - this._currentIndex = 0; - this._endIndex = this._string.length; - this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; - - this._skipOptionalSpaces(); + _skipOptionalSpacesOrDelimiter() { + if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') { + return false; } - _createClass(Source, [{ - key: "_isCurrentSpace", - value: function _isCurrentSpace() { - var character = this._string[this._currentIndex]; - return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f'); + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') { + this._currentIndex++; + + this._skipOptionalSpaces(); } - }, { - key: "_skipOptionalSpaces", - value: function _skipOptionalSpaces() { - while (this._currentIndex < this._endIndex && this._isCurrentSpace()) { - this._currentIndex++; - } + } - return this._currentIndex < this._endIndex; - } - }, { - key: "_skipOptionalSpacesOrDelimiter", - value: function _skipOptionalSpacesOrDelimiter() { - if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') { - return false; - } + return this._currentIndex < this._endIndex; + } - if (this._skipOptionalSpaces()) { - if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') { - this._currentIndex++; + hasMoreData() { + return this._currentIndex < this._endIndex; + } - this._skipOptionalSpaces(); - } - } + peekSegmentType() { + const lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + } - return this._currentIndex < this._endIndex; - } - }, { - key: "hasMoreData", - value: function hasMoreData() { - return this._currentIndex < this._endIndex; - } - }, { - key: "peekSegmentType", - value: function peekSegmentType() { - var lookahead = this._string[this._currentIndex]; - return this._pathSegTypeFromChar(lookahead); - } - }, { - key: "_pathSegTypeFromChar", - value: function _pathSegTypeFromChar(lookahead) { - switch (lookahead) { - case 'Z': - case 'z': - return SVGPathSeg.PATHSEG_CLOSEPATH; + _pathSegTypeFromChar(lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return SVGPathSeg.PATHSEG_CLOSEPATH; - case 'M': - return SVGPathSeg.PATHSEG_MOVETO_ABS; + case 'M': + return SVGPathSeg.PATHSEG_MOVETO_ABS; - case 'm': - return SVGPathSeg.PATHSEG_MOVETO_REL; + case 'm': + return SVGPathSeg.PATHSEG_MOVETO_REL; - case 'L': - return SVGPathSeg.PATHSEG_LINETO_ABS; + case 'L': + return SVGPathSeg.PATHSEG_LINETO_ABS; - case 'l': - return SVGPathSeg.PATHSEG_LINETO_REL; + case 'l': + return SVGPathSeg.PATHSEG_LINETO_REL; - case 'C': - return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + case 'C': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; - case 'c': - return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + case 'c': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; - case 'Q': - return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + case 'Q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; - case 'q': - return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + case 'q': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; - case 'A': - return SVGPathSeg.PATHSEG_ARC_ABS; + case 'A': + return SVGPathSeg.PATHSEG_ARC_ABS; - case 'a': - return SVGPathSeg.PATHSEG_ARC_REL; + case 'a': + return SVGPathSeg.PATHSEG_ARC_REL; - case 'H': - return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + case 'H': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; - case 'h': - return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + case 'h': + return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; - case 'V': - return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + case 'V': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; - case 'v': - return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + case 'v': + return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; - case 'S': - return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + case 'S': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; - case 's': - return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + case 's': + return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; - case 'T': - return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + case 'T': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; - case 't': - return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; - - default: - return SVGPathSeg.PATHSEG_UNKNOWN; - } - } - }, { - key: "_nextCommandHelper", - value: function _nextCommandHelper(lookahead, previousCommand) { - // Check for remaining coordinates in the current command. - if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || lookahead >= '0' && lookahead <= '9') && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) { - if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) { - return SVGPathSeg.PATHSEG_LINETO_ABS; - } - - if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) { - return SVGPathSeg.PATHSEG_LINETO_REL; - } - - return previousCommand; - } + case 't': + return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + default: return SVGPathSeg.PATHSEG_UNKNOWN; + } + } + + _nextCommandHelper(lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || lookahead >= '0' && lookahead <= '9') && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) { + return SVGPathSeg.PATHSEG_LINETO_ABS; } - }, { - key: "initialCommandIsMoveTo", - value: function initialCommandIsMoveTo() { - // If the path is empty it is still valid, so return true. - if (!this.hasMoreData()) { - return true; - } - var command = this.peekSegmentType(); // Path must start with moveTo. - - return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL; - } // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. - // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF - - }, { - key: "_parseNumber", - value: function _parseNumber() { - var exponent = 0; - var integer = 0; - var frac = 1; - var decimal = 0; - var sign = 1; - var expsign = 1; - var startIndex = this._currentIndex; - - this._skipOptionalSpaces(); // Read the sign. - - - if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') { - this._currentIndex++; - } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') { - this._currentIndex++; - sign = -1; - } - - if (this._currentIndex === this._endIndex || (this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.') { - // The first character of a number must be one of [0-9+-.]. - return undefined; - } // Read the integer part, build right-to-left. - - - var startIntPartIndex = this._currentIndex; - - while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { - this._currentIndex++; // Advance to first non-digit. - } - - if (this._currentIndex !== startIntPartIndex) { - var scanIntPartIndex = this._currentIndex - 1; - var multiplier = 1; - - while (scanIntPartIndex >= startIntPartIndex) { - integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); - multiplier *= 10; - } - } // Read the decimals. - - - if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') { - this._currentIndex++; // There must be a least one digit following the . - - if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { - return undefined; - } - - while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { - frac *= 10; - decimal += (this._string.charAt(this._currentIndex) - '0') / frac; - this._currentIndex += 1; - } - } // Read the exponent part. - - - if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm') { - this._currentIndex++; // Read the sign of the exponent. - - if (this._string.charAt(this._currentIndex) === '+') { - this._currentIndex++; - } else if (this._string.charAt(this._currentIndex) === '-') { - this._currentIndex++; - expsign = -1; - } // There must be an exponent. - - - if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { - return undefined; - } - - while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { - exponent *= 10; - exponent += this._string.charAt(this._currentIndex) - '0'; - this._currentIndex++; - } - } - - var number = integer + decimal; - number *= sign; - - if (exponent) { - number *= Math.pow(10, expsign * exponent); - } - - if (startIndex === this._currentIndex) { - return undefined; - } - - this._skipOptionalSpacesOrDelimiter(); - - return number; + if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) { + return SVGPathSeg.PATHSEG_LINETO_REL; } - }, { - key: "_parseArcFlag", - value: function _parseArcFlag() { - if (this._currentIndex >= this._endIndex) { - return undefined; - } - var flag = false; + return previousCommand; + } - var flagChar = this._string.charAt(this._currentIndex++); + return SVGPathSeg.PATHSEG_UNKNOWN; + } - if (flagChar === '0') { - flag = false; - } else if (flagChar === '1') { - flag = true; - } else { - return undefined; - } + initialCommandIsMoveTo() { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) { + return true; + } - this._skipOptionalSpacesOrDelimiter(); + const command = this.peekSegmentType(); // Path must start with moveTo. - return flag; + return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL; + } // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + + + _parseNumber() { + let exponent = 0; + let integer = 0; + let frac = 1; + let decimal = 0; + let sign = 1; + let expsign = 1; + const startIndex = this._currentIndex; + + this._skipOptionalSpaces(); // Read the sign. + + + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + sign = -1; + } + + if (this._currentIndex === this._endIndex || (this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.') { + // The first character of a number must be one of [0-9+-.]. + return undefined; + } // Read the integer part, build right-to-left. + + + const startIntPartIndex = this._currentIndex; + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + this._currentIndex++; // Advance to first non-digit. + } + + if (this._currentIndex !== startIntPartIndex) { + let scanIntPartIndex = this._currentIndex - 1; + let multiplier = 1; + + while (scanIntPartIndex >= startIntPartIndex) { + integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; } - }, { - key: "parseSegment", - value: function parseSegment() { - var lookahead = this._string[this._currentIndex]; + } // Read the decimals. - var command = this._pathSegTypeFromChar(lookahead); - if (command === SVGPathSeg.PATHSEG_UNKNOWN) { - // Possibly an implicit command. Not allowed if this is the first command. - if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) { - return null; - } + if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') { + this._currentIndex++; // There must be a least one digit following the . - command = this._nextCommandHelper(lookahead, this._previousCommand); - - if (command === SVGPathSeg.PATHSEG_UNKNOWN) { - return null; - } - } else { - this._currentIndex++; - } - - this._previousCommand = command; - - switch (command) { - case SVGPathSeg.PATHSEG_MOVETO_REL: - return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_MOVETO_ABS: - return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_REL: - return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_ABS: - return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: - return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: - return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: - return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); - - case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: - return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); - - case SVGPathSeg.PATHSEG_CLOSEPATH: - this._skipOptionalSpaces(); - - return new SVGPathSegClosePath(owningPathSegList); - - case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: - { - var points = { - x1: this._parseNumber(), - y1: this._parseNumber(), - x2: this._parseNumber(), - y2: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); - } - - case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: - { - var _points = { - x1: this._parseNumber(), - y1: this._parseNumber(), - x2: this._parseNumber(), - y2: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2); - } - - case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - { - var _points2 = { - x2: this._parseNumber(), - y2: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points2.x, _points2.y, _points2.x2, _points2.y2); - } - - case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - { - var _points3 = { - x2: this._parseNumber(), - y2: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2); - } - - case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: - { - var _points4 = { - x1: this._parseNumber(), - y1: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points4.x, _points4.y, _points4.x1, _points4.y1); - } - - case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: - { - var _points5 = { - x1: this._parseNumber(), - y1: this._parseNumber(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1); - } - - case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: - return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); - - case SVGPathSeg.PATHSEG_ARC_REL: - { - var _points6 = { - x1: this._parseNumber(), - y1: this._parseNumber(), - arcAngle: this._parseNumber(), - arcLarge: this._parseArcFlag(), - arcSweep: this._parseArcFlag(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegArcRel(owningPathSegList, _points6.x, _points6.y, _points6.x1, _points6.y1, _points6.arcAngle, _points6.arcLarge, _points6.arcSweep); - } - - case SVGPathSeg.PATHSEG_ARC_ABS: - { - var _points7 = { - x1: this._parseNumber(), - y1: this._parseNumber(), - arcAngle: this._parseNumber(), - arcLarge: this._parseArcFlag(), - arcSweep: this._parseArcFlag(), - x: this._parseNumber(), - y: this._parseNumber() - }; - return new SVGPathSegArcAbs(owningPathSegList, _points7.x, _points7.y, _points7.x1, _points7.y1, _points7.arcAngle, _points7.arcLarge, _points7.arcSweep); - } - - default: - throw new Error('Unknown path seg type.'); - } + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; } - }]); - return Source; - }(); + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } // Read the exponent part. - var builder = new Builder(); - var source = new Source(string); - if (!source.initialCommandIsMoveTo()) { + if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm') { + this._currentIndex++; // Read the sign of the exponent. + + if (this._string.charAt(this._currentIndex) === '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) === '-') { + this._currentIndex++; + expsign = -1; + } // There must be an exponent. + + + if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') { + return undefined; + } + + while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + + let number = integer + decimal; + number *= sign; + + if (exponent) { + number *= 10 ** (expsign * exponent); + } + + if (startIndex === this._currentIndex) { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return number; + } + + _parseArcFlag() { + if (this._currentIndex >= this._endIndex) { + return undefined; + } + + let flag = false; + + const flagChar = this._string.charAt(this._currentIndex++); + + if (flagChar === '0') { + flag = false; + } else if (flagChar === '1') { + flag = true; + } else { + return undefined; + } + + this._skipOptionalSpacesOrDelimiter(); + + return flag; + } + + parseSegment() { + const lookahead = this._string[this._currentIndex]; + + let command = this._pathSegTypeFromChar(lookahead); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + + command = this._nextCommandHelper(lookahead, this._previousCommand); + + if (command === SVGPathSeg.PATHSEG_UNKNOWN) { + return null; + } + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case SVGPathSeg.PATHSEG_MOVETO_REL: + return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_MOVETO_ABS: + return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_REL: + return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_ABS: + return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + + case SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + + return new SVGPathSegClosePath(owningPathSegList); + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + { + const points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + { + const points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1); + } + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + + case SVGPathSeg.PATHSEG_ARC_REL: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + } + + case SVGPathSeg.PATHSEG_ARC_ABS: + { + const points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + } + + default: + throw new Error('Unknown path seg type.'); + } + } + + } + + const builder = new Builder(); + const source = new Source(string); + + if (!source.initialCommandIsMoveTo()) { + return []; + } + + while (source.hasMoreData()) { + const pathSeg = source.parseSegment(); + + if (!pathSeg) { return []; } - while (source.hasMoreData()) { - var pathSeg = source.parseSegment(); - - if (!pathSeg) { - return []; - } - - builder.appendSegment(pathSeg); - } - - return builder.pathSegList; - } // STATIC - - }], [{ - key: "_pathSegArrayAsString", - value: function _pathSegArrayAsString(pathSegArray) { - var string = ''; - var first = true; - pathSegArray.forEach(function (pathSeg) { - if (first) { - first = false; - string += pathSeg._asPathString(); - } else { - string += ' ' + pathSeg._asPathString(); - } - }); - return string; + builder.appendSegment(pathSeg); } - }]); - return SVGPathSegList; - }(); + return builder.pathSegList; + } // STATIC + + + static _pathSegArrayAsString(pathSegArray) { + let string = ''; + let first = true; + pathSegArray.forEach(pathSeg => { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + } + + } SVGPathSegList.prototype.classname = 'SVGPathSegList'; Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', { - get: function get() { + get() { this._checkPathSynchronizedToList(); return this._list.length; }, + enumerable: true }); // Add the pathSegList accessors to SVGPathElement. // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData Object.defineProperties(SVGPathElement.prototype, { pathSegList: { - get: function get() { + get() { if (!this._pathSegList) { this._pathSegList = new SVGPathSegList(this); } return this._pathSegList; }, + enumerable: true }, // TODO: The following are not implemented and simply return SVGPathElement.pathSegList. normalizedPathSegList: { - get: function get() { + get() { return this.pathSegList; }, + enumerable: true }, animatedPathSegList: { - get: function get() { + get() { return this.pathSegList; }, + enumerable: true }, animatedNormalizedPathSegList: { - get: function get() { + get() { return this.pathSegList; }, + enumerable: true } }); @@ -2759,38 +2221,40 @@ } })(); - var $ = jQuery; + /* globals jQuery */ + const $ = jQuery; - var supportsSVG_ = function () { + const supportsSVG_ = function () { return Boolean(document.createElementNS && document.createElementNS(NS.SVG, 'svg').createSVGRect); }(); - var _navigator = navigator, - userAgent = _navigator.userAgent; - var svg = document.createElementNS(NS.SVG, 'svg'); // Note: Browser sniffing should only be used if no other detection method is possible + const { + userAgent + } = navigator; + const svg = document.createElementNS(NS.SVG, 'svg'); // Note: Browser sniffing should only be used if no other detection method is possible - var isOpera_ = Boolean(window.opera); - var isWebkit_ = userAgent.includes('AppleWebKit'); - var isGecko_ = userAgent.includes('Gecko/'); - var isIE_ = userAgent.includes('MSIE'); - var isChrome_ = userAgent.includes('Chrome/'); - var isWindows_ = userAgent.includes('Windows'); - var isMac_ = userAgent.includes('Macintosh'); - var isTouch_ = ('ontouchstart' in window); + const isOpera_ = Boolean(window.opera); + const isWebkit_ = userAgent.includes('AppleWebKit'); + const isGecko_ = userAgent.includes('Gecko/'); + const isIE_ = userAgent.includes('MSIE'); + const isChrome_ = userAgent.includes('Chrome/'); + const isWindows_ = userAgent.includes('Windows'); + const isMac_ = userAgent.includes('Macintosh'); + const isTouch_ = ('ontouchstart' in window); - var supportsSelectors_ = function () { + const supportsSelectors_ = function () { return Boolean(svg.querySelector); }(); - var supportsXpath_ = function () { + const supportsXpath_ = function () { return Boolean(document.evaluate); }(); // segList functions (for FF1.5 and 2.0) - var supportsPathReplaceItem_ = function () { - var path = document.createElementNS(NS.SVG, 'path'); + const supportsPathReplaceItem_ = function () { + const path = document.createElementNS(NS.SVG, 'path'); path.setAttribute('d', 'M0,0 10,10'); - var seglist = path.pathSegList; - var seg = path.createSVGPathSegLinetoAbs(5, 5); + const seglist = path.pathSegList; + const seg = path.createSVGPathSegLinetoAbs(5, 5); try { seglist.replaceItem(seg, 1); @@ -2800,11 +2264,11 @@ return false; }(); - var supportsPathInsertItemBefore_ = function () { - var path = document.createElementNS(NS.SVG, 'path'); + const supportsPathInsertItemBefore_ = function () { + const path = document.createElementNS(NS.SVG, 'path'); path.setAttribute('d', 'M0,0 10,10'); - var seglist = path.pathSegList; - var seg = path.createSVGPathSegLinetoAbs(5, 5); + const seglist = path.pathSegList; + const seg = path.createSVGPathSegLinetoAbs(5, 5); try { seglist.insertItemBefore(seg, 1); @@ -2815,19 +2279,19 @@ }(); // text character positioning (for IE9 and now Chrome) - var supportsGoodTextCharPos_ = function () { - var svgroot = document.createElementNS(NS.SVG, 'svg'); - var svgcontent = document.createElementNS(NS.SVG, 'svg'); + const supportsGoodTextCharPos_ = function () { + const svgroot = document.createElementNS(NS.SVG, 'svg'); + const svgcontent = document.createElementNS(NS.SVG, 'svg'); document.documentElement.append(svgroot); svgcontent.setAttribute('x', 5); svgroot.append(svgcontent); - var text = document.createElementNS(NS.SVG, 'text'); + const text = document.createElementNS(NS.SVG, 'text'); text.textContent = 'a'; svgcontent.append(text); try { // Chrome now fails here - var pos = text.getStartPositionOfChar(0).x; + const pos = text.getStartPositionOfChar(0).x; return pos === 0; } catch (err) { return false; @@ -2836,40 +2300,40 @@ } }(); - var supportsPathBBox_ = function () { - var svgcontent = document.createElementNS(NS.SVG, 'svg'); + const supportsPathBBox_ = function () { + const svgcontent = document.createElementNS(NS.SVG, 'svg'); document.documentElement.append(svgcontent); - var path = document.createElementNS(NS.SVG, 'path'); + const path = document.createElementNS(NS.SVG, 'path'); path.setAttribute('d', 'M0,0 C0,0 10,10 10,0'); svgcontent.append(path); - var bbox = path.getBBox(); + const bbox = path.getBBox(); svgcontent.remove(); return bbox.height > 4 && bbox.height < 5; }(); // Support for correct bbox sizing on groups with horizontal/vertical lines - var supportsHVLineContainerBBox_ = function () { - var svgcontent = document.createElementNS(NS.SVG, 'svg'); + const supportsHVLineContainerBBox_ = function () { + const svgcontent = document.createElementNS(NS.SVG, 'svg'); document.documentElement.append(svgcontent); - var path = document.createElementNS(NS.SVG, 'path'); + const path = document.createElementNS(NS.SVG, 'path'); path.setAttribute('d', 'M0,0 10,0'); - var path2 = document.createElementNS(NS.SVG, 'path'); + const path2 = document.createElementNS(NS.SVG, 'path'); path2.setAttribute('d', 'M5,0 15,0'); - var g = document.createElementNS(NS.SVG, 'g'); + const g = document.createElementNS(NS.SVG, 'g'); g.append(path, path2); svgcontent.append(g); - var bbox = g.getBBox(); + const bbox = g.getBBox(); svgcontent.remove(); // Webkit gives 0, FF gives 10, Opera (correctly) gives 15 return bbox.width === 15; }(); - var supportsGoodDecimals_ = function () { + const supportsGoodDecimals_ = function () { // Correct decimals on clone attributes (Opera < 10.5/win/non-en) - var rect = document.createElementNS(NS.SVG, 'rect'); + const rect = document.createElementNS(NS.SVG, 'rect'); rect.setAttribute('x', 0.1); - var crect = rect.cloneNode(false); - var retValue = !crect.getAttribute('x').includes(','); + const crect = rect.cloneNode(false); + const retValue = !crect.getAttribute('x').includes(','); if (!retValue) { // Todo: i18nize or remove @@ -2879,22 +2343,22 @@ return retValue; }(); - var supportsNonScalingStroke_ = function () { - var rect = document.createElementNS(NS.SVG, 'rect'); + const supportsNonScalingStroke_ = function () { + const rect = document.createElementNS(NS.SVG, 'rect'); rect.setAttribute('style', 'vector-effect:non-scaling-stroke'); return rect.style.vectorEffect === 'non-scaling-stroke'; }(); - var supportsNativeSVGTransformLists_ = function () { - var rect = document.createElementNS(NS.SVG, 'rect'); - var rxform = rect.transform.baseVal; - var t1 = svg.createSVGTransform(); + let supportsNativeSVGTransformLists_ = function () { + const rect = document.createElementNS(NS.SVG, 'rect'); + const rxform = rect.transform.baseVal; + const t1 = svg.createSVGTransform(); rxform.appendItem(t1); - var r1 = rxform.getItem(0); + const r1 = rxform.getItem(0); - var isSVGTransform = function isSVGTransform(o) { + const isSVGTransform = o => { // https://developer.mozilla.org/en-US/docs/Web/API/SVGTransform - return o && _typeof(o) === 'object' && typeof o.setMatrix === 'function' && 'angle' in o; + return o && typeof o === 'object' && typeof o.setMatrix === 'function' && 'angle' in o; }; return isSVGTransform(r1) && isSVGTransform(t1) && r1.type === t1.type && r1.angle === t1.angle && r1.matrix.a === t1.matrix.a && r1.matrix.b === t1.matrix.b && r1.matrix.c === t1.matrix.c && r1.matrix.d === t1.matrix.d && r1.matrix.e === t1.matrix.e && r1.matrix.f === t1.matrix.f; @@ -2906,129 +2370,97 @@ */ - var isOpera = function isOpera() { - return isOpera_; - }; + const isOpera = () => isOpera_; /** * @function module:browser.isWebkit * @returns {boolean} */ - var isWebkit = function isWebkit() { - return isWebkit_; - }; + const isWebkit = () => isWebkit_; /** * @function module:browser.isGecko * @returns {boolean} */ - var isGecko = function isGecko() { - return isGecko_; - }; + const isGecko = () => isGecko_; /** * @function module:browser.isIE * @returns {boolean} */ - var isIE = function isIE() { - return isIE_; - }; + const isIE = () => isIE_; /** * @function module:browser.isChrome * @returns {boolean} */ - var isChrome = function isChrome() { - return isChrome_; - }; + const isChrome = () => isChrome_; /** * @function module:browser.isMac * @returns {boolean} */ - var isMac = function isMac() { - return isMac_; - }; + const isMac = () => isMac_; /** * @function module:browser.isTouch * @returns {boolean} */ - var isTouch = function isTouch() { - return isTouch_; - }; + const isTouch = () => isTouch_; /** * @function module:browser.supportsSelectors * @returns {boolean} */ - var supportsSelectors = function supportsSelectors() { - return supportsSelectors_; - }; + const supportsSelectors = () => supportsSelectors_; /** * @function module:browser.supportsXpath * @returns {boolean} */ - var supportsXpath = function supportsXpath() { - return supportsXpath_; - }; + const supportsXpath = () => supportsXpath_; /** * @function module:browser.supportsPathReplaceItem * @returns {boolean} */ - var supportsPathReplaceItem = function supportsPathReplaceItem() { - return supportsPathReplaceItem_; - }; + const supportsPathReplaceItem = () => supportsPathReplaceItem_; /** * @function module:browser.supportsPathInsertItemBefore * @returns {boolean} */ - var supportsPathInsertItemBefore = function supportsPathInsertItemBefore() { - return supportsPathInsertItemBefore_; - }; + const supportsPathInsertItemBefore = () => supportsPathInsertItemBefore_; /** * @function module:browser.supportsPathBBox * @returns {boolean} */ - var supportsPathBBox = function supportsPathBBox() { - return supportsPathBBox_; - }; + const supportsPathBBox = () => supportsPathBBox_; /** * @function module:browser.supportsHVLineContainerBBox * @returns {boolean} */ - var supportsHVLineContainerBBox = function supportsHVLineContainerBBox() { - return supportsHVLineContainerBBox_; - }; + const supportsHVLineContainerBBox = () => supportsHVLineContainerBBox_; /** * @function module:browser.supportsGoodTextCharPos * @returns {boolean} */ - var supportsGoodTextCharPos = function supportsGoodTextCharPos() { - return supportsGoodTextCharPos_; - }; + const supportsGoodTextCharPos = () => supportsGoodTextCharPos_; /** * @function module:browser.supportsNonScalingStroke * @returns {boolean} */ - var supportsNonScalingStroke = function supportsNonScalingStroke() { - return supportsNonScalingStroke_; - }; + const supportsNonScalingStroke = () => supportsNonScalingStroke_; /** * @function module:browser.supportsNativeTransformLists * @returns {boolean} */ - var supportsNativeTransformLists = function supportsNativeTransformLists() { - return supportsNativeSVGTransformLists_; - }; + const supportsNativeTransformLists = () => supportsNativeSVGTransformLists_; /** * A jQuery module to work with SVG attributes. @@ -3051,8 +2483,8 @@ * @returns {external:jQuery} */ function jQueryPluginSVG($) { - var proxied = $.fn.attr, - svgns = 'http://www.w3.org/2000/svg'; + const proxied = $.fn.attr, + svgns = 'http://www.w3.org/2000/svg'; /** * @typedef {PlainObject} module:jQueryAttr.Attributes */ @@ -3065,14 +2497,14 @@ */ $.fn.attr = function (key, value) { - var len = this.length; + const len = this.length; if (!len) { return proxied.call(this, key, value); } - for (var i = 0; i < len; ++i) { - var elem = this[i]; // set/get SVG attribute + for (let i = 0; i < len; ++i) { + const elem = this[i]; // set/get SVG attribute if (elem.namespaceURI === svgns) { // Setting attribute @@ -3080,12 +2512,12 @@ elem.setAttribute(key, value); } else if (Array.isArray(key)) { // Getting attributes from array - var obj = {}; - var j = key.length; + const obj = {}; + let j = key.length; while (j--) { - var aname = key[j]; - var attr = elem.getAttribute(aname); // This returns a number when appropriate + const aname = key[j]; + let attr = elem.getAttribute(aname); // This returns a number when appropriate if (attr || attr === '0') { attr = isNaN(attr) ? attr : attr - 0; @@ -3097,24 +2529,20 @@ return obj; } - if (_typeof(key) === 'object') { + if (typeof key === 'object') { // Setting attributes from object - for (var _i = 0, _Object$entries = Object.entries(key); _i < _Object$entries.length; _i++) { - var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), - name = _Object$entries$_i[0], - val = _Object$entries$_i[1]; - + for (const [name, val] of Object.entries(key)) { elem.setAttribute(name, val); } // Getting attribute } else { - var _attr = elem.getAttribute(key); + let attr = elem.getAttribute(key); - if (_attr || _attr === '0') { - _attr = isNaN(_attr) ? _attr : _attr - 0; + if (attr || attr === '0') { + attr = isNaN(attr) ? attr : attr - 0; } - return _attr; + return attr; } } else { return proxied.call(this, key, value); @@ -3127,7 +2555,15 @@ return $; } - var svgroot = document.createElementNS(NS.SVG, 'svg'); + /** + * Partial polyfill of `SVGTransformList` + * @module SVGTransformList + * + * @license MIT + * + * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller + */ + const svgroot = document.createElementNS(NS.SVG, 'svg'); /** * Helper function to convert `SVGTransform` to a string. * @param {SVGTransform} xform @@ -3135,8 +2571,8 @@ */ function transformToString(xform) { - var m = xform.matrix; - var text = ''; + const m = xform.matrix; + let text = ''; switch (xform.type) { case 1: @@ -3162,11 +2598,11 @@ case 4: { // ROTATE - var cx = 0; - var cy = 0; // this prevents divide by zero + let cx = 0; + let cy = 0; // this prevents divide by zero if (xform.angle !== 0) { - var K = 1 - m.a; + const K = 1 - m.a; cy = (K * m.f + m.b * m.e) / (K * K + m.b * m.b); cx = (m.e - m.b * cy) / K; } @@ -3183,7 +2619,7 @@ */ - var listMap_ = {}; + let listMap_ = {}; /** * @interface module:SVGTransformList.SVGEditTransformList * @property {Integer} numberOfItems unsigned long @@ -3259,24 +2695,22 @@ * @implements {module:SVGTransformList.SVGEditTransformList} */ - var SVGTransformList = /*#__PURE__*/function () { + class SVGTransformList { // eslint-disable-line no-shadow /** * @param {Element} elem * @returns {SVGTransformList} */ - function SVGTransformList(elem) { - _classCallCheck(this, SVGTransformList); - + constructor(elem) { this._elem = elem || null; this._xforms = []; // TODO: how do we capture the undo-ability in the changed transform list? this._update = function () { - var tstr = ''; // /* const concatMatrix = */ svgroot.createSVGMatrix(); + let tstr = ''; // /* const concatMatrix = */ svgroot.createSVGMatrix(); - for (var i = 0; i < this.numberOfItems; ++i) { - var xform = this._list.getItem(i); + for (let i = 0; i < this.numberOfItems; ++i) { + const xform = this._list.getItem(i); tstr += transformToString(xform) + ' '; } @@ -3287,69 +2721,65 @@ this._list = this; this._init = function () { - var _this = this; - // Transform attribute parser - var str = this._elem.getAttribute('transform'); + let str = this._elem.getAttribute('transform'); if (!str) { return; } // TODO: Add skew support in future - var re = /\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; // const re = /\s*(?(?:scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; + const re = /\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; // const re = /\s*(?(?:scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/; - var m = true; + let m = true; while (m) { m = str.match(re); str = str.replace(re, ''); if (m && m[1]) { - (function () { - var x = m[1]; - var bits = x.split(/\s*\(/); - var name = bits[0]; - var valBits = bits[1].match(/\s*(.*?)\s*\)/); - valBits[1] = valBits[1].replace(/(\d)-/g, '$1 -'); - var valArr = valBits[1].split(/[, ]+/); - var letters = 'abcdef'.split(''); - /* - if (m && m.groups.xform) { - const x = m.groups.xform; - const [name, bits] = x.split(/\s*\(/); - const valBits = bits.match(/\s*(?.*?)\s*\)/); - valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace( - /(?\d)-/g, '$ -' - ); - const valArr = valBits.groups.nonWhitespace.split(/[, ]+/); - const letters = [...'abcdef']; - */ + const x = m[1]; + const bits = x.split(/\s*\(/); + const name = bits[0]; + const valBits = bits[1].match(/\s*(.*?)\s*\)/); + valBits[1] = valBits[1].replace(/(\d)-/g, '$1 -'); + const valArr = valBits[1].split(/[, ]+/); + const letters = 'abcdef'.split(''); + /* + if (m && m.groups.xform) { + const x = m.groups.xform; + const [name, bits] = x.split(/\s*\(/); + const valBits = bits.match(/\s*(?.*?)\s*\)/); + valBits.groups.nonWhitespace = valBits.groups.nonWhitespace.replace( + /(?\d)-/g, '$ -' + ); + const valArr = valBits.groups.nonWhitespace.split(/[, ]+/); + const letters = [...'abcdef']; + */ - var mtx = svgroot.createSVGMatrix(); - Object.values(valArr).forEach(function (item, i) { - valArr[i] = Number.parseFloat(item); + const mtx = svgroot.createSVGMatrix(); + Object.values(valArr).forEach(function (item, i) { + valArr[i] = Number.parseFloat(item); - if (name === 'matrix') { - mtx[letters[i]] = valArr[i]; - } - }); - var xform = svgroot.createSVGTransform(); - var fname = 'set' + name.charAt(0).toUpperCase() + name.slice(1); - var values = name === 'matrix' ? [mtx] : valArr; - - if (name === 'scale' && values.length === 1) { - values.push(values[0]); - } else if (name === 'translate' && values.length === 1) { - values.push(0); - } else if (name === 'rotate' && values.length === 1) { - values.push(0, 0); + if (name === 'matrix') { + mtx[letters[i]] = valArr[i]; } + }); + const xform = svgroot.createSVGTransform(); + const fname = 'set' + name.charAt(0).toUpperCase() + name.slice(1); + const values = name === 'matrix' ? [mtx] : valArr; - xform[fname].apply(xform, _toConsumableArray(values)); + if (name === 'scale' && values.length === 1) { + values.push(values[0]); + } else if (name === 'translate' && values.length === 1) { + values.push(0); + } else if (name === 'rotate' && values.length === 1) { + values.push(0, 0); + } - _this._list.appendItem(xform); - })(); + xform[fname](...values); + + this._list.appendItem(xform); } } }; @@ -3358,8 +2788,8 @@ if (item) { // Check if this transform is already in a transformlist, and // remove it if so. - Object.values(listMap_).some(function (tl) { - for (var i = 0, len = tl._xforms.length; i < len; ++i) { + Object.values(listMap_).some(tl => { + for (let i = 0, len = tl._xforms.length; i < len; ++i) { if (tl._xforms[i] === item) { tl.removeItem(i); return true; @@ -3378,168 +2808,158 @@ */ - _createClass(SVGTransformList, [{ - key: "clear", - value: function clear() { - this.numberOfItems = 0; - this._xforms = []; + clear() { + this.numberOfItems = 0; + this._xforms = []; + } + /** + * @param {SVGTransform} newItem + * @returns {void} + */ + + + initialize(newItem) { + this.numberOfItems = 1; + + this._removeFromOtherLists(newItem); + + this._xforms = [newItem]; + } + /** + * @param {Integer} index unsigned long + * @throws {Error} + * @returns {SVGTransform} + */ + + + getItem(index) { + if (index < this.numberOfItems && index >= 0) { + return this._xforms[index]; } - /** - * @param {SVGTransform} newItem - * @returns {void} - */ - }, { - key: "initialize", - value: function initialize(newItem) { - this.numberOfItems = 1; + const err = new Error('DOMException with code=INDEX_SIZE_ERR'); + err.code = 1; + throw err; + } + /** + * @param {SVGTransform} newItem + * @param {Integer} index unsigned long + * @returns {SVGTransform} + */ - this._removeFromOtherLists(newItem); - this._xforms = [newItem]; - } - /** - * @param {Integer} index unsigned long - * @throws {Error} - * @returns {SVGTransform} - */ + insertItemBefore(newItem, index) { + let retValue = null; - }, { - key: "getItem", - value: function getItem(index) { - if (index < this.numberOfItems && index >= 0) { - return this._xforms[index]; - } - - var err = new Error('DOMException with code=INDEX_SIZE_ERR'); - err.code = 1; - throw err; - } - /** - * @param {SVGTransform} newItem - * @param {Integer} index unsigned long - * @returns {SVGTransform} - */ - - }, { - key: "insertItemBefore", - value: function insertItemBefore(newItem, index) { - var retValue = null; - - if (index >= 0) { - if (index < this.numberOfItems) { - this._removeFromOtherLists(newItem); - - var newxforms = new Array(this.numberOfItems + 1); // TODO: use array copying and slicing - - var i; - - for (i = 0; i < index; ++i) { - newxforms[i] = this._xforms[i]; - } - - newxforms[i] = newItem; - - for (var j = i + 1; i < this.numberOfItems; ++j, ++i) { - newxforms[j] = this._xforms[i]; - } - - this.numberOfItems++; - this._xforms = newxforms; - retValue = newItem; - - this._list._update(); - } else { - retValue = this._list.appendItem(newItem); - } - } - - return retValue; - } - /** - * @param {SVGTransform} newItem - * @param {Integer} index unsigned long - * @returns {SVGTransform} - */ - - }, { - key: "replaceItem", - value: function replaceItem(newItem, index) { - var retValue = null; - - if (index < this.numberOfItems && index >= 0) { + if (index >= 0) { + if (index < this.numberOfItems) { this._removeFromOtherLists(newItem); - this._xforms[index] = newItem; - retValue = newItem; + const newxforms = new Array(this.numberOfItems + 1); // TODO: use array copying and slicing - this._list._update(); - } - - return retValue; - } - /** - * @param {Integer} index unsigned long - * @throws {Error} - * @returns {SVGTransform} - */ - - }, { - key: "removeItem", - value: function removeItem(index) { - if (index < this.numberOfItems && index >= 0) { - var retValue = this._xforms[index]; - var newxforms = new Array(this.numberOfItems - 1); - var i; + let i; for (i = 0; i < index; ++i) { newxforms[i] = this._xforms[i]; } - for (var j = i; j < this.numberOfItems - 1; ++j, ++i) { - newxforms[j] = this._xforms[i + 1]; + newxforms[i] = newItem; + + for (let j = i + 1; i < this.numberOfItems; ++j, ++i) { + newxforms[j] = this._xforms[i]; } - this.numberOfItems--; + this.numberOfItems++; this._xforms = newxforms; + retValue = newItem; this._list._update(); - - return retValue; + } else { + retValue = this._list.appendItem(newItem); } - - var err = new Error('DOMException with code=INDEX_SIZE_ERR'); - err.code = 1; - throw err; } - /** - * @param {SVGTransform} newItem - * @returns {SVGTransform} - */ - }, { - key: "appendItem", - value: function appendItem(newItem) { + return retValue; + } + /** + * @param {SVGTransform} newItem + * @param {Integer} index unsigned long + * @returns {SVGTransform} + */ + + + replaceItem(newItem, index) { + let retValue = null; + + if (index < this.numberOfItems && index >= 0) { this._removeFromOtherLists(newItem); - this._xforms.push(newItem); + this._xforms[index] = newItem; + retValue = newItem; - this.numberOfItems++; + this._list._update(); + } + + return retValue; + } + /** + * @param {Integer} index unsigned long + * @throws {Error} + * @returns {SVGTransform} + */ + + + removeItem(index) { + if (index < this.numberOfItems && index >= 0) { + const retValue = this._xforms[index]; + const newxforms = new Array(this.numberOfItems - 1); + let i; + + for (i = 0; i < index; ++i) { + newxforms[i] = this._xforms[i]; + } + + for (let j = i; j < this.numberOfItems - 1; ++j, ++i) { + newxforms[j] = this._xforms[i + 1]; + } + + this.numberOfItems--; + this._xforms = newxforms; this._list._update(); - return newItem; + return retValue; } - }]); - return SVGTransformList; - }(); + const err = new Error('DOMException with code=INDEX_SIZE_ERR'); + err.code = 1; + throw err; + } + /** + * @param {SVGTransform} newItem + * @returns {SVGTransform} + */ + + + appendItem(newItem) { + this._removeFromOtherLists(newItem); + + this._xforms.push(newItem); + + this.numberOfItems++; + + this._list._update(); + + return newItem; + } + + } /** * @function module:SVGTransformList.resetListMap * @returns {void} */ - var resetListMap = function resetListMap() { + const resetListMap = function () { listMap_ = {}; }; /** @@ -3549,7 +2969,7 @@ * @returns {void} */ - var removeElementFromListMap = function removeElementFromListMap(elem) { + let removeElementFromListMap = function (elem) { // eslint-disable-line import/no-mutable-exports if (elem.id && listMap_[elem.id]) { delete listMap_[elem.id]; @@ -3563,10 +2983,10 @@ * @returns {SVGAnimatedTransformList|SVGTransformList} */ - var getTransformList = function getTransformList(elem) { + const getTransformList = function (elem) { if (!supportsNativeTransformLists()) { - var id = elem.id || 'temp'; - var t = listMap_[id]; + const id = elem.id || 'temp'; + let t = listMap_[id]; if (!t || id === 'temp') { listMap_[id] = new SVGTransformList(elem); @@ -3601,9 +3021,9 @@ * * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller */ - var wAttrs = ['x', 'x1', 'cx', 'rx', 'width']; - var hAttrs = ['y', 'y1', 'cy', 'ry', 'height']; - var unitAttrs = ['r', 'radius'].concat(wAttrs, hAttrs); // unused + const wAttrs = ['x', 'x1', 'cx', 'rx', 'width']; + const hAttrs = ['y', 'y1', 'cy', 'ry', 'height']; + const unitAttrs = ['r', 'radius', ...wAttrs, ...hAttrs]; // unused /* const unitNumMap = { @@ -3620,9 +3040,9 @@ */ // Container of elements. - var elementContainer_; // Stores mapping of unit type to user coordinates. + let elementContainer_; // Stores mapping of unit type to user coordinates. - var typeMap_ = {}; + let typeMap_ = {}; /** * @interface module:units.ElementContainer */ @@ -3677,23 +3097,23 @@ * @returns {void} */ - var init = function init(elementContainer) { + const init = function (elementContainer) { elementContainer_ = elementContainer; // Get correct em/ex values by creating a temporary SVG. - var svg = document.createElementNS(NS.SVG, 'svg'); + const svg = document.createElementNS(NS.SVG, 'svg'); document.body.append(svg); - var rect = document.createElementNS(NS.SVG, 'rect'); + const rect = document.createElementNS(NS.SVG, 'rect'); rect.setAttribute('width', '1em'); rect.setAttribute('height', '1ex'); rect.setAttribute('x', '1in'); svg.append(rect); - var bb = rect.getBBox(); + const bb = rect.getBBox(); svg.remove(); - var inch = bb.x; + const inch = bb.x; typeMap_ = { em: bb.width, ex: bb.height, - "in": inch, + in: inch, cm: inch / 2.54, mm: inch / 25.4, pt: inch / 72, @@ -3711,7 +3131,7 @@ * @returns {module:units.TypeMap} The unit object with values for each unit */ - var getTypeMap = function getTypeMap() { + const getTypeMap = function () { return typeMap_; }; /** @@ -3731,8 +3151,8 @@ * with comma-separated floats */ - var shortFloat = function shortFloat(val) { - var digits = elementContainer_.getRoundDigits(); + const shortFloat = function (val) { + const digits = elementContainer_.getRoundDigits(); if (!isNaN(val)) { return Number(Number(val).toFixed(digits)); @@ -3752,7 +3172,7 @@ * @returns {Float} */ - var convertUnit = function convertUnit(val, unit) { + const convertUnit = function (val, unit) { unit = unit || elementContainer_.getBaseUnit(); // baseVal.convertToSpecifiedUnits(unitNumMap[unit]); // const val = baseVal.valueInSpecifiedUnits; // baseVal.convertToSpecifiedUnits(1); @@ -3769,7 +3189,7 @@ * @returns {void} */ - var setUnitAttr = function setUnitAttr(elem, attr, val) { + const setUnitAttr = function (elem, attr, val) { // if (!isNaN(val)) { // New value is a number, so check currently used unit // const oldVal = elem.getAttribute(attr); @@ -3812,7 +3232,7 @@ * @returns {Float} The converted number */ - var convertToNum = function convertToNum(attr, val) { + const convertToNum = function (attr, val) { // Return a number if that's what it already is if (!isNaN(val)) { return val - 0; @@ -3820,24 +3240,23 @@ if (val.substr(-1) === '%') { // Deal with percentage, depends on attribute - var _num = val.substr(0, val.length - 1) / 100; - - var width = elementContainer_.getWidth(); - var height = elementContainer_.getHeight(); + const num = val.substr(0, val.length - 1) / 100; + const width = elementContainer_.getWidth(); + const height = elementContainer_.getHeight(); if (wAttrs.includes(attr)) { - return _num * width; + return num * width; } if (hAttrs.includes(attr)) { - return _num * height; + return num * height; } - return _num * Math.sqrt(width * width + height * height) / Math.sqrt(2); + return num * Math.sqrt(width * width + height * height) / Math.sqrt(2); } - var unit = val.substr(-2); - var num = val.substr(0, val.length - 2); // Note that this multiplication turns the string into a number + const unit = val.substr(-2); + const num = val.substr(0, val.length - 2); // Note that this multiplication turns the string into a number return num * typeMap_[unit]; }; @@ -3850,7 +3269,7 @@ * @returns {boolean} Whether the unit is valid */ - var isValidUnit = function isValidUnit(attr, val, selectedElement) { + const isValidUnit = function (attr, val, selectedElement) { if (unitAttrs.includes(attr)) { // True if it's just a number if (!isNaN(val)) { @@ -3859,8 +3278,8 @@ val = val.toLowerCase(); - return Object.keys(typeMap_).some(function (unit) { - var re = new RegExp('^-?[\\d\\.]+' + unit + '$'); + return Object.keys(typeMap_).some(unit => { + const re = new RegExp('^-?[\\d\\.]+' + unit + '$'); return re.test(val); }); } @@ -3868,13 +3287,13 @@ if (attr === 'id') { // if we're trying to change the id, make sure it's not already present in the doc // and the id value is valid. - var result = false; // because getElem() can throw an exception in the case of an invalid id + let result = false; // because getElem() can throw an exception in the case of an invalid id // (according to https://www.w3.org/TR/xml-id/ IDs must be a NCName) // we wrap it in an exception and only return true if the ID was valid and // not already present try { - var elem = elementContainer_.getElement(val); + const elem = elementContainer_.getElement(val); result = isNullish(elem) || elem === selectedElement; } catch (e) {} @@ -3892,9 +3311,9 @@ * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller */ - var NEAR_ZERO = 1e-14; // Throw away SVGSVGElement used for creating matrices/transforms. + const NEAR_ZERO = 1e-14; // Throw away SVGSVGElement used for creating matrices/transforms. - var svg$1 = document.createElementNS(NS.SVG, 'svg'); + const svg$1 = document.createElementNS(NS.SVG, 'svg'); /** * A (hopefully) quicker function to transform a point by a matrix * (this function avoids any DOM calls and just does the math). @@ -3905,7 +3324,7 @@ * @returns {module:math.XYObject} An x, y object representing the transformed point */ - var transformPoint = function transformPoint(x, y, m) { + const transformPoint = function (x, y, m) { return { x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f @@ -3919,7 +3338,7 @@ * @returns {boolean} Indicates whether or not the matrix is 1,0,0,1,0,0 */ - var isIdentity = function isIdentity(m) { + const isIdentity = function (m) { return m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1 && m.e === 0 && m.f === 0; }; /** @@ -3930,12 +3349,8 @@ * @returns {SVGMatrix} The matrix object resulting from the calculation */ - var matrixMultiply = function matrixMultiply() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var m = args.reduceRight(function (prev, m1) { + const matrixMultiply = function (...args) { + const m = args.reduceRight((prev, m1) => { return m1.multiply(prev); }); @@ -3965,15 +3380,15 @@ return m; }; - var hasMatrixTransform = function hasMatrixTransform(tlist) { + const hasMatrixTransform = function (tlist) { if (!tlist) { return false; } - var num = tlist.numberOfItems; + let num = tlist.numberOfItems; while (num--) { - var xform = tlist.getItem(num); + const xform = tlist.getItem(num); if (xform.type === 1 && !isIdentity(xform.matrix)) { return true; @@ -4006,20 +3421,20 @@ * @returns {module:math.TransformedBox} */ - var transformBox = function transformBox(l, t, w, h, m) { - var tl = transformPoint(l, t, m), - tr = transformPoint(l + w, t, m), - bl = transformPoint(l, t + h, m), - br = transformPoint(l + w, t + h, m), - minx = Math.min(tl.x, tr.x, bl.x, br.x), - maxx = Math.max(tl.x, tr.x, bl.x, br.x), - miny = Math.min(tl.y, tr.y, bl.y, br.y), - maxy = Math.max(tl.y, tr.y, bl.y, br.y); + const transformBox = function (l, t, w, h, m) { + const tl = transformPoint(l, t, m), + tr = transformPoint(l + w, t, m), + bl = transformPoint(l, t + h, m), + br = transformPoint(l + w, t + h, m), + minx = Math.min(tl.x, tr.x, bl.x, br.x), + maxx = Math.max(tl.x, tr.x, bl.x, br.x), + miny = Math.min(tl.y, tr.y, bl.y, br.y), + maxy = Math.max(tl.y, tr.y, bl.y, br.y); return { - tl: tl, - tr: tr, - bl: bl, - br: br, + tl, + tr, + bl, + br, aabox: { x: minx, y: miny, @@ -4041,7 +3456,7 @@ * @returns {SVGTransform} A single matrix transform object */ - var transformListToTransform = function transformListToTransform(tlist, min, max) { + const transformListToTransform = function (tlist, min, max) { if (isNullish(tlist)) { // Or should tlist = null have been prevented before this? return svg$1.createSVGTransformFromMatrix(svg$1.createSVGMatrix()); @@ -4053,16 +3468,16 @@ max = Number.parseInt(max); if (min > max) { - var temp = max; + const temp = max; max = min; min = temp; } - var m = svg$1.createSVGMatrix(); + let m = svg$1.createSVGMatrix(); - for (var i = min; i <= max; ++i) { + for (let i = min; i <= max; ++i) { // if our indices are out of range, just use a harmless identity matrix - var mtom = i >= 0 && i < tlist.numberOfItems ? tlist.getItem(i).matrix : svg$1.createSVGMatrix(); + const mtom = i >= 0 && i < tlist.numberOfItems ? tlist.getItem(i).matrix : svg$1.createSVGMatrix(); m = matrixMultiply(m, mtom); } @@ -4075,8 +3490,8 @@ * @returns {SVGMatrix} The matrix object associated with the element's transformlist */ - var getMatrix = function getMatrix(elem) { - var tlist = getTransformList(elem); + const getMatrix = function (elem) { + const tlist = getTransformList(elem); return transformListToTransform(tlist).matrix; }; /** @@ -4090,14 +3505,14 @@ * @returns {module:math.AngleCoord45} */ - var snapToAngle = function snapToAngle(x1, y1, x2, y2) { - var snap = Math.PI / 4; // 45 degrees + const snapToAngle = function (x1, y1, x2, y2) { + const snap = Math.PI / 4; // 45 degrees - var dx = x2 - x1; - var dy = y2 - y1; - var angle = Math.atan2(dy, dx); - var dist = Math.sqrt(dx * dx + dy * dy); - var snapangle = Math.round(angle / snap) * snap; + const dx = x2 - x1; + const dy = y2 - y1; + const angle = Math.atan2(dy, dx); + const dist = Math.sqrt(dx * dx + dy * dy); + const snapangle = Math.round(angle / snap) * snap; return { x: x1 + dist * Math.cos(snapangle), y: y1 + dist * Math.sin(snapangle), @@ -4112,21 +3527,23 @@ * @returns {boolean} True if rectangles intersect */ - var rectsIntersect = function rectsIntersect(r1, r2) { + const rectsIntersect = function (r1, r2) { return r2.x < r1.x + r1.width && r2.x + r2.width > r1.x && r2.y < r1.y + r1.height && r2.y + r2.height > r1.y; }; - var $$1 = jQueryPluginSVG(jQuery); // String used to encode base64. + /* eslint-disable node/no-unsupported-features/node-builtins */ - var KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time + const $$1 = jQueryPluginSVG(jQuery); // String used to encode base64. - var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath'; - var visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath'; + const KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; // Much faster than running getBBox() every time - var editorContext_ = null; - var domdoc_ = null; - var domcontainer_ = null; - var svgroot_ = null; + const visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath'; + const visElemsArr = visElems.split(','); // const hidElems = 'defs,desc,feGaussianBlur,filter,linearGradient,marker,mask,metadata,pattern,radialGradient,stop,switch,symbol,title,textPath'; + + let editorContext_ = null; + let domdoc_ = null; + let domcontainer_ = null; + let svgroot_ = null; /** * Object with the following keys/values. * @typedef {PlainObject} module:utilities.SVGElementJSON @@ -4194,7 +3611,7 @@ * @returns {void} */ - var init$1 = function init(editorContext) { + const init$1 = function (editorContext) { editorContext_ = editorContext; domdoc_ = editorContext.getDOMDocument(); domcontainer_ = editorContext.getDOMContainer(); @@ -4208,7 +3625,7 @@ * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging */ - var dropXMLInternalSubset = function dropXMLInternalSubset(str) { + const dropXMLInternalSubset = str => { return str.replace(/()/, '$1$2'); // return str.replace(/(?\?\]>)/, '$$'); }; /** @@ -4219,11 +3636,22 @@ * @returns {string} The converted string */ - var toXml = function toXml(str) { + const toXml = function (str) { // ' is ok in XML, but not HTML // > does not normally need escaping, though it can if within a CDATA expression (and preceded by "]]") return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); // Note: `'` is XML only }; + /** + * Converts XML entities in a string to single characters. + * @function module:utilities.fromXml + * @example `&` becomes `&` + * @param {string} str - The string to be converted + * @returns {string} The converted string + */ + + function fromXml(str) { + return $$1('

').html(str).text(); + } // This code was written by Tyler Akins and has been placed in the // public domain. It would be nice if you left this header intact. // Base64 code from Tyler Akins -- http://rumkin.com // schiller: Removed string concatenation in favour of Array.join() optimization, @@ -4245,20 +3673,20 @@ return window.btoa(input); // Use native if available } - var output = new Array(Math.floor((input.length + 2) / 3) * 4); - var i = 0, + const output = new Array(Math.floor((input.length + 2) / 3) * 4); + let i = 0, p = 0; do { - var chr1 = input.charCodeAt(i++); - var chr2 = input.charCodeAt(i++); - var chr3 = input.charCodeAt(i++); + const chr1 = input.charCodeAt(i++); + const chr2 = input.charCodeAt(i++); + const chr3 = input.charCodeAt(i++); /* eslint-disable no-bitwise */ - var enc1 = chr1 >> 2; - var enc2 = (chr1 & 3) << 4 | chr2 >> 4; - var enc3 = (chr2 & 15) << 2 | chr3 >> 6; - var enc4 = chr3 & 63; + const enc1 = chr1 >> 2; + const enc2 = (chr1 & 3) << 4 | chr2 >> 4; + let enc3 = (chr2 & 15) << 2 | chr3 >> 6; + let enc4 = chr3 & 63; /* eslint-enable no-bitwise */ if (Number.isNaN(chr2)) { @@ -4290,19 +3718,19 @@ input = input.replace(/[^A-Za-z\d+/=]/g, ''); - var output = ''; - var i = 0; + let output = ''; + let i = 0; do { - var enc1 = KEYSTR.indexOf(input.charAt(i++)); - var enc2 = KEYSTR.indexOf(input.charAt(i++)); - var enc3 = KEYSTR.indexOf(input.charAt(i++)); - var enc4 = KEYSTR.indexOf(input.charAt(i++)); + const enc1 = KEYSTR.indexOf(input.charAt(i++)); + const enc2 = KEYSTR.indexOf(input.charAt(i++)); + const enc3 = KEYSTR.indexOf(input.charAt(i++)); + const enc4 = KEYSTR.indexOf(input.charAt(i++)); /* eslint-disable no-bitwise */ - var chr1 = enc1 << 2 | enc2 >> 4; - var chr2 = (enc2 & 15) << 4 | enc3 >> 2; - var chr3 = (enc3 & 3) << 6 | enc4; + const chr1 = enc1 << 2 | enc2 >> 4; + const chr2 = (enc2 & 15) << 4 | enc3 >> 2; + const chr3 = (enc3 & 3) << 6 | enc4; /* eslint-enable no-bitwise */ output += String.fromCharCode(chr1); @@ -4334,7 +3762,7 @@ * @returns {string} */ - var encodeUTF8 = function encodeUTF8(argString) { + const encodeUTF8 = function (argString) { return unescape(encodeURIComponent(argString)); }; /** @@ -4344,28 +3772,28 @@ * @returns {string} object URL or empty string */ - var dataURLToObjectURL = function dataURLToObjectURL(dataurl) { + const dataURLToObjectURL = function (dataurl) { if (typeof Uint8Array === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) { return ''; } - var arr = dataurl.split(','), - mime = arr[0].match(/:(.*?);/)[1], - bstr = atob(arr[1]); + const arr = dataurl.split(','), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[1]); /* const [prefix, suffix] = dataurl.split(','), {groups: {mime}} = prefix.match(/:(?.*?);/), bstr = atob(suffix); */ - var n = bstr.length; - var u8arr = new Uint8Array(n); + let n = bstr.length; + const u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } - var blob = new Blob([u8arr], { + const blob = new Blob([u8arr], { type: mime }); return URL.createObjectURL(blob); @@ -4377,7 +3805,7 @@ * @returns {string} object URL or empty string */ - var createObjectURL = function createObjectURL(blob) { + const createObjectURL = function (blob) { if (!blob || typeof URL === 'undefined' || !URL.createObjectURL) { return ''; } @@ -4388,17 +3816,37 @@ * @property {string} blankPageObjectURL */ - var blankPageObjectURL = function () { + const blankPageObjectURL = function () { if (typeof Blob === 'undefined') { return ''; } - var blob = new Blob(['SVG-edit '], { + const blob = new Blob(['SVG-edit '], { type: 'text/html' }); return createObjectURL(blob); }(); /** + * Converts a string to use XML references (for non-ASCII). + * @function module:utilities.convertToXMLReferences + * @param {string} input + * @returns {string} Decimal numeric character references + */ + + const convertToXMLReferences = function (input) { + let output = ''; + [...input].forEach(ch => { + const c = ch.charCodeAt(); + + if (c <= 127) { + output += ch; + } else { + output += `&#${c};`; + } + }); + return output; + }; + /** * Cross-browser compatible method of converting a string to an XML tree. * Found this function [here]{@link http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f}. * @function module:utilities.text2xml @@ -4407,12 +3855,12 @@ * @returns {XMLDocument} */ - var text2xml = function text2xml(sXML) { + const text2xml = function (sXML) { if (sXML.includes('` element, creating it first if necessary */ - var findDefs = function findDefs() { - var svgElement = editorContext_.getSVGContent(); - var defs = svgElement.getElementsByTagNameNS(NS.SVG, 'defs'); + const findDefs = function () { + const svgElement = editorContext_.getSVGContent(); + let defs = svgElement.getElementsByTagNameNS(NS.SVG, 'defs'); if (defs.length > 0) { defs = defs[0]; @@ -4589,21 +4038,21 @@ * @returns {module:utilities.BBoxObject} A BBox-like object */ - var getPathBBox = function getPathBBox(path) { - var seglist = path.pathSegList; - var tot = seglist.numberOfItems; - var bounds = [[], []]; - var start = seglist.getItem(0); - var P0 = [start.x, start.y]; + const getPathBBox = function (path) { + const seglist = path.pathSegList; + const tot = seglist.numberOfItems; + const bounds = [[], []]; + const start = seglist.getItem(0); + let P0 = [start.x, start.y]; - var getCalc = function getCalc(j, P1, P2, P3) { + const getCalc = function (j, P1, P2, P3) { return function (t) { - return 1 - Math.pow(t, 3) * P0[j] + 3 * 1 - Math.pow(t, 2) * t * P1[j] + 3 * (1 - t) * Math.pow(t, 2) * P2[j] + Math.pow(t, 3) * P3[j]; + return 1 - t ** 3 * P0[j] + 3 * 1 - t ** 2 * t * P1[j] + 3 * (1 - t) * t ** 2 * P2[j] + t ** 3 * P3[j]; }; }; - for (var i = 0; i < tot; i++) { - var seg = seglist.getItem(i); + for (let i = 0; i < tot; i++) { + const seg = seglist.getItem(i); if (seg.x === undefined) { continue; @@ -4614,22 +4063,22 @@ bounds[1].push(P0[1]); if (seg.x1) { - var P1 = [seg.x1, seg.y1], - P2 = [seg.x2, seg.y2], - P3 = [seg.x, seg.y]; + const P1 = [seg.x1, seg.y1], + P2 = [seg.x2, seg.y2], + P3 = [seg.x, seg.y]; - for (var j = 0; j < 2; j++) { - var calc = getCalc(j, P1, P2, P3); - var b = 6 * P0[j] - 12 * P1[j] + 6 * P2[j]; - var a = -3 * P0[j] + 9 * P1[j] - 9 * P2[j] + 3 * P3[j]; - var c = 3 * P1[j] - 3 * P0[j]; + for (let j = 0; j < 2; j++) { + const calc = getCalc(j, P1, P2, P3); + const b = 6 * P0[j] - 12 * P1[j] + 6 * P2[j]; + const a = -3 * P0[j] + 9 * P1[j] - 9 * P2[j] + 3 * P3[j]; + const c = 3 * P1[j] - 3 * P0[j]; if (a === 0) { if (b === 0) { continue; } - var t = -c / b; + const t = -c / b; if (t > 0 && t < 1) { bounds[j].push(calc(t)); @@ -4638,19 +4087,19 @@ continue; } - var b2ac = Math.pow(b, 2) - 4 * c * a; + const b2ac = b ** 2 - 4 * c * a; if (b2ac < 0) { continue; } - var t1 = (-b + Math.sqrt(b2ac)) / (2 * a); + const t1 = (-b + Math.sqrt(b2ac)) / (2 * a); if (t1 > 0 && t1 < 1) { bounds[j].push(calc(t1)); } - var t2 = (-b - Math.sqrt(b2ac)) / (2 * a); + const t2 = (-b - Math.sqrt(b2ac)) / (2 * a); if (t2 > 0 && t2 < 1) { bounds[j].push(calc(t2)); @@ -4664,13 +4113,13 @@ } } - var x = Math.min.apply(null, bounds[0]); - var w = Math.max.apply(null, bounds[0]) - x; - var y = Math.min.apply(null, bounds[1]); - var h = Math.max.apply(null, bounds[1]) - y; + const x = Math.min.apply(null, bounds[0]); + const w = Math.max.apply(null, bounds[0]) - x; + const y = Math.min.apply(null, bounds[1]); + const h = Math.max.apply(null, bounds[1]) - y; return { - x: x, - y: y, + x, + y, width: w, height: h }; @@ -4691,9 +4140,9 @@ } catch (e) {} } - var ref = $$1.data(selected, 'ref'); - var matched = null; - var ret, copy; + const ref = $$1.data(selected, 'ref'); + let matched = null; + let ret, copy; if (ref) { copy = $$1(ref).children().clone().attr('visibility', 'hidden'); @@ -4703,11 +4152,11 @@ matched = $$1(selected).find('line, path'); } - var issue = false; + let issue = false; if (matched.length) { matched.each(function () { - var bb = this.getBBox(); + const bb = this.getBBox(); if (!bb.width || !bb.height) { issue = true; @@ -4715,7 +4164,7 @@ }); if (issue) { - var elems = ref ? copy : $$1(selected).children(); + const elems = ref ? copy : $$1(selected).children(); ret = getStrokedBBox(elems); } else { ret = selected.getBBox(); @@ -4739,15 +4188,15 @@ */ - var getBBox = function getBBox(elem) { - var selected = elem || editorContext_.geSelectedElements()[0]; + const getBBox = function (elem) { + const selected = elem || editorContext_.geSelectedElements()[0]; if (elem.nodeType !== 1) { return null; } - var elname = selected.nodeName; - var ret = null; + const elname = selected.nodeName; + let ret = null; switch (elname) { case 'text': @@ -4790,14 +4239,15 @@ if (!isWebkit()) { - var _ret = ret, - x = _ret.x, - y = _ret.y, - width = _ret.width, - height = _ret.height; - var bb = { - width: width, - height: height, + const { + x, + y, + width, + height + } = ret; + const bb = { + width, + height, x: x + Number.parseFloat(selected.getAttribute('x') || 0), y: y + Number.parseFloat(selected.getAttribute('y') || 0) }; @@ -4810,21 +4260,20 @@ } catch (err) { // tspan (and textPath apparently) have no `getBBox` in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=937268 // Re: Chrome returning bbox for containing text element, see: https://bugs.chromium.org/p/chromium/issues/detail?id=349835 - var extent = selected.getExtentOfChar(0); // pos+dimensions of the first glyph - - var _width = selected.getComputedTextLength(); // width of the tspan + const extent = selected.getExtentOfChar(0); // pos+dimensions of the first glyph + const width = selected.getComputedTextLength(); // width of the tspan ret = { x: extent.x, y: extent.y, - width: _width, + width, height: extent.height }; } } else { // Check if element is child of a foreignObject - var fo = $$1(selected).closest('foreignObject'); + const fo = $$1(selected).closest('foreignObject'); if (fo.length) { if (fo[0].getBBox) { @@ -4858,16 +4307,12 @@ * @returns {string} The converted path d attribute. */ - var getPathDFromSegments = function getPathDFromSegments(pathSegments) { - var d = ''; - $$1.each(pathSegments, function (j, _ref2) { - var _ref3 = _slicedToArray(_ref2, 2), - singleChar = _ref3[0], - pts = _ref3[1]; - + const getPathDFromSegments = function (pathSegments) { + let d = ''; + $$1.each(pathSegments, function (j, [singleChar, pts]) { d += singleChar; - for (var i = 0; i < pts.length; i += 2) { + for (let i = 0; i < pts.length; i += 2) { d += pts[i] + ',' + pts[i + 1] + ' '; } }); @@ -4880,22 +4325,24 @@ * @returns {string} The path d attribute or `undefined` if the element type is unknown. */ - var getPathDFromElement = function getPathDFromElement(elem) { + const getPathDFromElement = function (elem) { // Possibly the cubed root of 6, but 1.81 works best - var num = 1.81; - var d, a, rx, ry; + let num = 1.81; + let d, a, rx, ry; switch (elem.tagName) { case 'ellipse': case 'circle': { a = $$1(elem).attr(['rx', 'ry', 'cx', 'cy']); - var _a = a, - cx = _a.cx, - cy = _a.cy; - var _a2 = a; - rx = _a2.rx; - ry = _a2.ry; + const { + cx, + cy + } = a; + ({ + rx, + ry + } = a); if (elem.tagName === 'circle') { ry = $$1(elem).attr('r'); @@ -4925,14 +4372,18 @@ case 'rect': { - var r = $$1(elem).attr(['rx', 'ry']); - rx = r.rx; - ry = r.ry; - var b = elem.getBBox(); - var x = b.x, - y = b.y, - w = b.width, - h = b.height; + const r = $$1(elem).attr(['rx', 'ry']); + ({ + rx, + ry + } = r); + const b = elem.getBBox(); + const { + x, + y + } = b, + w = b.width, + h = b.height; num = 4 - num; // Why? Because! if (!rx && !ry) { @@ -4955,12 +4406,12 @@ * @returns {PlainObject<"marker-start"|"marker-end"|"marker-mid"|"filter"|"clip-path", string>} An object with attributes. */ - var getExtraAttributesForConvertToPath = function getExtraAttributesForConvertToPath(elem) { - var attrs = {}; // TODO: make this list global so that we can properly maintain it + const getExtraAttributesForConvertToPath = function (elem) { + const attrs = {}; // TODO: make this list global so that we can properly maintain it // TODO: what about @transform, @clip-rule, @fill-rule, etc? $$1.each(['marker-start', 'marker-end', 'marker-mid', 'filter', 'clip-path'], function () { - var a = elem.getAttribute(this); + const a = elem.getAttribute(this); if (a) { attrs[this] = a; @@ -4977,18 +4428,20 @@ * @returns {DOMRect|false} The resulting path's bounding box object. */ - var getBBoxOfElementAsPath = function getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions) { - var path = addSVGElementFromJson({ + const getBBoxOfElementAsPath = function (elem, addSVGElementFromJson, pathActions) { + const path = addSVGElementFromJson({ element: 'path', attr: getExtraAttributesForConvertToPath(elem) }); - var eltrans = elem.getAttribute('transform'); + const eltrans = elem.getAttribute('transform'); if (eltrans) { path.setAttribute('transform', eltrans); } - var parentNode = elem.parentNode; + const { + parentNode + } = elem; if (elem.nextSibling) { elem.before(path); @@ -4996,7 +4449,7 @@ parentNode.append(path); } - var d = getPathDFromElement(elem); + const d = getPathDFromElement(elem); if (d) { path.setAttribute('d', d); @@ -5006,7 +4459,7 @@ pathActions.resetOrientation(path); - var bb = false; + let bb = false; try { bb = path.getBBox(); @@ -5030,22 +4483,26 @@ * @returns {SVGPathElement|null} The converted path element or null if the DOM element was not recognized. */ - var convertToPath = function convertToPath(elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) { - var batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes + const convertToPath = function (elem, attrs, addSVGElementFromJson, pathActions, clearSelection, addToSelection, hstry, addCommandToHistory) { + const batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes attrs = $$1.extend({}, attrs, getExtraAttributesForConvertToPath(elem)); - var path = addSVGElementFromJson({ + const path = addSVGElementFromJson({ element: 'path', attr: attrs }); - var eltrans = elem.getAttribute('transform'); + const eltrans = elem.getAttribute('transform'); if (eltrans) { path.setAttribute('transform', eltrans); } - var id = elem.id; - var parentNode = elem.parentNode; + const { + id + } = elem; + const { + parentNode + } = elem; if (elem.nextSibling) { elem.before(path); @@ -5053,21 +4510,23 @@ parentNode.append(path); } - var d = getPathDFromElement(elem); + const d = getPathDFromElement(elem); if (d) { path.setAttribute('d', d); // Replace the current element with the converted one // Reorient if it has a matrix if (eltrans) { - var tlist = getTransformList(path); + const tlist = getTransformList(path); if (hasMatrixTransform(tlist)) { pathActions.resetOrientation(path); } } - var nextSibling = elem.nextSibling; + const { + nextSibling + } = elem; batchCmd.addSubCommand(new hstry.RemoveElementCommand(elem, nextSibling, parent)); batchCmd.addSubCommand(new hstry.InsertElementCommand(path)); clearSelection(); @@ -5105,9 +4564,9 @@ */ function bBoxCanBeOptimizedOverNativeGetBBox(angle, hasAMatrixTransform) { - var angleModulo90 = angle % 90; - var closeTo90 = angleModulo90 < -89.99 || angleModulo90 > 89.99; - var closeTo0 = angleModulo90 > -0.001 && angleModulo90 < 0.001; + const angleModulo90 = angle % 90; + const closeTo90 = angleModulo90 < -89.99 || angleModulo90 > 89.99; + const closeTo0 = angleModulo90 > -0.001 && angleModulo90 < 0.001; return hasAMatrixTransform || !(closeTo0 || closeTo90); } /** @@ -5120,35 +4579,35 @@ */ - var getBBoxWithTransform = function getBBoxWithTransform(elem, addSVGElementFromJson, pathActions) { + const getBBoxWithTransform = function (elem, addSVGElementFromJson, pathActions) { // TODO: Fix issue with rotated groups. Currently they work // fine in FF, but not in other browsers (same problem mentioned // in Issue 339 comment #2). - var bb = getBBox(elem); + let bb = getBBox(elem); if (!bb) { return null; } - var tlist = getTransformList(elem); - var angle = getRotationAngleFromTransformList(tlist); - var hasMatrixXForm = hasMatrixTransform(tlist); + const tlist = getTransformList(elem); + const angle = getRotationAngleFromTransformList(tlist); + const hasMatrixXForm = hasMatrixTransform(tlist); if (angle || hasMatrixXForm) { - var goodBb = false; + let goodBb = false; if (bBoxCanBeOptimizedOverNativeGetBBox(angle, hasMatrixXForm)) { // Get the BBox from the raw path for these elements // TODO: why ellipse and not circle - var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; + const elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; if (elemNames.includes(elem.tagName)) { goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); bb = goodBb; } else if (elem.tagName === 'rect') { // Look for radius - var rx = elem.getAttribute('rx'); - var ry = elem.getAttribute('ry'); + const rx = elem.getAttribute('rx'); + const ry = elem.getAttribute('ry'); if (rx || ry) { goodBb = getBBoxOfElementAsPath(elem, addSVGElementFromJson, pathActions); @@ -5158,9 +4617,9 @@ } if (!goodBb) { - var _transformListToTrans = transformListToTransform(tlist), - matrix = _transformListToTrans.matrix; - + const { + matrix + } = transformListToTransform(tlist); bb = transformBox(bb.x, bb.y, bb.width, bb.height, matrix).aabox; // Old technique that was exceedingly slow with large documents. // // Accurate way to get BBox of rotated element in Firefox: @@ -5187,7 +4646,7 @@ */ function getStrokeOffsetForBBox(elem) { - var sw = elem.getAttribute('stroke-width'); + const sw = elem.getAttribute('stroke-width'); return !isNaN(sw) && elem.getAttribute('stroke') !== 'none' ? sw / 2 : 0; } /** @@ -5208,12 +4667,12 @@ */ - var getStrokedBBox = function getStrokedBBox(elems, addSVGElementFromJson, pathActions) { + const getStrokedBBox = function (elems, addSVGElementFromJson, pathActions) { if (!elems || !elems.length) { return false; } - var fullBb; + let fullBb; $$1.each(elems, function () { if (fullBb) { return; @@ -5232,30 +4691,29 @@ // if (elems.length == 1) return fullBb; - var maxX = fullBb.x + fullBb.width; - var maxY = fullBb.y + fullBb.height; - var minX = fullBb.x; - var minY = fullBb.y; // If only one elem, don't call the potentially slow getBBoxWithTransform method again. + let maxX = fullBb.x + fullBb.width; + let maxY = fullBb.y + fullBb.height; + let minX = fullBb.x; + let minY = fullBb.y; // If only one elem, don't call the potentially slow getBBoxWithTransform method again. if (elems.length === 1) { - var offset = getStrokeOffsetForBBox(elems[0]); + const offset = getStrokeOffsetForBBox(elems[0]); minX -= offset; minY -= offset; maxX += offset; maxY += offset; } else { $$1.each(elems, function (i, elem) { - var curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions); + const curBb = getBBoxWithTransform(elem, addSVGElementFromJson, pathActions); if (curBb) { - var _offset = getStrokeOffsetForBBox(elem); - - minX = Math.min(minX, curBb.x - _offset); - minY = Math.min(minY, curBb.y - _offset); // TODO: The old code had this test for max, but not min. I suspect this test should be for both min and max + const offset = getStrokeOffsetForBBox(elem); + minX = Math.min(minX, curBb.x - offset); + minY = Math.min(minY, curBb.y - offset); // TODO: The old code had this test for max, but not min. I suspect this test should be for both min and max if (elem.nodeType === 1) { - maxX = Math.max(maxX, curBb.x + curBb.width + _offset); - maxY = Math.max(maxY, curBb.y + curBb.height + _offset); + maxX = Math.max(maxX, curBb.x + curBb.width + offset); + maxY = Math.max(maxY, curBb.y + curBb.height + offset); } } }); @@ -5276,12 +4734,12 @@ * @returns {Element[]} All "visible" elements. */ - var getVisibleElements = function getVisibleElements(parentElement) { + const getVisibleElements = function (parentElement) { if (!parentElement) { parentElement = $$1(editorContext_.getSVGContent()).children(); // Prevent layers from being included } - var contentElems = []; + const contentElems = []; $$1(parentElement).children().each(function (i, elem) { if (elem.getBBox) { contentElems.push(elem); @@ -5296,7 +4754,7 @@ * @returns {module:utilities.BBoxObject} A single bounding box object */ - var getStrokedBBoxDefaultVisible = function getStrokedBBoxDefaultVisible(elems) { + const getStrokedBBoxDefaultVisible = function (elems) { if (!elems) { elems = getVisibleElements(); } @@ -5311,16 +4769,16 @@ * @returns {Float} The angle in degrees or radians */ - var getRotationAngleFromTransformList = function getRotationAngleFromTransformList(tlist, toRad) { + const getRotationAngleFromTransformList = function (tlist, toRad) { if (!tlist) { return 0; } // elements have no tlist - var N = tlist.numberOfItems; + const N = tlist.numberOfItems; - for (var i = 0; i < N; ++i) { - var xform = tlist.getItem(i); + for (let i = 0; i < N; ++i) { + const xform = tlist.getItem(i); if (xform.type === 4) { return toRad ? xform.angle * Math.PI / 180.0 : xform.angle; @@ -5337,11 +4795,11 @@ * @returns {Float} The angle in degrees or radians */ - var getRotationAngle = function getRotationAngle(elem, toRad) { + let getRotationAngle = function (elem, toRad) { // eslint-disable-line import/no-mutable-exports - var selected = elem || editorContext_.getSelectedElements()[0]; // find the rotation transform (if any) and set it + const selected = elem || editorContext_.getSelectedElements()[0]; // find the rotation transform (if any) and set it - var tlist = getTransformList(selected); + const tlist = getTransformList(selected); return getRotationAngleFromTransformList(tlist, toRad); }; /** @@ -5351,7 +4809,7 @@ * @returns {Element} Reference element */ - var getRefElem = function getRefElem(attrVal) { + const getRefElem = function (attrVal) { return getElem(getUrlFromAttr(attrVal).substr(1)); }; /** @@ -5361,7 +4819,7 @@ * @returns {?Element} */ - var getElem = supportsSelectors() ? function (id) { + const getElem = supportsSelectors() ? function (id) { // querySelector lookup return svgroot_.querySelector('#' + id); } : supportsXpath() ? function (id) { @@ -5371,7 +4829,7 @@ }, 9, null).singleNodeValue; } : function (id) { // jQuery lookup: twice as slow as xpath in FF - return $$1(svgroot_).find("[id=".concat(id, "]"))[0]; + return $$1(svgroot_).find(`[id=${id}]`)[0]; }; /** * Assigns multiple attributes to an element. @@ -5383,13 +4841,9 @@ * @returns {void} */ - var assignAttributes = function assignAttributes(elem, attrs, suspendLength, unitCheck) { - for (var _i = 0, _Object$entries = Object.entries(attrs); _i < _Object$entries.length; _i++) { - var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), - key = _Object$entries$_i[0], - value = _Object$entries$_i[1]; - - var ns = key.substr(0, 4) === 'xml:' ? NS.XML : key.substr(0, 6) === 'xlink:' ? NS.XLINK : null; + const assignAttributes = function (elem, attrs, suspendLength, unitCheck) { + for (const [key, value] of Object.entries(attrs)) { + const ns = key.substr(0, 4) === 'xml:' ? NS.XML : key.substr(0, 6) === 'xlink:' ? NS.XLINK : null; if (isNullish(value)) { if (ns) { @@ -5417,8 +4871,8 @@ * @returns {void} */ - var cleanupElement = function cleanupElement(element) { - var defaults = { + const cleanupElement = function (element) { + const defaults = { 'fill-opacity': 1, 'stop-opacity': 1, opacity: 1, @@ -5438,11 +4892,7 @@ delete defaults.ry; } - Object.entries(defaults).forEach(function (_ref4) { - var _ref5 = _slicedToArray(_ref4, 2), - attr = _ref5[0], - val = _ref5[1]; - + Object.entries(defaults).forEach(([attr, val]) => { if (element.getAttribute(attr) === String(val)) { element.removeAttribute(attr); } @@ -5455,9 +4905,9 @@ * @returns {Integer} */ - var snapToGrid = function snapToGrid(value) { - var unit = editorContext_.getBaseUnit(); - var stepSize = editorContext_.getSnappingStep(); + const snapToGrid = function (value) { + const unit = editorContext_.getBaseUnit(); + let stepSize = editorContext_.getSnappingStep(); if (unit !== 'px') { stepSize *= getTypeMap()[unit]; @@ -5473,7 +4923,7 @@ * @returns {string} */ - var regexEscape = function regexEscape(str) { + const regexEscape = function (str) { // Originally from: http://phpjs.org/functions return String(str).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g, '\\$&'); }; @@ -5484,7 +4934,7 @@ * @returns {void} */ - var preventClickDefault = function preventClickDefault(img) { + const preventClickDefault = function (img) { $$1(img).click(function (e) { e.preventDefault(); }); @@ -5500,12 +4950,78 @@ * @returns {boolean} */ - var isNullish = function isNullish(val) { + const isNullish = val => { return val === null || val === undefined; }; - var $q = function $q(sel) { - return document.querySelector(sel); + /** + * Overwrite methods for unit testing. + * @function module:utilities.mock + * @param {PlainObject} mockMethods + * @param {module:utilities.getHref} mockMethods.getHref + * @param {module:utilities.setHref} mockMethods.setHref + * @param {module:utilities.getRotationAngle} mockMethods.getRotationAngle + * @returns {void} + */ + + const mock = ({ + getHref: getHrefUser, + setHref: setHrefUser, + getRotationAngle: getRotationAngleUser + }) => { + getHref = getHrefUser; + setHref = setHrefUser; + getRotationAngle = getRotationAngleUser; }; + const $q = sel => document.querySelector(sel); + const $qq = sel => [...document.querySelectorAll(sel)]; + + var Utils = /*#__PURE__*/Object.freeze({ + __proto__: null, + init: init$1, + dropXMLInternalSubset: dropXMLInternalSubset, + toXml: toXml, + fromXml: fromXml, + encode64: encode64, + decode64: decode64, + decodeUTF8: decodeUTF8, + encodeUTF8: encodeUTF8, + dataURLToObjectURL: dataURLToObjectURL, + createObjectURL: createObjectURL, + blankPageObjectURL: blankPageObjectURL, + convertToXMLReferences: convertToXMLReferences, + text2xml: text2xml, + bboxToObj: bboxToObj, + walkTree: walkTree, + walkTreePost: walkTreePost, + getUrlFromAttr: getUrlFromAttr, + get getHref () { return getHref; }, + get setHref () { return setHref; }, + findDefs: findDefs, + getPathBBox: getPathBBox, + getBBox: getBBox, + getPathDFromSegments: getPathDFromSegments, + getPathDFromElement: getPathDFromElement, + getExtraAttributesForConvertToPath: getExtraAttributesForConvertToPath, + getBBoxOfElementAsPath: getBBoxOfElementAsPath, + convertToPath: convertToPath, + getBBoxWithTransform: getBBoxWithTransform, + getStrokedBBox: getStrokedBBox, + getVisibleElements: getVisibleElements, + getStrokedBBoxDefaultVisible: getStrokedBBoxDefaultVisible, + getRotationAngleFromTransformList: getRotationAngleFromTransformList, + get getRotationAngle () { return getRotationAngle; }, + getRefElem: getRefElem, + getElem: getElem, + assignAttributes: assignAttributes, + cleanupElement: cleanupElement, + snapToGrid: snapToGrid, + regexEscape: regexEscape, + preventClickDefault: preventClickDefault, + isNullish: isNullish, + mock: mock, + $q: $q, + $qq: $qq + }); /* globals jQuery */ @@ -5517,15 +5033,15 @@ */ // Dependencies: // 1) jQuery (for dom injection of context menus) - var $$2 = jQuery; - var contextMenuExtensions = {}; + const $$2 = jQuery; + let contextMenuExtensions = {}; /** * @function module:contextmenu.hasCustomHandler * @param {string} handlerKey * @returns {boolean} */ - var hasCustomHandler = function hasCustomHandler(handlerKey) { + const hasCustomHandler = function (handlerKey) { return Boolean(contextMenuExtensions[handlerKey]); }; /** @@ -5534,7 +5050,7 @@ * @returns {module:contextmenu.MenuItemAction} */ - var getCustomHandler = function getCustomHandler(handlerKey) { + const getCustomHandler = function (handlerKey) { return contextMenuExtensions[handlerKey].action; }; /** @@ -5542,14 +5058,14 @@ * @returns {void} */ - var injectExtendedContextMenuItemIntoDom = function injectExtendedContextMenuItemIntoDom(menuItem) { + const injectExtendedContextMenuItemIntoDom = function (menuItem) { if (!Object.keys(contextMenuExtensions).length) { // all menuItems appear at the bottom of the menu in their own container. // if this is the first extension menu we need to add the separator. $$2('#cmenu_canvas').append("

  • "); } - var shortcut = menuItem.shortcut || ''; + const shortcut = menuItem.shortcut || ''; $$2('#cmenu_canvas').append("
  • " + menuItem.label + "" + shortcut + '
  • '); }; /** @@ -5558,12 +5074,30 @@ */ - var injectExtendedContextMenuItemsIntoDom = function injectExtendedContextMenuItemsIntoDom() { - Object.values(contextMenuExtensions).forEach(function (menuItem) { + const injectExtendedContextMenuItemsIntoDom = function () { + Object.values(contextMenuExtensions).forEach(menuItem => { injectExtendedContextMenuItemIntoDom(menuItem); }); }; + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + /* eslint-disable jsdoc/require-file-overview */ /** @@ -5578,7 +5112,7 @@ * @returns {string} */ function toAbsoluteURL(url) { - var a = document.createElement('a'); + const a = document.createElement('a'); a.setAttribute('href', url); // return a.cloneNode(false).href; // -> "http://example.com/hoge.html" @@ -5592,7 +5126,7 @@ function addScriptAtts(script, atts) { - ['id', 'class', 'type'].forEach(function (prop) { + ['id', 'class', 'type'].forEach(prop => { if (prop in atts) { script[prop] = atts[prop]; } @@ -5626,8 +5160,21 @@ * any other value depends on the export of the targeted module. */ - function importSetGlobal(_x, _x2) { - return _importSetGlobal.apply(this, arguments); + async function importSetGlobal(url, { + global: glob, + returnDefault + }) { + // Todo: Replace calls to this function with `import()` when supported + const modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; + + if (modularVersion) { + return importModule(url, undefined, { + returnDefault + }); + } + + await importScript(url); + return window[glob]; } /** * @@ -5638,62 +5185,23 @@ * script loading error */ - function _importSetGlobal() { - _importSetGlobal = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, _ref) { - var glob, returnDefault, modularVersion; - return regeneratorRuntime.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - glob = _ref.global, returnDefault = _ref.returnDefault; - // Todo: Replace calls to this function with `import()` when supported - modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; - - if (!modularVersion) { - _context.next = 4; - break; - } - - return _context.abrupt("return", importModule(url, undefined, { - returnDefault: returnDefault - })); - - case 4: - _context.next = 6; - return importScript(url); - - case 6: - return _context.abrupt("return", window[glob]); - - case 7: - case "end": - return _context.stop(); - } - } - }, _callee); - })); - return _importSetGlobal.apply(this, arguments); - } - - function importScript(url) { - var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - + function importScript(url, atts = {}) { if (Array.isArray(url)) { - return Promise.all(url.map(function (u) { + return Promise.all(url.map(u => { return importScript(u, atts); })); } - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new - var script = document.createElement('script'); + const script = document.createElement('script'); /** * * @returns {void} */ function scriptOnError() { - reject(new Error("Failed to import: ".concat(url))); + reject(new Error(`Failed to import: ${url}`)); destructor(); } /** @@ -5707,7 +5215,7 @@ destructor(); } - var destructor = function destructor() { + const destructor = () => { script.removeEventListener('error', scriptOnError); script.removeEventListener('load', scriptOnLoad); script.remove(); @@ -5732,30 +5240,26 @@ * `Error` upon a script loading error. */ - function importModule(url) { - var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - _ref2$returnDefault = _ref2.returnDefault, - returnDefault = _ref2$returnDefault === void 0 ? false : _ref2$returnDefault; - + function importModule(url, atts = {}, { + returnDefault = false + } = {}) { if (Array.isArray(url)) { - return Promise.all(url.map(function (u) { + return Promise.all(url.map(u => { return importModule(u, atts); })); } - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new - var vector = '$importModule$' + Math.random().toString(32).slice(2); - var script = document.createElement('script'); + const vector = '$importModule$' + Math.random().toString(32).slice(2); + const script = document.createElement('script'); /** * * @returns {void} */ function scriptOnError() { - reject(new Error("Failed to import: ".concat(url))); + reject(new Error(`Failed to import: ${url}`)); destructor(); } /** @@ -5769,7 +5273,7 @@ destructor(); } - var destructor = function destructor() { + const destructor = () => { delete window[vector]; script.removeEventListener('error', scriptOnError); script.removeEventListener('load', scriptOnLoad); @@ -5783,10 +5287,10 @@ script.type = 'module'; script.addEventListener('error', scriptOnError); script.addEventListener('load', scriptOnLoad); - var absURL = toAbsoluteURL(url); - var loader = "import * as m from '".concat(absURL.replace(/'/g, "\\'"), "'; window.").concat(vector, " = ").concat(returnDefault ? 'm.default || ' : '', "m;"); // export Module + const absURL = toAbsoluteURL(url); + const loader = `import * as m from '${absURL.replace(/'/g, "\\'")}'; window.${vector} = ${returnDefault ? 'm.default || ' : ''}m;`; // export Module - var blob = new Blob([loader], { + const blob = new Blob([loader], { type: 'text/javascript' }); script.src = URL.createObjectURL(blob); @@ -5802,7 +5306,7 @@ An extraction of the deparam method from Ben Alman's jQuery BBQ http://benalman.com/projects/jquery-bbq-plugin/ */ - var coerce_types = { + const coerce_types = { 'true': !0, 'false': !1, 'null': null @@ -5810,11 +5314,11 @@ function deparam(params, coerce) { // console.log(params) - var obj = {}; // Iterate over all name=value pairs. + const obj = {}; // Iterate over all name=value pairs. params.replace(/\+/g, ' ').split('&').forEach(function (v) { - var param = v.split('='); - var key = decodeURIComponent(param[0]), + const param = v.split('='); + let key = decodeURIComponent(param[0]), // If key is more complex than 'foo', like 'a[]' or 'a[b][c]', split it // into its component parts. keys = key.split(']['), @@ -5835,7 +5339,7 @@ if (param.length >= 2) { - var val = decodeURIComponent(param.slice(1).join('=')); // Coerce values. + let val = decodeURIComponent(param.slice(1).join('=')); // Coerce values. if (coerce) { val = val && !isNaN(val) ? +val // number @@ -5845,7 +5349,7 @@ } if (keys_last) { - var cur = obj; // Complex key, build deep object structure based on a few rules: + let cur = obj; // Complex key, build deep object structure based on a few rules: // * The 'cur' pointer starts at the object top-level. // * [] = array push (n is set to array length), [n] = array if n is // numeric, otherwise object. @@ -5855,7 +5359,7 @@ // * Move the 'cur' pointer to the next level. // * Rinse & repeat. - for (var i = 0; i <= keys_last; i++) { + for (let i = 0; i <= keys_last; i++) { key = keys[i] === '' ? cur.length : keys[i]; cur = cur[key] = i < keys_last ? cur[key] || (keys[i + 1] && isNaN(keys[i + 1]) ? {} : []) : val; } @@ -5893,13 +5397,10 @@ * @param {PlainObject} [strings.cancel] * @returns {external:jQuery} */ - function jQueryPluginDBox($) { - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - _ref$ok = _ref.ok, - okString = _ref$ok === void 0 ? 'Ok' : _ref$ok, - _ref$cancel = _ref.cancel, - cancelString = _ref$cancel === void 0 ? 'Cancel' : _ref$cancel; - + function jQueryPluginDBox($, { + ok: okString = 'Ok', + cancel: cancelString = 'Cancel' + } = {}) { // This sets up alternative dialog boxes. They mostly work the same way as // their UI counterparts, expect instead of returning the result, a callback // needs to be included that returns the result as its first parameter. @@ -5909,9 +5410,9 @@ cancel: '#dialog_content, #dialog_buttons *', containment: 'window' }).css('position', 'absolute'); - var box = $('#dialog_box'), - btnHolder = $('#dialog_buttons'), - dialogContent = $('#dialog_content'); + const box = $('#dialog_box'), + btnHolder = $('#dialog_buttons'), + dialogContent = $('#dialog_content'); /** * @typedef {PlainObject} module:jQueryPluginDBox.PromiseResultObject * @property {string|true} response @@ -5964,8 +5465,8 @@ function dbox(type, msg, defaultVal, opts, changeListener, checkbox) { dialogContent.html('

    ' + msg.replace(/\n/g, '

    ') + '

    ').toggleClass('prompt', type === 'prompt'); btnHolder.empty(); - var ok = $('').appendTo(btnHolder); - return new Promise(function (resolve, reject) { + const ok = $('').appendTo(btnHolder); + return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new if (type !== 'alert') { $('').appendTo(btnHolder).click(function () { @@ -5974,7 +5475,7 @@ }); } - var ctrl, chkbx; + let ctrl, chkbx; if (type === 'prompt') { ctrl = $('').prependTo(btnHolder); @@ -5983,11 +5484,11 @@ ok.click(); }); } else if (type === 'select') { - var div = $('
    '); - ctrl = $("`).appendTo(div); if (checkbox) { - var label = $('