From cf52b419be2179a66e0254e692741e546b26503c Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 18 Oct 2017 17:15:08 +0100 Subject: [PATCH] Issue #2915534 by drpal, nod_: JS codestyle: prefer-rest-params --- core/.eslintrc.passing.json | 3 +-- core/misc/debounce.es6.js | 3 +-- core/misc/debounce.js | 5 ++++- core/misc/dialog/dialog.ajax.es6.js | 4 ++-- core/misc/dialog/dialog.ajax.js | 6 +++++- core/misc/drupal.es6.js | 5 ++--- core/misc/drupal.js | 9 +++++++-- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/core/.eslintrc.passing.json b/core/.eslintrc.passing.json index 05bd17608712..db5f24e49d9c 100644 --- a/core/.eslintrc.passing.json +++ b/core/.eslintrc.passing.json @@ -12,7 +12,6 @@ "new-cap": "off", "max-len": "off", "default-case": "off", - "camelcase": "off", - "prefer-rest-params": "off" + "camelcase": "off" } } diff --git a/core/misc/debounce.es6.js b/core/misc/debounce.es6.js index 56ba0db68160..e77940b9efa3 100644 --- a/core/misc/debounce.es6.js +++ b/core/misc/debounce.es6.js @@ -29,9 +29,8 @@ Drupal.debounce = function (func, wait, immediate) { let timeout; let result; - return function () { + return function (...args) { const context = this; - const args = arguments; const later = function () { timeout = null; if (!immediate) { diff --git a/core/misc/debounce.js b/core/misc/debounce.js index b6bb5d08c269..c2cfe9abe0e9 100644 --- a/core/misc/debounce.js +++ b/core/misc/debounce.js @@ -9,8 +9,11 @@ Drupal.debounce = function (func, wait, immediate) { var timeout = void 0; var result = void 0; return function () { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var context = this; - var args = arguments; var later = function later() { timeout = null; if (!immediate) { diff --git a/core/misc/dialog/dialog.ajax.es6.js b/core/misc/dialog/dialog.ajax.es6.js index 798673a1d86c..a6f2e71ce70e 100644 --- a/core/misc/dialog/dialog.ajax.es6.js +++ b/core/misc/dialog/dialog.ajax.es6.js @@ -42,8 +42,8 @@ const originalClose = settings.dialog.close; // Overwrite the close method to remove the dialog on closing. - settings.dialog.close = function (event) { - originalClose.apply(settings.dialog, arguments); + settings.dialog.close = function (event, ...args) { + originalClose.apply(settings.dialog, [event, ...args]); $(event.target).remove(); }; }, diff --git a/core/misc/dialog/dialog.ajax.js b/core/misc/dialog/dialog.ajax.js index 8277df3e51b2..de1d3c921977 100644 --- a/core/misc/dialog/dialog.ajax.js +++ b/core/misc/dialog/dialog.ajax.js @@ -26,7 +26,11 @@ var originalClose = settings.dialog.close; settings.dialog.close = function (event) { - originalClose.apply(settings.dialog, arguments); + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + originalClose.apply(settings.dialog, [event].concat(args)); $(event.target).remove(); }; }, diff --git a/core/misc/drupal.es6.js b/core/misc/drupal.es6.js index e64f9dac0dd1..43a78f9f71f9 100644 --- a/core/misc/drupal.es6.js +++ b/core/misc/drupal.es6.js @@ -559,10 +559,9 @@ window.Drupal = { behaviors: {}, locale: {} }; * Any data the theme function returns. This could be a plain HTML string, * but also a complex object. */ - Drupal.theme = function (func) { - const args = Array.prototype.slice.apply(arguments, [1]); + Drupal.theme = function (func, ...args) { if (func in Drupal.theme) { - return Drupal.theme[func].apply(this, args); + return Drupal.theme[func](...args); } }; diff --git a/core/misc/drupal.js b/core/misc/drupal.js index a00d8ce54835..0ede48da607b 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -181,9 +181,14 @@ window.Drupal = { behaviors: {}, locale: {} }; }; Drupal.theme = function (func) { - var args = Array.prototype.slice.apply(arguments, [1]); if (func in Drupal.theme) { - return Drupal.theme[func].apply(this, args); + var _Drupal$theme; + + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return (_Drupal$theme = Drupal.theme)[func].apply(_Drupal$theme, args); } }; -- GitLab