From 777d878dae42fc0719ab5e1f31005348653240a5 Mon Sep 17 00:00:00 2001 From: JFH Date: Tue, 28 Jul 2020 00:59:20 +0200 Subject: [PATCH] added back polyfills for older browsers --- .eslintrc.js | 53 ++++++++++++++++++++++++- src/common/layer.js | 4 +- src/editor/embedapi.js | 6 +-- src/editor/spinbtn/jQuery.SpinButton.js | 4 +- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d73c9f79..2d37e0b1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,57 @@ module.exports = { browser: true, es6: true }, + settings: { + polyfills: [ + // These are the primary polyfills needed by regular users if + // not present, e.g., with core-js-bundle; also those under + // extensions + // 'Array.isArray', + // 'Blob', + // 'console', + // 'CustomEvent', + // 'document.body', + // 'document.createElementNS', + // 'document.evaluate', + // 'document.head', + // 'document.importNode', + // 'document.querySelector', + // 'document.querySelectorAll', + // 'DOMParser', + // 'Error', + 'fetch', + // 'FileReader', + // 'JSON', + // 'KeyboardEvent', + // 'location.href', + // 'location.origin', + // 'MouseEvent', + // 'MutationObserver', + // 'navigator', + // 'Number.isNaN', + // 'Number.parseFloat', + // 'Number.parseInt', + // 'Object.assign', + // 'Object.defineProperty', + // 'Object.defineProperties', + // 'Object.entries', + // 'Object.getOwnPropertyDescriptor', + // 'Object.keys', + // 'Object.values', + 'Promise', + 'Promise.all', + // 'Set', + 'Uint8Array', + 'URL', + // 'URL.createObjectURL', + // 'XMLSerializer', + // 'XMLHttpRequest', + // 'window.getComputedStyle', + // 'window.parent', + // 'window.scrollX', + // 'window.scrollY' + ] + }, rules: { // check-examples is not picking up eslint config properly in some // environments; see also discussion above @@ -63,7 +114,7 @@ module.exports = { 'unicorn/no-zero-fractions': 'off', 'unicorn/prefer-number-properties': 'off', 'eslint-comments/require-description': 'off', - 'compat/compat': 'warn', + 'compat/compat': 'error', 'consistent-this': 'off', 'import/no-anonymous-default-export': 'off', 'node/no-unsupported-features/node-builtins': 'warn', diff --git a/src/common/layer.js b/src/common/layer.js index 8c814786..9cc31d79 100644 --- a/src/common/layer.js +++ b/src/common/layer.js @@ -17,9 +17,9 @@ const $ = jQuery; * an existing group element or, with three parameters, will create a new layer group element. * * @example - * const l1 = new Layer('name', group); // Use the existing group for this layer. + * const l1 = new Layer('name', group); // Use the existing group for this layer. * const l2 = new Layer('name', group, svgElem); // Create a new group and add it to the DOM after group. - * const l3 = new Layer('name', null, svgElem); // Create a new group and add it to the DOM as the last layer. + * const l3 = new Layer('name', null, svgElem); // Create a new group and add it to the DOM as the last layer. * @memberof module:layer */ class Layer { diff --git a/src/editor/embedapi.js b/src/editor/embedapi.js index b41a6e9b..c1b4bfe0 100644 --- a/src/editor/embedapi.js +++ b/src/editor/embedapi.js @@ -105,11 +105,11 @@ svgCanvas.setSvgString('string'); // Or if a callback is needed: svgCanvas.setSvgString('string')(function (data, error) { - if (error) { + if (error) { // There was an error - } else { + } else { // Handle data - } + } }); // Everything is done with the same API as the real svg-edit, diff --git a/src/editor/spinbtn/jQuery.SpinButton.js b/src/editor/spinbtn/jQuery.SpinButton.js index 6d556787..fb85de1e 100644 --- a/src/editor/spinbtn/jQuery.SpinButton.js +++ b/src/editor/spinbtn/jQuery.SpinButton.js @@ -65,8 +65,8 @@ }; $(function () { - // Initialise INPUT element(s) as SpinButtons: (passing options if desired) - $('#myInputElement').SpinButton(myOptions); + // Initialise INPUT element(s) as SpinButtons: (passing options if desired) + $('#myInputElement').SpinButton(myOptions); }); */ /**