From 926b48493a86ff037fdf7d9a41fcb7cd92e225ca Mon Sep 17 00:00:00 2001 From: Lauri Eskola <lauri.eskola@acquia.com> Date: Tue, 16 Nov 2021 10:20:33 +0200 Subject: [PATCH] Issue #3238860 by mstrelan, Theresa.Grannum, hooroomoo, bnjmnm, larowlan: Refactor (if feasible) use of jquery map to use vanillaJS --- core/.eslintrc.jquery.json | 2 +- core/misc/form.es6.js | 12 +++--------- core/misc/form.js | 5 ++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/.eslintrc.jquery.json b/core/.eslintrc.jquery.json index b1d27ef159c8..aa023ca34501 100644 --- a/core/.eslintrc.jquery.json +++ b/core/.eslintrc.jquery.json @@ -30,7 +30,7 @@ "jquery/no-is-function": 2, "jquery/no-is": 0, "jquery/no-load": 2, - "jquery/no-map": 0, + "jquery/no-map": 2, "jquery/no-merge": 2, "jquery/no-param": 2, "jquery/no-parent": 0, diff --git a/core/misc/form.es6.js b/core/misc/form.es6.js index ad02ee6dac41..6b2663b0bec9 100644 --- a/core/misc/form.es6.js +++ b/core/misc/form.es6.js @@ -157,15 +157,9 @@ * Array of IDs for form fields. */ function fieldsList(form) { - const $fieldList = $(form) - .find('[name]') - .map( - // We use id to avoid name duplicates on radio fields and filter out - // elements with a name but no id. - (index, element) => element.getAttribute('id'), - ); - // Return a true array. - return $.makeArray($fieldList); + // We use id to avoid name duplicates on radio fields and filter out + // elements with a name but no id. + return [].map.call(form.querySelectorAll('[name][id]'), (el) => el.id); } /** diff --git a/core/misc/form.js b/core/misc/form.js index bc6f0524b1d1..d85f85f14324 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -50,10 +50,9 @@ } function fieldsList(form) { - var $fieldList = $(form).find('[name]').map(function (index, element) { - return element.getAttribute('id'); + return [].map.call(form.querySelectorAll('[name][id]'), function (el) { + return el.id; }); - return $.makeArray($fieldList); } Drupal.behaviors.formUpdated = { -- GitLab