diff --git a/core/.eslintrc.jquery.json b/core/.eslintrc.jquery.json index aa023ca34501c9c2a397a1d960dc42344494b561..6beae36d73bd7f0b8bc6031949dc41a8dd844dc7 100644 --- a/core/.eslintrc.jquery.json +++ b/core/.eslintrc.jquery.json @@ -49,7 +49,7 @@ "jquery/no-toggle": 0, "jquery/no-trigger": 0, "jquery/no-trim": 2, - "jquery/no-val": 0, + "jquery/no-val": 2, "jquery/no-when": 0, "jquery/no-wrap": 0 } diff --git a/core/core.libraries.yml b/core/core.libraries.yml index 2ddda9f2b8b164069d9758dd3a4e14fa88945cb1..664f6bd6c93528e1c1a7fc9c4d258cb9c61de4d3 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -311,6 +311,7 @@ drupal.ajax: - core/jquery - core/drupal - core/drupalSettings + - core/drupal.nodelist.foreach - core/drupal.progress - core/once - core/jquery.once.bc @@ -677,6 +678,7 @@ drupal.timezone: js: misc/timezone.js: {} dependencies: + - core/drupal.nodelist.foreach - core/jquery - core/once - core/jquery.once.bc diff --git a/core/misc/ajax.es6.js b/core/misc/ajax.es6.js index df7a0d5b0c6b64f49c07a97368f313743e0f02d8..94ff62df5da7db8901e0f91d31ff140e7d0090ec 100644 --- a/core/misc/ajax.es6.js +++ b/core/misc/ajax.es6.js @@ -1570,9 +1570,13 @@ * The XMLHttpRequest status. */ update_build_id(ajax, response, status) { - $(`input[name="form_build_id"][value="${response.old}"]`).val( - response.new, - ); + document + .querySelectorAll( + `input[name="form_build_id"][value="${response.old}"]`, + ) + .forEach((item) => { + item.value = response.new; + }); }, /** diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 043a892974c96dc153d328d2e7efd3bc843ebc2d..9ae188c3c67ab1799fa980a4431b75df7fd00a65 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -647,7 +647,9 @@ }, update_build_id(ajax, response, status) { - $(`input[name="form_build_id"][value="${response.old}"]`).val(response.new); + document.querySelectorAll(`input[name="form_build_id"][value="${response.old}"]`).forEach(item => { + item.value = response.new; + }); }, add_css(ajax, response, status) { diff --git a/core/misc/form.es6.js b/core/misc/form.es6.js index 6b2663b0bec93caa62990f7f2b666dec64a00408..c02220c099730865e276bdb441d904ca2ad1c036 100644 --- a/core/misc/form.es6.js +++ b/core/misc/form.es6.js @@ -245,11 +245,16 @@ userInfo.forEach((info) => { const $element = $forms.find(`[name=${info}]`); const browserData = localStorage.getItem(`Drupal.visitor.${info}`); - const emptyOrDefault = - $element.val() === '' || - $element.attr('data-drupal-default-value') === $element.val(); - if ($element.length && emptyOrDefault && browserData) { - $element.val(browserData); + if (!$element.length) { + return; + } + const emptyValue = $element[0].value === ''; + const defaultValue = + $element.attr('data-drupal-default-value') === $element[0].value; + if (browserData && (emptyValue || defaultValue)) { + $element.each(function (index, item) { + item.value = browserData; + }); } }); } @@ -257,7 +262,7 @@ userInfo.forEach((info) => { const $element = $forms.find(`[name=${info}]`); if ($element.length) { - localStorage.setItem(`Drupal.visitor.${info}`, $element.val()); + localStorage.setItem(`Drupal.visitor.${info}`, $element[0].value); } }); }); diff --git a/core/misc/form.js b/core/misc/form.js index c51425ea7533673d97b640bf595f88df36cedd37..ea5f8f50e600ee4038494160be0dc7009427e411 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -105,10 +105,18 @@ userInfo.forEach(info => { const $element = $forms.find(`[name=${info}]`); const browserData = localStorage.getItem(`Drupal.visitor.${info}`); - const emptyOrDefault = $element.val() === '' || $element.attr('data-drupal-default-value') === $element.val(); - if ($element.length && emptyOrDefault && browserData) { - $element.val(browserData); + if (!$element.length) { + return; + } + + const emptyValue = $element[0].value === ''; + const defaultValue = $element.attr('data-drupal-default-value') === $element[0].value; + + if (browserData && (emptyValue || defaultValue)) { + $element.each(function (index, item) { + item.value = browserData; + }); } }); } @@ -118,7 +126,7 @@ const $element = $forms.find(`[name=${info}]`); if ($element.length) { - localStorage.setItem(`Drupal.visitor.${info}`, $element.val()); + localStorage.setItem(`Drupal.visitor.${info}`, $element[0].value); } }); }); diff --git a/core/misc/machine-name.es6.js b/core/misc/machine-name.es6.js index a8f1f757242d24aea9d9f916d3f33305aa0e30ed..e890685ec5159b9cd9a2cbc8434cd54ea3e355b2 100644 --- a/core/misc/machine-name.es6.js +++ b/core/misc/machine-name.es6.js @@ -55,7 +55,7 @@ function machineNameHandler(e) { const data = e.data; const options = data.options; - const baseValue = $(e.target).val(); + const baseValue = e.target.value; const rx = new RegExp(options.replace_pattern, 'g'); const expected = baseValue @@ -119,7 +119,7 @@ // Hide the form item container of the machine name form element. $wrapper.addClass('visually-hidden'); // Initial machine name from the target field default value. - const machine = $target.val(); + const machine = $target[0].value; // Append the machine name preview to the source field. const $preview = $( `<span class="machine-name-value">${ @@ -150,8 +150,8 @@ // If no initial value, determine machine name based on the // human-readable form element value. - if (machine === '' && $source.val() !== '') { - self.transliterate($source.val(), options).done((machineName) => { + if (machine === '' && $source[0].value !== '') { + self.transliterate($source[0].value, options).done((machineName) => { self.showMachineName( machineName.substr(0, options.maxlength), eventData, @@ -170,7 +170,7 @@ // Preview the machine name in realtime when the human-readable name // changes, but only if there is no machine name yet; i.e., only upon // initial creation, not when editing. - if ($target.val() === '') { + if ($target[0].value === '') { $source .on('formUpdated.machineName', eventData, machineNameHandler) // Initialize machine name preview. @@ -188,7 +188,7 @@ // Set the machine name to the transliterated value. if (machine !== '') { if (machine !== settings.replace) { - data.$target.val(machine); + data.$target[0].value = machine; data.$preview.html( settings.field_prefix + Drupal.checkPlain(machine) + @@ -198,7 +198,7 @@ data.$suffix.show(); } else { data.$suffix.hide(); - data.$target.val(machine); + data.$target[0].value = machine; data.$preview.empty(); } }, diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index 6b74c3945107d4d752780a925eeef39554efe308..7281c4a3eda26e7b954fab84a998c29dfae10f11 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -24,7 +24,7 @@ function machineNameHandler(e) { const data = e.data; const options = data.options; - const baseValue = $(e.target).val(); + const baseValue = e.target.value; const rx = new RegExp(options.replace_pattern, 'g'); const expected = baseValue.toLowerCase().replace(rx, options.replace).substr(0, options.maxlength); @@ -66,7 +66,7 @@ options.maxlength = $target.attr('maxlength'); $wrapper.addClass('visually-hidden'); - const machine = $target.val(); + const machine = $target[0].value; const $preview = $(`<span class="machine-name-value">${options.field_prefix}${Drupal.checkPlain(machine)}${options.field_suffix}</span>`); $suffix.empty(); @@ -89,8 +89,8 @@ options }; - if (machine === '' && $source.val() !== '') { - self.transliterate($source.val(), options).done(machineName => { + if (machine === '' && $source[0].value !== '') { + self.transliterate($source[0].value, options).done(machineName => { self.showMachineName(machineName.substr(0, options.maxlength), eventData); }); } @@ -98,7 +98,7 @@ const $link = $(`<span class="admin-link"><button type="button" class="link">${Drupal.t('Edit')}</button></span>`).on('click', eventData, clickEditHandler); $suffix.append($link); - if ($target.val() === '') { + if ($target[0].value === '') { $source.on('formUpdated.machineName', eventData, machineNameHandler).trigger('formUpdated.machineName'); } @@ -111,14 +111,14 @@ if (machine !== '') { if (machine !== settings.replace) { - data.$target.val(machine); + data.$target[0].value = machine; data.$preview.html(settings.field_prefix + Drupal.checkPlain(machine) + settings.field_suffix); } data.$suffix.show(); } else { data.$suffix.hide(); - data.$target.val(machine); + data.$target[0].value = machine; data.$preview.empty(); } }, diff --git a/core/misc/tabledrag.es6.js b/core/misc/tabledrag.es6.js index fd6c1c30767920b2f4e71112935cc7a264320796..7830c043bf007be2548077fb9674dd89fdaa80dd 100644 --- a/core/misc/tabledrag.es6.js +++ b/core/misc/tabledrag.es6.js @@ -1137,8 +1137,11 @@ }); } else { // Assume a numeric input field. - let weight = - parseInt($(siblings[0]).find(targetClass).val(), 10) || 0; + let weight = 0; + const $siblingTarget = $(siblings[0]).find(targetClass); + if ($siblingTarget.length) { + weight = parseInt($siblingTarget[0].value, 10) || 0; + } $(siblings) .find(targetClass) .each(function () { diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js index 67d9a76ecb42c13b9c50207446c126c07d3f368a..b0782bbb34fca765a96dc23d8f86a520949f1fc7 100644 --- a/core/misc/tabledrag.js +++ b/core/misc/tabledrag.js @@ -653,7 +653,13 @@ } }); } else { - let weight = parseInt($(siblings[0]).find(targetClass).val(), 10) || 0; + let weight = 0; + const $siblingTarget = $(siblings[0]).find(targetClass); + + if ($siblingTarget.length) { + weight = parseInt($siblingTarget[0].value, 10) || 0; + } + $(siblings).find(targetClass).each(function () { this.value = weight; weight++; diff --git a/core/misc/timezone.es6.js b/core/misc/timezone.es6.js index e6d79c8829895a97ff39d5c4ee3b23f48f88b518..a8c1a5f7ac581ea5732ccceb0c356f814d5d3e06 100644 --- a/core/misc/timezone.es6.js +++ b/core/misc/timezone.es6.js @@ -13,12 +13,13 @@ attach(context, settings) { const timezone = once('timezone', '.timezone-detect', context); if (timezone.length) { - const $timezone = $(timezone); const tz = new Intl.DateTimeFormat().resolvedOptions().timeZone; // Ensure that the timezone value returned by the browser is supported // by the server. - if (tz && $timezone.find(`option[value="${tz}"]`).length) { - $timezone.val(tz); + if (tz && $(timezone).find(`option[value="${tz}"]`).length) { + timezone.forEach((item) => { + item.value = tz; + }); return; } @@ -71,7 +72,9 @@ dataType: 'json', success(data) { if (data) { - $timezone.val(data); + document.querySelectorAll('.timezone-detect').forEach((item) => { + item.value = data; + }); } }, }); diff --git a/core/misc/timezone.js b/core/misc/timezone.js index 5b36317c8dab5631fdf18acfe7e792ec5f1f68cd..053182bfbb4de7683f23cabd02f710e68304bd13 100644 --- a/core/misc/timezone.js +++ b/core/misc/timezone.js @@ -11,11 +11,12 @@ const timezone = once('timezone', '.timezone-detect', context); if (timezone.length) { - const $timezone = $(timezone); const tz = new Intl.DateTimeFormat().resolvedOptions().timeZone; - if (tz && $timezone.find(`option[value="${tz}"]`).length) { - $timezone.val(tz); + if (tz && $(timezone).find(`option[value="${tz}"]`).length) { + timezone.forEach(item => { + item.value = tz; + }); return; } @@ -49,7 +50,9 @@ success(data) { if (data) { - $timezone.val(data); + document.querySelectorAll('.timezone-detect').forEach(item => { + item.value = data; + }); } } diff --git a/core/misc/vertical-tabs.es6.js b/core/misc/vertical-tabs.es6.js index 5a55d880b21cea40c7a0f82c845823c24491fad4..2a66dd3182736b77b642848f5f202f25fbee13f8 100644 --- a/core/misc/vertical-tabs.es6.js +++ b/core/misc/vertical-tabs.es6.js @@ -64,7 +64,8 @@ once('vertical-tabs', '[data-vertical-tabs-panes]', context).forEach( (verticalTab) => { const $this = $(verticalTab).addClass('vertical-tabs__panes'); - const focusID = $this.find(':hidden.vertical-tabs__active-tab').val(); + const focusID = $this.find(':hidden.vertical-tabs__active-tab')[0] + .value; let tabFocus; // Check if there are some details that can be converted to @@ -180,8 +181,8 @@ }) .end() .show() - .siblings(':hidden.vertical-tabs__active-tab') - .val(this.details.attr('id')); + .siblings(':hidden.vertical-tabs__active-tab')[0].value = + this.details.attr('id'); this.item.addClass('is-selected'); // Mark the active tab for screen readers. $('#active-vertical-tab').remove(); diff --git a/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js index e727cfde985708f716788b239d02fd64724227d3..bfbe36fe0c9f39ea592dee2ffc765b171bb24d9c 100644 --- a/core/misc/vertical-tabs.js +++ b/core/misc/vertical-tabs.js @@ -24,7 +24,7 @@ $(once('vertical-tabs-fragments', 'body')).on('formFragmentLinkClickOrHashChange.verticalTabs', handleFragmentLinkClickOrHashChange); once('vertical-tabs', '[data-vertical-tabs-panes]', context).forEach(verticalTab => { const $this = $(verticalTab).addClass('vertical-tabs__panes'); - const focusID = $this.find(':hidden.vertical-tabs__active-tab').val(); + const focusID = $this.find(':hidden.vertical-tabs__active-tab')[0].value; let tabFocus; const $details = $this.find('> details'); @@ -94,7 +94,7 @@ const tab = $(this).data('verticalTab'); tab.details.hide(); tab.item.removeClass('is-selected'); - }).end().show().siblings(':hidden.vertical-tabs__active-tab').val(this.details.attr('id')); + }).end().show().siblings(':hidden.vertical-tabs__active-tab')[0].value = this.details.attr('id'); this.item.addClass('is-selected'); $('#active-vertical-tab').remove(); this.link.append(`<span id="active-vertical-tab" class="visually-hidden">${Drupal.t('(active tab)')}</span>`); diff --git a/core/modules/block/js/block.admin.es6.js b/core/modules/block/js/block.admin.es6.js index 360fcf41ff0285b72cf74b77464315b81e66b628..42d22546a56e6cf015c838af7fdbaa22fe60fc1a 100644 --- a/core/modules/block/js/block.admin.es6.js +++ b/core/modules/block/js/block.admin.es6.js @@ -33,7 +33,7 @@ * The jQuery event for the keyup event that triggered the filter. */ function filterBlockList(e) { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); /** * Shows or hides the block entry based on the query. diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 254c838806b7617f603240557a8b401d08581fae..7daee8c46470c2c26b66a4364b4857139f592f87 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -13,7 +13,7 @@ let $filterRows; function filterBlockList(e) { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); function toggleBlockEntry(index, label) { const $label = $(label); diff --git a/core/modules/block/js/block.es6.js b/core/modules/block/js/block.es6.js index eda67f8ac0478d2c9c9a43a26f6cfd0164d4f18c..a642ce363e6bc5299ea416ea2460d038ab9bbc78 100644 --- a/core/modules/block/js/block.es6.js +++ b/core/modules/block/js/block.es6.js @@ -55,7 +55,7 @@ const $pages = $(context).find( 'textarea[name="visibility[request_path][pages]"]', ); - if (!$pages.val()) { + if (!$pages.length || !$pages[0].value) { return Drupal.t('Not restricted'); } @@ -157,13 +157,13 @@ .find(`.region-${region}-message`) .nextUntil('.region-title') .find('select.block-weight') - .val( + .each(function () { // Increment the weight before assigning it to prevent using the // absolute minimum available weight. This way we always have an // unused upper and lower bound, which makes manually setting the // weights easier for users who prefer to do it that way. - () => ++weight, - ); + this.value = ++weight; + }); } const table = $('#blocks'); @@ -211,7 +211,7 @@ weightField .removeClass(`block-weight-${oldRegionName}`) .addClass(`block-weight-${regionName}`); - regionField.val(regionName); + regionField[0].value = regionName; } updateBlockWeights(table, regionName); diff --git a/core/modules/block/js/block.js b/core/modules/block/js/block.js index eac0fde0e596f7aa43af3488413778d7895b0783..0b02179de94521de689b32d0c916f8ab9d52779c 100644 --- a/core/modules/block/js/block.js +++ b/core/modules/block/js/block.js @@ -32,7 +32,7 @@ $('[data-drupal-selector="edit-visibility-request-path"]').drupalSetSummary(context => { const $pages = $(context).find('textarea[name="visibility[request_path][pages]"]'); - if (!$pages.val()) { + if (!$pages.length || !$pages[0].value) { return Drupal.t('Not restricted'); } @@ -77,7 +77,9 @@ function updateBlockWeights(table, region) { let weight = -Math.round(table.find('.draggable').length / 2); - table.find(`.region-${region}-message`).nextUntil('.region-title').find('select.block-weight').val(() => ++weight); + table.find(`.region-${region}-message`).nextUntil('.region-title').find('select.block-weight').each(function () { + this.value = ++weight; + }); } const table = $('#blocks'); @@ -105,7 +107,7 @@ const oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2'); regionField.removeClass(`block-region-${oldRegionName}`).addClass(`block-region-${regionName}`); weightField.removeClass(`block-weight-${oldRegionName}`).addClass(`block-weight-${regionName}`); - regionField.val(regionName); + regionField[0].value = regionName; } updateBlockWeights(table, regionName); diff --git a/core/modules/book/book.es6.js b/core/modules/book/book.es6.js index 6192834d04fbf162b89fb1d723a187e1b1d92fa9..c102a5be05c1b0994ef2af5031b1a2cd0d1e8712 100644 --- a/core/modules/book/book.es6.js +++ b/core/modules/book/book.es6.js @@ -18,7 +18,7 @@ .find('.book-outline-form') .drupalSetSummary((context) => { const $select = $(context).find('.book-title-select'); - const val = $select.val(); + const val = $select[0].value; if (val === '0') { return Drupal.t('Not in book'); diff --git a/core/modules/book/book.js b/core/modules/book/book.js index 7e4dfce37227c7817c2022e0dea01aa29c419c4f..243e028a835a5fbf36ba1d8cb8b5d92c31080784 100644 --- a/core/modules/book/book.js +++ b/core/modules/book/book.js @@ -10,7 +10,7 @@ attach(context) { $(context).find('.book-outline-form').drupalSetSummary(context => { const $select = $(context).find('.book-title-select'); - const val = $select.val(); + const val = $select[0].value; if (val === '0') { return Drupal.t('Not in book'); diff --git a/core/modules/ckeditor/js/ckeditor.admin.es6.js b/core/modules/ckeditor/js/ckeditor.admin.es6.js index 5390e81f14bdfe1a737a6f8426a1579bfd9e5d79..24dbf45469bd18e08a7a48f9c33494e1ad972224 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.es6.js +++ b/core/modules/ckeditor/js/ckeditor.admin.es6.js @@ -41,7 +41,7 @@ // Create a configuration model. Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({ $textarea, - activeEditorConfig: JSON.parse($textarea.val()), + activeEditorConfig: JSON.parse($textarea[0].value), hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig, }); diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js index dd716834deeef672a748e1347adbb85c69e1ef0d..ae8d0011814fdb8eb0d1820a700f6e5c65c66c85 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.js +++ b/core/modules/ckeditor/js/ckeditor.admin.js @@ -17,7 +17,7 @@ $configurationForm.append(drupalSettings.ckeditor.toolbarAdmin); Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({ $textarea, - activeEditorConfig: JSON.parse($textarea.val()), + activeEditorConfig: JSON.parse($textarea[0].value), hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig }); const viewDefaults = { diff --git a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.es6.js b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.es6.js index 88980358c5b9cdac34b831d0fc284aaecf0cbe7f..f473b957487f84fde638a7fd7725a9e4b14d2c03 100644 --- a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.es6.js +++ b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.es6.js @@ -19,17 +19,23 @@ const root = 'input[name="editor[settings][plugins][drupalimage][image_upload]'; const $status = $(`${root}[status]"]`); - const $maxFileSize = $(`${root}[max_size]"]`); - const $maxWidth = $(`${root}[max_dimensions][width]"]`); - const $maxHeight = $(`${root}[max_dimensions][height]"]`); + const maxFileSizeElement = document.querySelector( + `${root}[max_size]"]`, + ); + const maxWidth = document.querySelector( + `${root}[max_dimensions][width]"]`, + ); + const maxHeight = document.querySelector( + `${root}[max_dimensions][height]"]`, + ); const $scheme = $(`${root}[scheme]"]:checked`); - const maxFileSize = $maxFileSize.val() - ? $maxFileSize.val() - : $maxFileSize.attr('placeholder'); + const maxFileSize = maxFileSizeElement.value + ? maxFileSizeElement.value + : maxFileSizeElement.getAttribute('placeholder'); const maxDimensions = - $maxWidth.val() && $maxHeight.val() - ? `(${$maxWidth.val()}x${$maxHeight.val()})` + maxWidth.value && maxHeight.value + ? `(${maxWidth.value}x${maxHeight.value})` : ''; if (!$status.is(':checked')) { diff --git a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js index 8d91c56718a339a0693104635656677502747f13..56ba642f553845e294a0111d5d46bb70fea099ca 100644 --- a/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js +++ b/core/modules/ckeditor/js/ckeditor.drupalimage.admin.js @@ -11,12 +11,12 @@ $('[data-ckeditor-plugin-id="drupalimage"]').drupalSetSummary(context => { const root = 'input[name="editor[settings][plugins][drupalimage][image_upload]'; const $status = $(`${root}[status]"]`); - const $maxFileSize = $(`${root}[max_size]"]`); - const $maxWidth = $(`${root}[max_dimensions][width]"]`); - const $maxHeight = $(`${root}[max_dimensions][height]"]`); + const maxFileSizeElement = document.querySelector(`${root}[max_size]"]`); + const maxWidth = document.querySelector(`${root}[max_dimensions][width]"]`); + const maxHeight = document.querySelector(`${root}[max_dimensions][height]"]`); const $scheme = $(`${root}[scheme]"]:checked`); - const maxFileSize = $maxFileSize.val() ? $maxFileSize.val() : $maxFileSize.attr('placeholder'); - const maxDimensions = $maxWidth.val() && $maxHeight.val() ? `(${$maxWidth.val()}x${$maxHeight.val()})` : ''; + const maxFileSize = maxFileSizeElement.value ? maxFileSizeElement.value : maxFileSizeElement.getAttribute('placeholder'); + const maxDimensions = maxWidth.value && maxHeight.value ? `(${maxWidth.value}x${maxHeight.value})` : ''; if (!$status.is(':checked')) { return Drupal.t('Uploads disabled'); diff --git a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.es6.js b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.es6.js index 26a377bbc1d6335aae0c81a981ef0661b92ed64f..6717a65433ea7d702d2ba131fb0f3fba7850e327 100644 --- a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.es6.js +++ b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.es6.js @@ -36,7 +36,7 @@ $context .find('[name="editor[settings][plugins][stylescombo][styles]"]') .on('blur.ckeditorStylesComboSettings', function () { - const styles = $(this).val().trim(); + const styles = this.value.trim(); const stylesSet = that._generateStylesSetSetting(styles); if (!_.isEqual(previousStylesSet, stylesSet)) { previousStylesSet = stylesSet; @@ -116,11 +116,11 @@ attach() { $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary( (context) => { - const styles = $( + const stylesElement = document.querySelector( '[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]', - ) - .val() - .trim(); + ); + const styles = stylesElement ? stylesElement.value.trim() : ''; + if (styles.length === 0) { return Drupal.t('No styles configured'); } diff --git a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js index dd8165091c0bbfe586d1570bc94130c30767d5fb..bd51791e1b959e9b5bd03c22ad46ea2fab6522dd 100644 --- a/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js +++ b/core/modules/ckeditor/js/ckeditor.stylescombo.admin.js @@ -13,7 +13,7 @@ let previousStylesSet = drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet; const that = this; $context.find('[name="editor[settings][plugins][stylescombo][styles]"]').on('blur.ckeditorStylesComboSettings', function () { - const styles = $(this).val().trim(); + const styles = this.value.trim(); const stylesSet = that._generateStylesSetSetting(styles); @@ -63,7 +63,8 @@ Drupal.behaviors.ckeditorStylesComboSettingsSummary = { attach() { $('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary(context => { - const styles = $('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]').val().trim(); + const stylesElement = document.querySelector('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]'); + const styles = stylesElement ? stylesElement.value.trim() : ''; if (styles.length === 0) { return Drupal.t('No styles configured'); diff --git a/core/modules/color/color.es6.js b/core/modules/color/color.es6.js index 6cde1cf443010038df3a1ac9d29a2f79dab44bff..b0c766aea2d6a4b155ef559ab18d7b84547f3ce5 100644 --- a/core/modules/color/color.es6.js +++ b/core/modules/color/color.es6.js @@ -139,8 +139,8 @@ }); // Change input value. - if ($(input).val() && $(input).val() !== color) { - $(input).val(color); + if (input.value && input.value !== color) { + input.value = color; // Update locked values. if (propagate) { diff --git a/core/modules/color/color.js b/core/modules/color/color.js index 90050867efc678c0b2c0369ebf8fb303c7a9df36..cb1ce2535d69d5931b8a91fef1c4965080761d8a 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -79,8 +79,8 @@ color: farb.RGBToHSL(farb.unpack(color))[2] > 0.5 ? '#000' : '#fff' }); - if ($(input).val() && $(input).val() !== color) { - $(input).val(color); + if (input.value && input.value !== color) { + input.value = color; if (propagate) { i = input.i; diff --git a/core/modules/content_translation/content_translation.admin.es6.js b/core/modules/content_translation/content_translation.admin.es6.js index 1360ca33474e240eef8ce32fd24d611c7d8d065c..d74009ec315b6866acfb3d9b947986c8f1ce4d08 100644 --- a/core/modules/content_translation/content_translation.admin.es6.js +++ b/core/modules/content_translation/content_translation.admin.es6.js @@ -49,7 +49,7 @@ let column; function filterFieldsList(index, field) { - return $(field).val() === column; + return field.value === column; } // A field that has many different translatable parts can also define one diff --git a/core/modules/content_translation/content_translation.admin.js b/core/modules/content_translation/content_translation.admin.js index d27a7d6ded686c4f721fc5ab9093aec391311d19..768394bcd447f63d691b41eef7986777fc03d06e 100644 --- a/core/modules/content_translation/content_translation.admin.js +++ b/core/modules/content_translation/content_translation.admin.js @@ -33,7 +33,7 @@ let column; function filterFieldsList(index, field) { - return $(field).val() === column; + return field.value === column; } Object.keys(dependentColumns || {}).forEach(index => { diff --git a/core/modules/editor/js/editor.es6.js b/core/modules/editor/js/editor.es6.js index b6deb24b62fd9d71aeec5114a7694a5a4eee5333..ccff56bbd4440e5ce6dd7cda845e72fbb95b4492 100644 --- a/core/modules/editor/js/editor.es6.js +++ b/core/modules/editor/js/editor.es6.js @@ -109,10 +109,10 @@ * The text format change event. */ function onTextFormatChange(event) { - const $select = $(event.target); + const select = event.target; const field = event.data.field; const activeFormatID = field.getAttribute('data-editor-active-text-format'); - const newFormatID = $select.val(); + const newFormatID = select.value; // Prevent double-attaching if the change event is triggered manually. if (newFormatID === activeFormatID) { @@ -132,7 +132,7 @@ const message = Drupal.t( 'Changing the text format to %text_format will permanently remove content that is not allowed in that text format.<br><br>Save your changes before switching the text format to avoid losing data.', { - '%text_format': $select.find('option:selected').text(), + '%text_format': $(select).find('option:selected').text(), }, ); const confirmationDialog = Drupal.dialog(`<div>${message}</div>`, { @@ -156,7 +156,7 @@ // cannot simply call event.preventDefault() because jQuery's // change event is only triggered after the change has already // been accepted. - $select.val(activeFormatID); + select.value = activeFormatID; confirmationDialog.close(); }, }, @@ -214,7 +214,7 @@ } // Store the current active format. - const activeFormatID = $this.val(); + const activeFormatID = editor.value; field.setAttribute('data-editor-active-text-format', activeFormatID); // Directly attach this text editor, if the text format is enabled. @@ -268,7 +268,7 @@ editors.forEach((editor) => { const $this = $(editor); - const activeFormatID = $this.val(); + const activeFormatID = editor.value; const field = findFieldForFormatSelector($this); if (field && activeFormatID in settings.editor.formats) { Drupal.editorDetach( diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index c819efcd70ea434e49b44f8d0c9d3b9147567977..ed78718583038a2497bc642c939bb3f2c3185998 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -54,10 +54,10 @@ } function onTextFormatChange(event) { - const $select = $(event.target); + const select = event.target; const field = event.data.field; const activeFormatID = field.getAttribute('data-editor-active-text-format'); - const newFormatID = $select.val(); + const newFormatID = select.value; if (newFormatID === activeFormatID) { return; @@ -68,7 +68,7 @@ if (hasContent && supportContentFiltering) { const message = Drupal.t('Changing the text format to %text_format will permanently remove content that is not allowed in that text format.<br><br>Save your changes before switching the text format to avoid losing data.', { - '%text_format': $select.find('option:selected').text() + '%text_format': $(select).find('option:selected').text() }); const confirmationDialog = Drupal.dialog(`<div>${message}</div>`, { title: Drupal.t('Change text format?'), @@ -88,7 +88,7 @@ class: 'button', click() { - $select.val(activeFormatID); + select.value = activeFormatID; confirmationDialog.close(); } @@ -127,7 +127,7 @@ return; } - const activeFormatID = $this.val(); + const activeFormatID = editor.value; field.setAttribute('data-editor-active-text-format', activeFormatID); if (settings.editor.formats[activeFormatID]) { @@ -168,7 +168,7 @@ editors.forEach(editor => { const $this = $(editor); - const activeFormatID = $this.val(); + const activeFormatID = editor.value; const field = findFieldForFormatSelector($this); if (field && activeFormatID in settings.editor.formats) { diff --git a/core/modules/field_ui/field_ui.es6.js b/core/modules/field_ui/field_ui.es6.js index 4779b5f86287375bcea231e0dbd5fff7e048457a..950df384ca7cdaae2dcc86780002c3a480f5f1a0 100644 --- a/core/modules/field_ui/field_ui.es6.js +++ b/core/modules/field_ui/field_ui.es6.js @@ -43,27 +43,32 @@ // When the user selects a new field type, clear the "existing field" // selection. $newFieldType.on('change', function () { - if ($(this).val() !== '') { + if (this.value !== '') { // Reset the "existing storage name" selection. - $existingStorageName.val('').trigger('change'); + if ($existingStorageName.length) { + $existingStorageName[0].value = ''; + $existingStorageName.trigger('change'); + } } }); // When the user selects an existing storage name, clear the "new field // type" selection and populate the 'existing_storage_label' element. $existingStorageName.on('change', function () { - const value = $(this).val(); + const { value } = this; if (value !== '') { - // Reset the "new field type" selection. - $newFieldType.val('').trigger('change'); + if ($newFieldType.length) { + // Reset the "new field type" selection. + $newFieldType[0].value = ''; + $newFieldType.trigger('change'); + } // Pre-populate the "existing storage label" element. if ( typeof drupalSettings.existingFieldLabels[value] !== 'undefined' ) { - $existingStorageLabel.val( - drupalSettings.existingFieldLabels[value], - ); + $existingStorageLabel[0].value = + drupalSettings.existingFieldLabels[value]; } } }); @@ -152,8 +157,11 @@ // Handle region change. const region = rowHandler.getRegion(); if (region !== rowHandler.region) { - // Remove parenting. - $row.find('select.js-field-parent').val(''); + const $fieldParent = $row.find('select.js-field-parent'); + if ($fieldParent.length) { + // Remove parenting. + $fieldParent[0].value = ''; + } // Let the row handler deal with the region change. $.extend(refreshRows, rowHandler.regionChange(region)); // Update the row region. @@ -258,9 +266,11 @@ if (rowNames.length) { // Add a throbber next each of the ajaxElements. $(ajaxElements).after(Drupal.theme.ajaxProgressThrobber()); - - // Fire the Ajax update. - $('input[name=refresh_rows]').val(rowNames.join(' ')); + const $refreshRows = $('input[name=refresh_rows]'); + if ($refreshRows.length) { + // Fire the Ajax update. + $refreshRows[0].value = rowNames.join(' '); + } $('input[data-drupal-selector="edit-refresh"]').trigger('mousedown'); // Disabled elements do not appear in POST ajax data, so we mark the @@ -318,7 +328,9 @@ * Either 'hidden' or 'content'. */ getRegion() { - return this.$regionSelect.val(); + if (this.$regionSelect.length) { + return this.$regionSelect[0].value; + } }, /** @@ -344,8 +356,10 @@ // Replace dashes with underscores. region = region.replace(/-/g, '_'); - // Set the region of the select list. - this.$regionSelect.val(region); + if (this.$regionSelect.length) { + // Set the region of the select list. + this.$regionSelect[0].value = region; + } // Restore the formatter back to the default formatter only if it was // disabled previously. Pseudo-fields do not have default formatters, @@ -354,10 +368,12 @@ const value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin - : this.$pluginSelect.find('option').val(); + : this.$pluginSelect.find('option')[0].value; if (typeof value !== 'undefined') { - this.$pluginSelect.val(value); + if (this.$pluginSelect.length) { + this.$pluginSelect[0].value = value; + } } } diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js index 76fdabc27e6fe00d5c4d164e81af00200a79ab74..f90a0ff64fd2213616fe3251d05d40468d964dfc 100644 --- a/core/modules/field_ui/field_ui.js +++ b/core/modules/field_ui/field_ui.js @@ -17,18 +17,26 @@ const $existingStorageName = $form.find('select[name="existing_storage_name"]'); const $existingStorageLabel = $form.find('input[name="existing_storage_label"]'); $newFieldType.on('change', function () { - if ($(this).val() !== '') { - $existingStorageName.val('').trigger('change'); + if (this.value !== '') { + if ($existingStorageName.length) { + $existingStorageName[0].value = ''; + $existingStorageName.trigger('change'); + } } }); $existingStorageName.on('change', function () { - const value = $(this).val(); + const { + value + } = this; if (value !== '') { - $newFieldType.val('').trigger('change'); + if ($newFieldType.length) { + $newFieldType[0].value = ''; + $newFieldType.trigger('change'); + } if (typeof drupalSettings.existingFieldLabels[value] !== 'undefined') { - $existingStorageLabel.val(drupalSettings.existingFieldLabels[value]); + $existingStorageLabel[0].value = drupalSettings.existingFieldLabels[value]; } } }); @@ -70,7 +78,12 @@ const region = rowHandler.getRegion(); if (region !== rowHandler.region) { - $row.find('select.js-field-parent').val(''); + const $fieldParent = $row.find('select.js-field-parent'); + + if ($fieldParent.length) { + $fieldParent[0].value = ''; + } + $.extend(refreshRows, rowHandler.regionChange(region)); rowHandler.region = region; } @@ -125,7 +138,12 @@ if (rowNames.length) { $(ajaxElements).after(Drupal.theme.ajaxProgressThrobber()); - $('input[name=refresh_rows]').val(rowNames.join(' ')); + const $refreshRows = $('input[name=refresh_rows]'); + + if ($refreshRows.length) { + $refreshRows[0].value = rowNames.join(' '); + } + $('input[data-drupal-selector="edit-refresh"]').trigger('mousedown'); $(ajaxElements).prop('disabled', true); } @@ -149,18 +167,25 @@ Drupal.fieldUIDisplayOverview.field.prototype = { getRegion() { - return this.$regionSelect.val(); + if (this.$regionSelect.length) { + return this.$regionSelect[0].value; + } }, regionChange(region) { region = region.replace(/-/g, '_'); - this.$regionSelect.val(region); + + if (this.$regionSelect.length) { + this.$regionSelect[0].value = region; + } if (this.region === 'hidden') { - const value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin : this.$pluginSelect.find('option').val(); + const value = typeof this.defaultPlugin !== 'undefined' ? this.defaultPlugin : this.$pluginSelect.find('option')[0].value; if (typeof value !== 'undefined') { - this.$pluginSelect.val(value); + if (this.$pluginSelect.length) { + this.$pluginSelect[0].value = value; + } } } diff --git a/core/modules/filter/filter.es6.js b/core/modules/filter/filter.es6.js index 58b7232cee29a7cc91954ffbc9345bd8261e4447..733dc93f3c9c632acc7e2d4e17410b4bb87324e5 100644 --- a/core/modules/filter/filter.es6.js +++ b/core/modules/filter/filter.es6.js @@ -16,7 +16,7 @@ attach(context) { function updateFilterGuidelines(event) { const $this = $(event.target); - const value = $this.val(); + const { value } = event.target; $this .closest('.js-filter-wrapper') .find('[data-drupal-format-id]') diff --git a/core/modules/filter/filter.filter_html.admin.es6.js b/core/modules/filter/filter.filter_html.admin.es6.js index 05cb0508c27027e8739ef968cc2751ecd5c78c87..599d061b9f6fd124d5fa4f23a617ffcd0c64fd40 100644 --- a/core/modules/filter/filter.filter_html.admin.es6.js +++ b/core/modules/filter/filter.filter_html.admin.es6.js @@ -17,9 +17,9 @@ * An array of filter rules. */ getRules() { - const currentValue = $( + const currentValue = document.querySelector( '#edit-filters-filter-html-settings-allowed-html', - ).val(); + ).value; const rules = Drupal.behaviors.filterFilterHtmlUpdating._parseSetting(currentValue); diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js index eef5514052e3c8fa30cb41a653617c2455acb3a6..0f2f08a4263d0072ff0d49d39b4acb512ea861fe 100644 --- a/core/modules/filter/filter.filter_html.admin.js +++ b/core/modules/filter/filter.filter_html.admin.js @@ -9,7 +9,7 @@ if (Drupal.filterConfiguration) { Drupal.filterConfiguration.liveSettingParsers.filter_html = { getRules() { - const currentValue = $('#edit-filters-filter-html-settings-allowed-html').val(); + const currentValue = document.querySelector('#edit-filters-filter-html-settings-allowed-html').value; const rules = Drupal.behaviors.filterFilterHtmlUpdating._parseSetting(currentValue); diff --git a/core/modules/filter/filter.js b/core/modules/filter/filter.js index de9391b207a74b1dee7ef48203c2501c769941d9..529f59ff60f8708cb4edc1a1d23e0e72ab7ccb51 100644 --- a/core/modules/filter/filter.js +++ b/core/modules/filter/filter.js @@ -10,7 +10,9 @@ attach(context) { function updateFilterGuidelines(event) { const $this = $(event.target); - const value = $this.val(); + const { + value + } = event.target; $this.closest('.js-filter-wrapper').find('[data-drupal-format-id]').hide().filter(`[data-drupal-format-id="${value}"]`).show(); } diff --git a/core/modules/image/js/editors/image.es6.js b/core/modules/image/js/editors/image.es6.js index 1710335995e356f2aebdc48fa3b3f5ea3aa82540..30a54f51b821edfc599a7c4b44b9b1cea6511cbf 100644 --- a/core/modules/image/js/editors/image.es6.js +++ b/core/modules/image/js/editors/image.es6.js @@ -18,8 +18,7 @@ Drupal.quickedit.EditorView.prototype.initialize.call(this, options); // Set our original value to our current HTML (for reverting). this.model.set('originalValue', this.$el.html().trim()); - // $.val() callback function for copying input from our custom form to - // the Quick Edit Field Form. + // Copy input from our custom form to the Quick Edit Field Form. this.model.set('currentValue', function (index, value) { const matches = $(this) .attr('name') @@ -33,7 +32,7 @@ `.quickedit-image-field-info input[name="${name}"]`, ); if ($input.length) { - return $input.val(); + return $input[0].value; } } }); diff --git a/core/modules/image/js/editors/image.js b/core/modules/image/js/editors/image.js index c6a5126384e2dc15c49fee314292eb4547941e7c..8845cf76b13277dfc36e4ef3b18776f83eb91b1e 100644 --- a/core/modules/image/js/editors/image.js +++ b/core/modules/image/js/editors/image.js @@ -19,7 +19,7 @@ const $input = $toolgroup.find(`.quickedit-image-field-info input[name="${name}"]`); if ($input.length) { - return $input.val(); + return $input[0].value; } } }); diff --git a/core/modules/layout_builder/js/layout-builder.es6.js b/core/modules/layout_builder/js/layout-builder.es6.js index 149d2bd53a9055c6b59390a323b4befb8e57d544..77ab574b0466c74346f574d0653264bd0bc32124 100644 --- a/core/modules/layout_builder/js/layout-builder.es6.js +++ b/core/modules/layout_builder/js/layout-builder.es6.js @@ -32,7 +32,7 @@ * The jQuery event for the keyup event that triggered the filter. */ const filterBlockList = (e) => { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); /** * Shows or hides the block entry based on the query. diff --git a/core/modules/layout_builder/js/layout-builder.js b/core/modules/layout_builder/js/layout-builder.js index be5a820c093143bff1cfa78246f69646975430af..79997c2becae8e8feed7ba6b58773a64be20c283 100644 --- a/core/modules/layout_builder/js/layout-builder.js +++ b/core/modules/layout_builder/js/layout-builder.js @@ -20,7 +20,7 @@ const $filterLinks = $categories.find('.js-layout-builder-block-link'); const filterBlockList = e => { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); const toggleBlockEntry = (index, link) => { const $link = $(link); diff --git a/core/modules/locale/locale.bulk.es6.js b/core/modules/locale/locale.bulk.es6.js index 7066baee50bf215344d234f2aa59ebbed6189bf7..1b7d0ff2e5560f205e7045785dd34e1e736afca1 100644 --- a/core/modules/locale/locale.bulk.es6.js +++ b/core/modules/locale/locale.bulk.es6.js @@ -23,14 +23,12 @@ $form.find('.file-import-input').on('change', function () { // If the filename is fully the language code or the filename // ends with a language code, pre-select that one. - const matches = $(this) - .val() - .match(/([^.][.]*)([\w-]+)\.po$/); + const matches = this.value.match(/([^.][.]*)([\w-]+)\.po$/); if ( matches && $langcode.find(`option[value="${matches[2]}"]`).length ) { - $langcode.val(matches[2]); + $langcode[0].value = matches[2]; } }); } diff --git a/core/modules/locale/locale.bulk.js b/core/modules/locale/locale.bulk.js index 9ee0feb957a0bd3cb3389e540dc33a425626eea4..5d6c08f950540231a9481f6ff7a8b05315bad028 100644 --- a/core/modules/locale/locale.bulk.js +++ b/core/modules/locale/locale.bulk.js @@ -14,10 +14,10 @@ const $form = $(form); const $langcode = $form.find('.langcode-input'); $form.find('.file-import-input').on('change', function () { - const matches = $(this).val().match(/([^.][.]*)([\w-]+)\.po$/); + const matches = this.value.match(/([^.][.]*)([\w-]+)\.po$/); if (matches && $langcode.find(`option[value="${matches[2]}"]`).length) { - $langcode.val(matches[2]); + $langcode[0].value = matches[2]; } }); } diff --git a/core/modules/media/js/form.es6.js b/core/modules/media/js/form.es6.js index 0d17267a60aed329723149953f09a9b1b37cf719..e7ac049cb87e5a15184086ade1de85d9c2a1b42e 100644 --- a/core/modules/media/js/form.es6.js +++ b/core/modules/media/js/form.es6.js @@ -14,26 +14,27 @@ */ Drupal.behaviors.mediaFormSummaries = { attach(context) { - const $context = $(context); + $(context) + .find('.media-form-author') + .drupalSetSummary((context) => { + const nameInput = context.querySelector('.field--name-uid input'); + const name = nameInput && nameInput.value; + const dateInput = context.querySelector('.field--name-created input'); + const date = dateInput && dateInput.value; - $context.find('.media-form-author').drupalSetSummary((context) => { - const $authorContext = $(context); - const name = $authorContext.find('.field--name-uid input').val(); - const date = $authorContext.find('.field--name-created input').val(); - - if (name && date) { - return Drupal.t('By @name on @date', { - '@name': name, - '@date': date, - }); - } - if (name) { - return Drupal.t('By @name', { '@name': name }); - } - if (date) { - return Drupal.t('Authored on @date', { '@date': date }); - } - }); + if (name && date) { + return Drupal.t('By @name on @date', { + '@name': name, + '@date': date, + }); + } + if (name) { + return Drupal.t('By @name', { '@name': name }); + } + if (date) { + return Drupal.t('Authored on @date', { '@date': date }); + } + }); }, }; })(jQuery, Drupal); diff --git a/core/modules/media/js/form.js b/core/modules/media/js/form.js index 970e2eafe562dcb09491a3fd8fa01ad344f41656..397769fb0253826fa71645fefc2805ef5be56765 100644 --- a/core/modules/media/js/form.js +++ b/core/modules/media/js/form.js @@ -8,11 +8,11 @@ (function ($, Drupal) { Drupal.behaviors.mediaFormSummaries = { attach(context) { - const $context = $(context); - $context.find('.media-form-author').drupalSetSummary(context => { - const $authorContext = $(context); - const name = $authorContext.find('.field--name-uid input').val(); - const date = $authorContext.find('.field--name-created input').val(); + $(context).find('.media-form-author').drupalSetSummary(context => { + const nameInput = context.querySelector('.field--name-uid input'); + const name = nameInput && nameInput.value; + const dateInput = context.querySelector('.field--name-created input'); + const date = dateInput && dateInput.value; if (name && date) { return Drupal.t('By @name on @date', { diff --git a/core/modules/media_library/js/media_library.ui.es6.js b/core/modules/media_library/js/media_library.ui.es6.js index d6a7303983647a6b987f6c3060f6205c93305043..95bc01ac3fe51236569a605eaf99a9727533c6c1 100644 --- a/core/modules/media_library/js/media_library.ui.es6.js +++ b/core/modules/media_library/js/media_library.ui.es6.js @@ -342,18 +342,24 @@ currentSelection.splice(position, 1); } - // Set the selection in the hidden form element. - $form - .find('#media-library-modal-selection') - .val(currentSelection.join()) - .trigger('change'); + const mediaLibraryModalSelection = document.querySelector( + '#media-library-modal-selection', + ); + + if (mediaLibraryModalSelection) { + // Set the selection in the hidden form element. + mediaLibraryModalSelection.value = currentSelection.join(); + $(mediaLibraryModalSelection).trigger('change'); + } // Set the selection in the media library add form. Since the form is // not necessarily loaded within the same context, we can't use the // context here. - $('.js-media-library-add-form-current-selection').val( - currentSelection.join(), - ); + document + .querySelectorAll('.js-media-library-add-form-current-selection') + .forEach((item) => { + item.value = currentSelection.join(); + }); }); // The hidden selection form field changes when the selection is updated. diff --git a/core/modules/media_library/js/media_library.ui.js b/core/modules/media_library/js/media_library.ui.js index 64a479edc7790fe5d542bf2c517f1c3b97dad0da..afbe1a662d47679fdfb04224a134af75d7c4dadd 100644 --- a/core/modules/media_library/js/media_library.ui.js +++ b/core/modules/media_library/js/media_library.ui.js @@ -176,8 +176,16 @@ currentSelection.splice(position, 1); } - $form.find('#media-library-modal-selection').val(currentSelection.join()).trigger('change'); - $('.js-media-library-add-form-current-selection').val(currentSelection.join()); + const mediaLibraryModalSelection = document.querySelector('#media-library-modal-selection'); + + if (mediaLibraryModalSelection) { + mediaLibraryModalSelection.value = currentSelection.join(); + $(mediaLibraryModalSelection).trigger('change'); + } + + document.querySelectorAll('.js-media-library-add-form-current-selection').forEach(item => { + item.value = currentSelection.join(); + }); }); $(once('media-library-selection-change', $form.find('#media-library-modal-selection'))).on('change', e => { updateSelectionCount(settings.media_library.selection_remaining); diff --git a/core/modules/media_library/js/media_library.widget.es6.js b/core/modules/media_library/js/media_library.widget.es6.js index 88ad11fbc71788f174a2d99d0ec1439895d16920..9c517fe870a30174f269e12a63d649683ccd9d49 100644 --- a/core/modules/media_library/js/media_library.widget.es6.js +++ b/core/modules/media_library/js/media_library.widget.es6.js @@ -22,7 +22,7 @@ $(widget) .children() .each((index, child) => { - $(child).find('.js-media-library-item-weight').val(index); + $(child).find('.js-media-library-item-weight')[0].value = index; }); }, }); diff --git a/core/modules/media_library/js/media_library.widget.js b/core/modules/media_library/js/media_library.widget.js index 4b6df19ba4eb03e103e725633695be21e3eb85b6..c193f74183ad0d2fb7495d450bb6161891b1b95f 100644 --- a/core/modules/media_library/js/media_library.widget.js +++ b/core/modules/media_library/js/media_library.widget.js @@ -15,7 +15,7 @@ handle: '.js-media-library-item-preview', onEnd: () => { $(widget).children().each((index, child) => { - $(child).find('.js-media-library-item-weight').val(index); + $(child).find('.js-media-library-item-weight')[0].value = index; }); } }); diff --git a/core/modules/media_library/media_library.libraries.yml b/core/modules/media_library/media_library.libraries.yml index 28b873879aae2f58447f6ad465a1b5b397abc5a8..8c2f1b393a0af47bdae1486afde25834406f1d5a 100644 --- a/core/modules/media_library/media_library.libraries.yml +++ b/core/modules/media_library/media_library.libraries.yml @@ -32,6 +32,7 @@ ui: dependencies: - core/drupal.ajax - core/drupal.announce + - core/drupal.nodelist.foreach - core/once - core/jquery.once.bc - core/jquery diff --git a/core/modules/menu_ui/menu_ui.admin.es6.js b/core/modules/menu_ui/menu_ui.admin.es6.js index 69b0d6843e3a521755708b19866263914e3dbd2d..57607657c3f026f5ff655f3b257418705923782c 100644 --- a/core/modules/menu_ui/menu_ui.admin.es6.js +++ b/core/modules/menu_ui/menu_ui.admin.es6.js @@ -32,7 +32,7 @@ $menu.find('input:checked').each(function () { // Get the names of all checked menus. - values.push(Drupal.checkPlain($(this).val())); + values.push(Drupal.checkPlain(this.value)); }); $.ajax({ @@ -45,21 +45,17 @@ success(options) { const $select = $('#edit-menu-parent'); // Save key of last selected element. - const selected = $select.val(); + const selected = $select[0].value; // Remove all existing options from dropdown. $select.children().remove(); // Add new options to dropdown. Keep a count of options for testing later. let totalOptions = 0; Object.keys(options || {}).forEach((machineName) => { - $select.append( - $( - `<option ${ - machineName === selected ? ' selected="selected"' : '' - }></option>`, - ) - .val(machineName) - .text(options[machineName]), - ); + const selectContents = document.createElement('option'); + selectContents.selected = machineName === selected; + selectContents.value = machineName; + selectContents.innerText = options[machineName]; + $select.append(selectContents); totalOptions++; }); diff --git a/core/modules/menu_ui/menu_ui.admin.js b/core/modules/menu_ui/menu_ui.admin.js index 728ca26fdcd86a408080212c37052c06cd0c1af0..f78d82ff82ac486309f487a242c603409d138646 100644 --- a/core/modules/menu_ui/menu_ui.admin.js +++ b/core/modules/menu_ui/menu_ui.admin.js @@ -23,7 +23,7 @@ const $menu = $('#edit-menu'); const values = []; $menu.find('input:checked').each(function () { - values.push(Drupal.checkPlain($(this).val())); + values.push(Drupal.checkPlain(this.value)); }); $.ajax({ url: `${window.location.protocol}//${window.location.host}${Drupal.url('admin/structure/menu/parents')}`, @@ -35,11 +35,15 @@ success(options) { const $select = $('#edit-menu-parent'); - const selected = $select.val(); + const selected = $select[0].value; $select.children().remove(); let totalOptions = 0; Object.keys(options || {}).forEach(machineName => { - $select.append($(`<option ${machineName === selected ? ' selected="selected"' : ''}></option>`).val(machineName).text(options[machineName])); + const selectContents = document.createElement('option'); + selectContents.selected = machineName === selected; + selectContents.value = machineName; + selectContents.innerText = options[machineName]; + $select.append(selectContents); totalOptions++; }); $select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0); diff --git a/core/modules/menu_ui/menu_ui.es6.js b/core/modules/menu_ui/menu_ui.es6.js index 5188164f149828bfdc9f79e1f84541bf8759a83a..51c417cab14eaa6311e960da9fa42c20f0318cfb 100644 --- a/core/modules/menu_ui/menu_ui.es6.js +++ b/core/modules/menu_ui/menu_ui.es6.js @@ -22,7 +22,7 @@ $context.find('.js-form-item-menu-enabled input').is(':checked') ) { return Drupal.checkPlain( - $context.find('.js-form-item-menu-title input').val(), + $context.find('.js-form-item-menu-title input')[0].value, ); } @@ -60,7 +60,7 @@ // If there is a link title already, mark it as overridden. The user // expects that toggling the checkbox twice will take over the node's // title. - if ($checkbox.is(':checked') && $linkTitle.val().length) { + if ($checkbox.is(':checked') && $linkTitle[0].value.length) { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); } // Whenever the value is changed manually, disable this behavior. @@ -71,10 +71,10 @@ $checkbox.on('change', () => { if ($checkbox.is(':checked')) { if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) { - $linkTitle.val($title.val()); + $linkTitle[0].value = $title[0].value; } } else { - $linkTitle.val(''); + $linkTitle[0].value = ''; $linkTitle.removeData('menuLinkAutomaticTitleOverridden'); } $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated'); @@ -86,8 +86,8 @@ !$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked') ) { - $linkTitle.val($title.val()); - $linkTitle.val($title.val()).trigger('formUpdated'); + $linkTitle[0].value = $title[0].value; + $linkTitle.trigger('formUpdated'); } }); }); diff --git a/core/modules/menu_ui/menu_ui.js b/core/modules/menu_ui/menu_ui.js index c4bb7d7e885836c16d15796b232b4d1ec3949326..58d32d44c78ccffcec1193c5209f298632f01dcd 100644 --- a/core/modules/menu_ui/menu_ui.js +++ b/core/modules/menu_ui/menu_ui.js @@ -12,7 +12,7 @@ const $context = $(context); if ($context.find('.js-form-item-menu-enabled input').is(':checked')) { - return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val()); + return Drupal.checkPlain($context.find('.js-form-item-menu-title input')[0].value); } return Drupal.t('Not in menu'); @@ -33,7 +33,7 @@ return; } - if ($checkbox.is(':checked') && $linkTitle.val().length) { + if ($checkbox.is(':checked') && $linkTitle[0].value.length) { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); } @@ -43,10 +43,10 @@ $checkbox.on('change', () => { if ($checkbox.is(':checked')) { if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) { - $linkTitle.val($title.val()); + $linkTitle[0].value = $title[0].value; } } else { - $linkTitle.val(''); + $linkTitle[0].value = ''; $linkTitle.removeData('menuLinkAutomaticTitleOverridden'); } @@ -55,8 +55,8 @@ }); $title.on('keyup', () => { if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) { - $linkTitle.val($title.val()); - $linkTitle.val($title.val()).trigger('formUpdated'); + $linkTitle[0].value = $title[0].value; + $linkTitle.trigger('formUpdated'); } }); }); diff --git a/core/modules/node/content_types.es6.js b/core/modules/node/content_types.es6.js index dbfd7a9ddef915c9e002d8adbf18451c75bfd76e..4bb82a5c468be251c87234d00a3bf2bc35ae091a 100644 --- a/core/modules/node/content_types.es6.js +++ b/core/modules/node/content_types.es6.js @@ -19,7 +19,7 @@ $context.find('#edit-submission').drupalSetSummary((context) => { const vals = []; vals.push( - Drupal.checkPlain($(context).find('#edit-title-label').val()) || + Drupal.checkPlain($(context).find('#edit-title-label')[0].value) || Drupal.t('Requires a title'), ); return vals.join(', '); diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index fa3b16ffac21a16daab31244ad70c5a9dcf1c7cf..c66537b2187336094cdabccbf6ee6507555c5edc 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -11,7 +11,7 @@ const $context = $(context); $context.find('#edit-submission').drupalSetSummary(context => { const vals = []; - vals.push(Drupal.checkPlain($(context).find('#edit-title-label').val()) || Drupal.t('Requires a title')); + vals.push(Drupal.checkPlain($(context).find('#edit-title-label')[0].value) || Drupal.t('Requires a title')); return vals.join(', '); }); $context.find('#edit-workflow').drupalSetSummary(context => { diff --git a/core/modules/node/node.es6.js b/core/modules/node/node.es6.js index 45a670241727264a42aca48a1a28429e6a4916db..23e6cb44158d5fcb0404deb35f4ee401718c97f4 100644 --- a/core/modules/node/node.es6.js +++ b/core/modules/node/node.es6.js @@ -17,9 +17,10 @@ const $context = $(context); $context.find('.node-form-author').drupalSetSummary((context) => { - const $authorContext = $(context); - const name = $authorContext.find('.field--name-uid input').val(); - const date = $authorContext.find('.field--name-created input').val(); + const nameElement = context.querySelector('.field--name-uid input'); + const name = nameElement && nameElement.value; + const dateElement = context.querySelector('.field--name-created input'); + const date = dateElement && dateElement.value; if (name && date) { return Drupal.t('By @name on @date', { diff --git a/core/modules/node/node.js b/core/modules/node/node.js index d50a617f87165eb5aabd34c560518f8264a9cf47..a31756ca98e0629e2dc94201c0088b2866825bbc 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -10,9 +10,10 @@ attach(context) { const $context = $(context); $context.find('.node-form-author').drupalSetSummary(context => { - const $authorContext = $(context); - const name = $authorContext.find('.field--name-uid input').val(); - const date = $authorContext.find('.field--name-created input').val(); + const nameElement = context.querySelector('.field--name-uid input'); + const name = nameElement && nameElement.value; + const dateElement = context.querySelector('.field--name-created input'); + const date = dateElement && dateElement.value; if (name && date) { return Drupal.t('By @name on @date', { diff --git a/core/modules/path/path.es6.js b/core/modules/path/path.es6.js index f54f53b08d64621b5b6b8bbd9e2f4f677b018433..9d55741b78d9b462e8c9eec1486c52e27ca9513b 100644 --- a/core/modules/path/path.es6.js +++ b/core/modules/path/path.es6.js @@ -16,8 +16,10 @@ $(context) .find('.path-form') .drupalSetSummary((context) => { - const path = $('.js-form-item-path-0-alias input').val(); - + const pathElement = document.querySelector( + '.js-form-item-path-0-alias input', + ); + const path = pathElement && pathElement.value; return path ? Drupal.t('Alias: @alias', { '@alias': path }) : Drupal.t('No alias'); diff --git a/core/modules/path/path.js b/core/modules/path/path.js index ac60045f8003c2428961b6042784f6c9635cea8d..b02e559a67676fea137155521d3b463ecf89cf15 100644 --- a/core/modules/path/path.js +++ b/core/modules/path/path.js @@ -9,7 +9,8 @@ Drupal.behaviors.pathDetailsSummaries = { attach(context) { $(context).find('.path-form').drupalSetSummary(context => { - const path = $('.js-form-item-path-0-alias input').val(); + const pathElement = document.querySelector('.js-form-item-path-0-alias input'); + const path = pathElement && pathElement.value; return path ? Drupal.t('Alias: @alias', { '@alias': path }) : Drupal.t('No alias'); diff --git a/core/modules/quickedit/js/views/EditorView.es6.js b/core/modules/quickedit/js/views/EditorView.es6.js index e3ee331e65ccff20b9d2f62166e896aa94b09fc2..cb6b5153a35f6f6e6fb2ee94cf6c160f899b1fdb 100644 --- a/core/modules/quickedit/js/views/EditorView.es6.js +++ b/core/modules/quickedit/js/views/EditorView.es6.js @@ -198,6 +198,7 @@ const $form = $(`#${backstageId}`).find('form'); // Fill in the value in any <input> that isn't hidden or a submit // button. + // eslint-disable-next-line jquery/no-val $form .find(':input[type!="hidden"][type!="submit"]:not(select)') // Don't mess with the node summary. diff --git a/core/modules/system/js/system.date.es6.js b/core/modules/system/js/system.date.es6.js index 8617d4ae1d1e76e2bcdac521d01285afa20dc55c..8412bd07f021a4971778706f0f876f04e3e29fb3 100644 --- a/core/modules/system/js/system.date.es6.js +++ b/core/modules/system/js/system.date.es6.js @@ -42,7 +42,7 @@ * The jQuery event triggered. */ function dateFormatHandler(e) { - const baseValue = $(e.target).val() || ''; + const baseValue = e.target.value || ''; const dateString = baseValue.replace(/\\?(.?)/gi, (key, value) => dateFormats[key] ? dateFormats[key] : value, ); diff --git a/core/modules/system/js/system.date.js b/core/modules/system/js/system.date.js index faeba83cbf2feb400934dc5ac58aa7e52736da1d..e742395ea2399fcf72dfdeb6a45bc7f060476884 100644 --- a/core/modules/system/js/system.date.js +++ b/core/modules/system/js/system.date.js @@ -20,7 +20,7 @@ const $preview = $target.find('em'); function dateFormatHandler(e) { - const baseValue = $(e.target).val() || ''; + const baseValue = e.target.value || ''; const dateString = baseValue.replace(/\\?(.?)/gi, (key, value) => dateFormats[key] ? dateFormats[key] : value); $preview.text(dateString); $target.toggleClass('js-hide', !dateString.length); diff --git a/core/modules/system/js/system.es6.js b/core/modules/system/js/system.es6.js index 7717d290b563b8f6c5c33436ff520a1ee232e007..7bca481c068bd41c507ee5b33f16f581a128ee7b 100644 --- a/core/modules/system/js/system.es6.js +++ b/core/modules/system/js/system.es6.js @@ -58,9 +58,9 @@ * Custom value from jQuery trigger. */ valueTargetCopyHandler(e, value) { - const $target = $(e.target); - if ($target.val() === '') { - $target.val(value); + const { target } = e; + if (target.value === '') { + target.value = value; } }, @@ -74,7 +74,7 @@ * The event triggered. */ valueSourceBlurHandler(e) { - const value = $(e.target).val(); + const { value } = e.target; const targetIds = drupalSettings.copyFieldValue[e.target.id]; $(`#${targetIds.join(', #')}`).trigger('value:copy', value); }, diff --git a/core/modules/system/js/system.js b/core/modules/system/js/system.js index 3aee4859c487f826910c1375f0445b18dc6e450d..86bbfb220a8b361eb64fec9aeb0119953447800e 100644 --- a/core/modules/system/js/system.js +++ b/core/modules/system/js/system.js @@ -27,15 +27,19 @@ }, valueTargetCopyHandler(e, value) { - const $target = $(e.target); + const { + target + } = e; - if ($target.val() === '') { - $target.val(value); + if (target.value === '') { + target.value = value; } }, valueSourceBlurHandler(e) { - const value = $(e.target).val(); + const { + value + } = e.target; const targetIds = drupalSettings.copyFieldValue[e.target.id]; $(`#${targetIds.join(', #')}`).trigger('value:copy', value); } diff --git a/core/modules/system/js/system.modules.es6.js b/core/modules/system/js/system.modules.es6.js index 98be18f98905d1bd810e8d74d40f8a24d503be74..632d9758de4cb85a7a3f5033f1ad7023c7d57919 100644 --- a/core/modules/system/js/system.modules.es6.js +++ b/core/modules/system/js/system.modules.es6.js @@ -35,7 +35,7 @@ } function filterModuleList(e) { - const query = $(e.target).val(); + const query = e.target.value; // Case insensitive expression to find query at the beginning of a word. const re = new RegExp(`\\b${query}`, 'i'); diff --git a/core/modules/system/js/system.modules.js b/core/modules/system/js/system.modules.js index e397b2c736e609fe185bcd8c4eef3739b3794ea9..98f53c683bc86d8989d7f7fa2c2a1bbeb83f5e0e 100644 --- a/core/modules/system/js/system.modules.js +++ b/core/modules/system/js/system.modules.js @@ -27,7 +27,7 @@ } function filterModuleList(e) { - const query = $(e.target).val(); + const query = e.target.value; const re = new RegExp(`\\b${query}`, 'i'); function showModuleRow(index, row) { diff --git a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.es6.js b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.es6.js index ccd013ae727f22dd18e02796ede57062ab6103fc..abea6396e25099605eeaed98e33d861ba7675450 100644 --- a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.es6.js +++ b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.es6.js @@ -3,7 +3,7 @@ * Testing behavior for JSWebAssertTest. */ -(function ($, Drupal, drupalSettings) { +(function (Drupal, drupalSettings) { /** * @type {Drupal~behavior} * @@ -12,9 +12,13 @@ */ Drupal.behaviors.js_webassert_test_wait_for_ajax_request = { attach(context) { - $('input[name="test_assert_wait_on_ajax_input"]').val( - 'js_webassert_test', + const waitAjaxInput = document.querySelector( + 'input[name="test_assert_wait_on_ajax_input"]', ); + // Confirm the input exists before assigning a value to it. + if (waitAjaxInput) { + waitAjaxInput.value = 'js_webassert_test'; + } }, }; -})(jQuery, Drupal, drupalSettings); +})(Drupal, drupalSettings); diff --git a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js index e67b784226290e17aef32ca63f9688e34ee3e8ff..a62ccd82f4ce651148802bb7c7e73e031f3523eb 100644 --- a/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js +++ b/core/modules/system/tests/modules/js_webassert_test/js/js_webassert_test.wait_for_ajax_request.js @@ -5,11 +5,15 @@ * @preserve **/ -(function ($, Drupal, drupalSettings) { +(function (Drupal, drupalSettings) { Drupal.behaviors.js_webassert_test_wait_for_ajax_request = { attach(context) { - $('input[name="test_assert_wait_on_ajax_input"]').val('js_webassert_test'); + const waitAjaxInput = document.querySelector('input[name="test_assert_wait_on_ajax_input"]'); + + if (waitAjaxInput) { + waitAjaxInput.value = 'js_webassert_test'; + } } }; -})(jQuery, Drupal, drupalSettings); \ No newline at end of file +})(Drupal, drupalSettings); \ No newline at end of file diff --git a/core/modules/system/tests/modules/js_webassert_test/js_webassert_test.libraries.yml b/core/modules/system/tests/modules/js_webassert_test/js_webassert_test.libraries.yml index 898e6375078a5a3315f351424a8559afb279e74e..e7ec966a162554e222a95063dd77414615e2832a 100644 --- a/core/modules/system/tests/modules/js_webassert_test/js_webassert_test.libraries.yml +++ b/core/modules/system/tests/modules/js_webassert_test/js_webassert_test.libraries.yml @@ -3,7 +3,6 @@ wait_for_ajax_request: js: js/js_webassert_test.wait_for_ajax_request.js: {} dependencies: - - core/jquery - core/drupal wait_for_element: version: VERSION diff --git a/core/modules/text/text.es6.js b/core/modules/text/text.es6.js index 0dfc7f0f4bb41cb9851b113bebec8af71b3dfd9b..c584f2dbd13209650e7d06dda01729f7271f1398 100644 --- a/core/modules/text/text.es6.js +++ b/core/modules/text/text.es6.js @@ -64,7 +64,7 @@ .appendTo($summaryLabel); // If no summary is set, hide the summary field. - if ($widget.find('.js-text-summary').val() === '') { + if (summary.value === '') { $link.trigger('click'); } }); diff --git a/core/modules/text/text.js b/core/modules/text/text.js index df62c14002777dd805dde91fb38224ca0df5358f..0996a9e4f2881d657c3a2451e6118da49e56b5a5 100644 --- a/core/modules/text/text.js +++ b/core/modules/text/text.js @@ -42,7 +42,7 @@ toggleClick = !toggleClick; }).appendTo($summaryLabel); - if ($widget.find('.js-text-summary').val() === '') { + if (summary.value === '') { $link.trigger('click'); } }); diff --git a/core/modules/toolbar/js/views/ToolbarVisualView.es6.js b/core/modules/toolbar/js/views/ToolbarVisualView.es6.js index c6afbdc0eb279411fefec963b04b02ff233d8c96..6f514edfa5d03842ece2a25e668a1779a6371a6e 100644 --- a/core/modules/toolbar/js/views/ToolbarVisualView.es6.js +++ b/core/modules/toolbar/js/views/ToolbarVisualView.es6.js @@ -287,9 +287,9 @@ const $orientationToggle = this.$el .find('.toolbar-toggle-orientation') .toggle(this.model.get('isTrayToggleVisible')); - $orientationToggle - .find('button') - .val(antiOrientation) + const $orientationToggleButton = $orientationToggle.find('button'); + $orientationToggleButton[0].value = antiOrientation; + $orientationToggleButton .attr('title', this.strings[antiOrientation]) .text(this.strings[antiOrientation]) .removeClass(iconClass) diff --git a/core/modules/toolbar/js/views/ToolbarVisualView.js b/core/modules/toolbar/js/views/ToolbarVisualView.js index 36b75a32dbbf7ae465411823e471f3c2afe1c356..0a6ac272050856ac21ddabc0338196de3cbb441b 100644 --- a/core/modules/toolbar/js/views/ToolbarVisualView.js +++ b/core/modules/toolbar/js/views/ToolbarVisualView.js @@ -144,7 +144,9 @@ const iconClass = `toolbar-icon-toggle-${orientation}`; const iconAntiClass = `toolbar-icon-toggle-${antiOrientation}`; const $orientationToggle = this.$el.find('.toolbar-toggle-orientation').toggle(this.model.get('isTrayToggleVisible')); - $orientationToggle.find('button').val(antiOrientation).attr('title', this.strings[antiOrientation]).text(this.strings[antiOrientation]).removeClass(iconClass).addClass(iconAntiClass); + const $orientationToggleButton = $orientationToggle.find('button'); + $orientationToggleButton[0].value = antiOrientation; + $orientationToggleButton.attr('title', this.strings[antiOrientation]).text(this.strings[antiOrientation]).removeClass(iconClass).addClass(iconAntiClass); const dir = document.documentElement.dir; const edge = dir === 'rtl' ? 'right' : 'left'; $trays.removeAttr('data-offset-left data-offset-right data-offset-top'); diff --git a/core/modules/user/user.es6.js b/core/modules/user/user.es6.js index 0b6a6c966aa05fc7adeca200d4822348bd7f1ff2..cc8169b44d956d536d7d172ddbffaec51f58cdc1 100644 --- a/core/modules/user/user.es6.js +++ b/core/modules/user/user.es6.js @@ -169,12 +169,12 @@ const addWidgetClasses = () => { $passwordWidget .addClass( - $mainInput.val() + $mainInput[0].value ? cssClasses.passwordFilled : cssClasses.passwordEmpty, ) .addClass( - $confirmInput.val() + $confirmInput[0].value ? cssClasses.confirmFilled : cssClasses.confirmEmpty, ); @@ -187,7 +187,7 @@ * The value of the confirm input. */ const passwordCheckMatch = (confirmInputVal) => { - const passwordsAreMatching = $mainInput.val() === confirmInputVal; + const passwordsAreMatching = $mainInput[0].value === confirmInputVal; const confirmClass = passwordsAreMatching ? cssClasses.passwordsMatch : cssClasses.passwordsNotMatch; @@ -216,7 +216,7 @@ if (settings.password.showStrengthIndicator) { // Evaluate the password strength. const result = Drupal.evaluatePasswordStrength( - $mainInput.val(), + $mainInput[0].value, settings.password, ); const $currentPasswordSuggestions = $( @@ -255,8 +255,8 @@ } // Check the value in the confirm input and show results. - if ($confirmInput.val()) { - passwordCheckMatch($confirmInput.val()); + if ($confirmInput[0].value) { + passwordCheckMatch($confirmInput[0].value); $passwordConfirmMessage.css({ visibility: 'visible' }); } else { $passwordConfirmMessage.css({ visibility: 'hidden' }); @@ -310,7 +310,9 @@ // otherwise use value from the database. const $usernameBox = $('input.username'); const username = - $usernameBox.length > 0 ? $usernameBox.val() : passwordSettings.username; + $usernameBox.length > 0 + ? $usernameBox[0].value + : passwordSettings.username; // Lose 5 points for every character less than 12, plus a 30 point penalty. if (password.length < 12) { diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 75b7ad64bdafca786c7a0665146c60a6a90d668f..73c501ba1d9d6d5da31aa4fc47af11ff82968925 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -75,11 +75,11 @@ } const addWidgetClasses = () => { - $passwordWidget.addClass($mainInput.val() ? cssClasses.passwordFilled : cssClasses.passwordEmpty).addClass($confirmInput.val() ? cssClasses.confirmFilled : cssClasses.confirmEmpty); + $passwordWidget.addClass($mainInput[0].value ? cssClasses.passwordFilled : cssClasses.passwordEmpty).addClass($confirmInput[0].value ? cssClasses.confirmFilled : cssClasses.confirmEmpty); }; const passwordCheckMatch = confirmInputVal => { - const passwordsAreMatching = $mainInput.val() === confirmInputVal; + const passwordsAreMatching = $mainInput[0].value === confirmInputVal; const confirmClass = passwordsAreMatching ? cssClasses.passwordsMatch : cssClasses.passwordsNotMatch; const confirmMessage = passwordsAreMatching ? settings.password.confirmSuccess : settings.password.confirmFailure; @@ -94,7 +94,7 @@ const passwordCheck = () => { if (settings.password.showStrengthIndicator) { - const result = Drupal.evaluatePasswordStrength($mainInput.val(), settings.password); + const result = Drupal.evaluatePasswordStrength($mainInput[0].value, settings.password); const $currentPasswordSuggestions = $(Drupal.theme('passwordSuggestions', settings.password, result.messageTips)); if (password.$suggestions.html() !== $currentPasswordSuggestions.html()) { @@ -110,8 +110,8 @@ password.$strengthTextWrapper.html(result.indicatorText); } - if ($confirmInput.val()) { - passwordCheckMatch($confirmInput.val()); + if ($confirmInput[0].value) { + passwordCheckMatch($confirmInput[0].value); $passwordConfirmMessage.css({ visibility: 'visible' }); @@ -150,7 +150,7 @@ const hasNumbers = /[0-9]/.test(password); const hasPunctuation = /[^a-zA-Z0-9]/.test(password); const $usernameBox = $('input.username'); - const username = $usernameBox.length > 0 ? $usernameBox.val() : passwordSettings.username; + const username = $usernameBox.length > 0 ? $usernameBox[0].value : passwordSettings.username; if (password.length < 12) { msg.push(passwordSettings.tooShort); diff --git a/core/modules/views_ui/js/ajax.es6.js b/core/modules/views_ui/js/ajax.es6.js index 560353769504ac499a6bd4dfef64bfb8475d436a..e98be85b8173c7de6ff242d7da13d5e4f72e781a 100644 --- a/core/modules/views_ui/js/ajax.es6.js +++ b/core/modules/views_ui/js/ajax.es6.js @@ -194,8 +194,13 @@ const href = $(this).attr('href'); // Cut of #views-tabset. const displayId = href.substr(11); - // Set the form element. - $('#views-live-preview #preview-display-id').val(displayId); + const viewsPreviewId = document.querySelector( + '#views-live-preview #preview-display-id', + ); + if (viewsPreviewId) { + // Set the form element if it is present. + viewsPreviewId.value = displayId; + } }); }, }; diff --git a/core/modules/views_ui/js/ajax.js b/core/modules/views_ui/js/ajax.js index 6a5df0c8f61f1671166f9e9bbd5e99808c0b7a23..c467facc5bd3c071fdbede56b27a0636b587b22b 100644 --- a/core/modules/views_ui/js/ajax.js +++ b/core/modules/views_ui/js/ajax.js @@ -72,7 +72,11 @@ $(once('views-ajax', '#views-tabset a')).on('click', function () { const href = $(this).attr('href'); const displayId = href.substr(11); - $('#views-live-preview #preview-display-id').val(displayId); + const viewsPreviewId = document.querySelector('#views-live-preview #preview-display-id'); + + if (viewsPreviewId) { + viewsPreviewId.value = displayId; + } }); } diff --git a/core/modules/views_ui/js/views-admin.es6.js b/core/modules/views_ui/js/views-admin.es6.js index f91f29e8d9ba27152279fa832e4b4dc88fbfa2df..b29af12a4123995eede208316242e3c859e8d237 100644 --- a/core/modules/views_ui/js/views-admin.es6.js +++ b/core/modules/views_ui/js/views-admin.es6.js @@ -207,7 +207,7 @@ * The source form field value. */ getTransliterated() { - let from = this.source.val(); + let from = this.source.length ? this.source[0].value : ''; if (this.exclude) { from = from.toLowerCase().replace(this.exclude, this.replace); } @@ -223,7 +223,7 @@ this.target.each(function (i) { // Ensure that the maxlength is not exceeded by prepopulating the field. const maxlength = $(this).attr('maxlength') - suffix.length; - $(this).val(transliterated.substr(0, maxlength) + suffix); + this.value = transliterated.substr(0, maxlength) + suffix; }); }, @@ -390,9 +390,9 @@ // placed in an 'Add' dropdown. @todo This assumes English, but so does // $addDisplayDropdown above. Add support for translation. $displayButtons.each(function () { - const label = $(this).val(); + const label = this.value; if (label.substr(0, 4) === 'Add ') { - $(this).val(label.substr(4)); + this.value = label.substr(4); } }); $addDisplayDropdown.appendTo($menu); @@ -559,10 +559,10 @@ handleFilter(event) { // Determine the user's search query. The search text has been converted // to lowercase. - const search = this.$searchBox.val().toLowerCase(); + const search = this.$searchBox[0].value.toLowerCase(); const words = search.split(' '); // Get selected Group - const group = this.$controlGroup.val(); + const group = this.$controlGroup[0].value; // Search through the search texts in the form for matching text. this.options.forEach((option) => { @@ -753,7 +753,7 @@ // When the link is clicked, dynamically click the hidden form // button for adding a new filter group. $( - `<ul class="action-links"><li><a id="views-add-group-link" href="#">${this.addGroupButton.val()}</a></li></ul>`, + `<ul class="action-links"><li><a id="views-add-group-link" href="#">${this.addGroupButton[0].value}</a></li></ul>`, ).prependTo(this.table.parent()), ), ) @@ -896,7 +896,9 @@ const operators = this.dropdowns.find('select').not($target); // Change the other operators to match this new value. - operators.val($target.val()); + operators.each(function (index, item) { + item.value = $target[0].value; + }); }, /** @@ -984,7 +986,7 @@ groupField .removeClass(`views-group-select-${oldGroupName}`) .addClass(`views-group-select-${groupName}`); - groupField.val(groupName); + groupField[0].value = groupName; } }; }, @@ -1236,26 +1238,28 @@ ).forEach((dropdown) => { // Closures! :( const $context = $(context); - const $submit = $context.find('[id^=edit-submit]'); - const oldValue = $submit.val(); + const submit = context.querySelector('[id^=edit-submit]'); + const oldValue = submit ? submit.value : ''; - $(once('views-ui-override-button-text', $submit)).on( + $(once('views-ui-override-button-text', submit)).on( 'mouseup', function () { - $(this).val(oldValue); + this.value = oldValue; return true; }, ); $(dropdown) .on('change', function () { - const $this = $(this); - if ($this.val() === 'default') { - $submit.val(Drupal.t('Apply (all displays)')); - } else if ($this.val() === 'default_revert') { - $submit.val(Drupal.t('Revert to default')); + if (!submit) { + return; + } + if (this.value === 'default') { + submit.value = Drupal.t('Apply (all displays)'); + } else if (this.value === 'default_revert') { + submit.value = Drupal.t('Revert to default'); } else { - $submit.val(Drupal.t('Apply (this display)')); + submit.value = Drupal.t('Apply (this display)'); } const $dialog = $context.closest('.ui-dialog-content'); $dialog.trigger('dialogButtonsChange'); diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index cfced1787a687624b77bcc4e0b1f500dbc1e9a83..99583f75ed17b25f53ef4272f1ba36869e586f91 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -82,7 +82,7 @@ }, getTransliterated() { - let from = this.source.val(); + let from = this.source.length ? this.source[0].value : ''; if (this.exclude) { from = from.toLowerCase().replace(this.exclude, this.replace); @@ -96,7 +96,7 @@ const suffix = this.suffix; this.target.each(function (i) { const maxlength = $(this).attr('maxlength') - suffix.length; - $(this).val(transliterated.substr(0, maxlength) + suffix); + this.value = transliterated.substr(0, maxlength) + suffix; }); }, @@ -178,10 +178,10 @@ const $displayButtons = $menu.nextAll('input.add-display').detach(); $displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('<li>').parent().eq(0).addClass('first').end().eq(-1).addClass('last'); $displayButtons.each(function () { - const label = $(this).val(); + const label = this.value; if (label.substr(0, 4) === 'Add ') { - $(this).val(label.substr(4)); + this.value = label.substr(4); } }); $addDisplayDropdown.appendTo($menu); @@ -264,9 +264,9 @@ }, handleFilter(event) { - const search = this.$searchBox.val().toLowerCase(); + const search = this.$searchBox[0].value.toLowerCase(); const words = search.split(' '); - const group = this.$controlGroup.val(); + const group = this.$controlGroup[0].value; this.options.forEach(option => { function hasWord(word) { return option.searchText.indexOf(word) !== -1; @@ -333,7 +333,7 @@ $.extend(Drupal.viewsUi.RearrangeFilterHandler.prototype, { insertAddRemoveFilterGroupLinks() { - $(once('views-rearrange-filter-handler', $(`<ul class="action-links"><li><a id="views-add-group-link" href="#">${this.addGroupButton.val()}</a></li></ul>`).prependTo(this.table.parent()))).find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton')); + $(once('views-rearrange-filter-handler', $(`<ul class="action-links"><li><a id="views-add-group-link" href="#">${this.addGroupButton[0].value}</a></li></ul>`).prependTo(this.table.parent()))).find('#views-add-group-link').on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton')); const length = this.removeGroupButtons.length; let i; @@ -398,7 +398,9 @@ operatorChangeHandler(event) { const $target = $(event.target); const operators = this.dropdowns.find('select').not($target); - operators.val($target.val()); + operators.each(function (index, item) { + item.value = $target[0].value; + }); }, modifyTableDrag() { @@ -442,7 +444,7 @@ if (!groupField.is(`.views-group-select-${groupName}`)) { const oldGroupName = groupField.attr('class').replace(/([^ ]+[ ]+)*views-group-select-([^ ]+)([ ]+[^ ]+)*/, '$2'); groupField.removeClass(`views-group-select-${oldGroupName}`).addClass(`views-group-select-${groupName}`); - groupField.val(groupName); + groupField[0].value = groupName; } }; }, @@ -568,21 +570,23 @@ attach(context) { once('views-ui-override-button-text', '[data-drupal-selector="edit-override-dropdown"]', context).forEach(dropdown => { const $context = $(context); - const $submit = $context.find('[id^=edit-submit]'); - const oldValue = $submit.val(); - $(once('views-ui-override-button-text', $submit)).on('mouseup', function () { - $(this).val(oldValue); + const submit = context.querySelector('[id^=edit-submit]'); + const oldValue = submit ? submit.value : ''; + $(once('views-ui-override-button-text', submit)).on('mouseup', function () { + this.value = oldValue; return true; }); $(dropdown).on('change', function () { - const $this = $(this); + if (!submit) { + return; + } - if ($this.val() === 'default') { - $submit.val(Drupal.t('Apply (all displays)')); - } else if ($this.val() === 'default_revert') { - $submit.val(Drupal.t('Revert to default')); + if (this.value === 'default') { + submit.value = Drupal.t('Apply (all displays)'); + } else if (this.value === 'default_revert') { + submit.value = Drupal.t('Revert to default'); } else { - $submit.val(Drupal.t('Apply (this display)')); + submit.value = Drupal.t('Apply (this display)'); } const $dialog = $context.closest('.ui-dialog-content'); diff --git a/core/modules/views_ui/js/views_ui.listing.es6.js b/core/modules/views_ui/js/views_ui.listing.es6.js index a3ba5604e38ef12fbe48705815ea0f94edf71a28..8a9f3195e54456034e952a02e2456394c6e418c5 100644 --- a/core/modules/views_ui/js/views_ui.listing.es6.js +++ b/core/modules/views_ui/js/views_ui.listing.es6.js @@ -26,7 +26,7 @@ let $rows; function filterViewList(e) { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); function showViewRow(index, row) { const $row = $(row); diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index b87dbede61f68ca611b4a4af1be9a1f3fbe4ff09..6a81659066045f7179f88f622cf3891ac28a55d0 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -18,7 +18,7 @@ let $rows; function filterViewList(e) { - const query = $(e.target).val().toLowerCase(); + const query = e.target.value.toLowerCase(); function showViewRow(index, row) { const $row = $(row); diff --git a/core/themes/bartik/color/preview.es6.js b/core/themes/bartik/color/preview.es6.js index 7f91f8fad1b6b50e45b0c9917144db7ce71a5f00..914493d7484fd48669e90323c287ab2c44bf9487 100644 --- a/core/themes/bartik/color/preview.es6.js +++ b/core/themes/bartik/color/preview.es6.js @@ -25,16 +25,22 @@ // Solid background. $colorPreview.css( 'backgroundColor', - $colorPalette.find('input[name="palette[bg]"]').val(), + $colorPalette.find('input[name="palette[bg]"]')[0].value, ); // Text preview. $colorPreview .find('.color-preview-main h2, .color-preview .preview-content') - .css('color', $colorPalette.find('input[name="palette[text]"]').val()); + .css( + 'color', + $colorPalette.find('input[name="palette[text]"]')[0].value, + ); $colorPreview .find('.color-preview-content a') - .css('color', $colorPalette.find('input[name="palette[link]"]').val()); + .css( + 'color', + $colorPalette.find('input[name="palette[link]"]')[0].value, + ); // Sidebar block. const $colorPreviewBlock = $colorPreview.find( @@ -42,11 +48,11 @@ ); $colorPreviewBlock.css( 'background-color', - $colorPalette.find('input[name="palette[sidebar]"]').val(), + $colorPalette.find('input[name="palette[sidebar]"]')[0].value, ); $colorPreviewBlock.css( 'border-color', - $colorPalette.find('input[name="palette[sidebarborders]"]').val(), + $colorPalette.find('input[name="palette[sidebarborders]"]')[0].value, ); // Footer wrapper background. @@ -54,16 +60,14 @@ .find('.color-preview-footer-wrapper') .css( 'background-color', - $colorPalette.find('input[name="palette[footer]"]').val(), + $colorPalette.find('input[name="palette[footer]"]')[0].value, ); // CSS3 Gradients. - const gradientStart = $colorPalette - .find('input[name="palette[top]"]') - .val(); - const gradientEnd = $colorPalette - .find('input[name="palette[bottom]"]') - .val(); + const gradientStart = $colorPalette.find('input[name="palette[top]"]')[0] + .value; + const gradientEnd = $colorPalette.find('input[name="palette[bottom]"]')[0] + .value; $colorPreview .find('.color-preview-header') @@ -76,7 +80,7 @@ .find('.color-preview-site-name') .css( 'color', - $colorPalette.find('input[name="palette[titleslogan]"]').val(), + $colorPalette.find('input[name="palette[titleslogan]"]')[0].value, ); }, }; diff --git a/core/themes/bartik/color/preview.js b/core/themes/bartik/color/preview.js index 52d6f421a47c6e10908049da6b308a6f5c358eac..19624ffa57fabbe9ff53aea3bc7e20cf170b2f8f 100644 --- a/core/themes/bartik/color/preview.js +++ b/core/themes/bartik/color/preview.js @@ -21,17 +21,17 @@ const $colorPreview = $form.find('.color-preview'); const $colorPalette = $form.find('.js-color-palette'); - $colorPreview.css('backgroundColor', $colorPalette.find('input[name="palette[bg]"]').val()); - $colorPreview.find('.color-preview-main h2, .color-preview .preview-content').css('color', $colorPalette.find('input[name="palette[text]"]').val()); - $colorPreview.find('.color-preview-content a').css('color', $colorPalette.find('input[name="palette[link]"]').val()); + $colorPreview.css('backgroundColor', $colorPalette.find('input[name="palette[bg]"]')[0].value); + $colorPreview.find('.color-preview-main h2, .color-preview .preview-content').css('color', $colorPalette.find('input[name="palette[text]"]')[0].value); + $colorPreview.find('.color-preview-content a').css('color', $colorPalette.find('input[name="palette[link]"]')[0].value); const $colorPreviewBlock = $colorPreview.find('.color-preview-sidebar .color-preview-block'); - $colorPreviewBlock.css('background-color', $colorPalette.find('input[name="palette[sidebar]"]').val()); - $colorPreviewBlock.css('border-color', $colorPalette.find('input[name="palette[sidebarborders]"]').val()); - $colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]').val()); - const gradientStart = $colorPalette.find('input[name="palette[top]"]').val(); - const gradientEnd = $colorPalette.find('input[name="palette[bottom]"]').val(); + $colorPreviewBlock.css('background-color', $colorPalette.find('input[name="palette[sidebar]"]')[0].value); + $colorPreviewBlock.css('border-color', $colorPalette.find('input[name="palette[sidebarborders]"]')[0].value); + $colorPreview.find('.color-preview-footer-wrapper').css('background-color', $colorPalette.find('input[name="palette[footer]"]')[0].value); + const gradientStart = $colorPalette.find('input[name="palette[top]"]')[0].value; + const gradientEnd = $colorPalette.find('input[name="palette[bottom]"]')[0].value; $colorPreview.find('.color-preview-header').attr('style', `background-color: ${gradientStart}; background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(${gradientStart}), to(${gradientEnd})); background-image: -moz-linear-gradient(-90deg, ${gradientStart}, ${gradientEnd});`); - $colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]').val()); + $colorPreview.find('.color-preview-site-name').css('color', $colorPalette.find('input[name="palette[titleslogan]"]')[0].value); } }; diff --git a/core/themes/claro/js/vertical-tabs.es6.js b/core/themes/claro/js/vertical-tabs.es6.js index 32e7591780d371323c75fefc131cbe8f2155b528..28758071d26ed8e1d19758ca5b8198bb75eaff0b 100644 --- a/core/themes/claro/js/vertical-tabs.es6.js +++ b/core/themes/claro/js/vertical-tabs.es6.js @@ -104,7 +104,8 @@ once('vertical-tabs', '[data-vertical-tabs-panes]', context).forEach( (panes) => { const $this = $(panes).addClass('vertical-tabs__items--processed'); - const focusID = $this.find(':hidden.vertical-tabs__active-tab').val(); + const focusID = $this.find(':hidden.vertical-tabs__active-tab')[0] + .value; let tabFocus; // Check if there are some details that can be converted to diff --git a/core/themes/claro/js/vertical-tabs.js b/core/themes/claro/js/vertical-tabs.js index 551964ac4118325b3d748316593f7ee4b65e6c82..dc58e6585cb0da7df503fd6c2d07fb917772149a 100644 --- a/core/themes/claro/js/vertical-tabs.js +++ b/core/themes/claro/js/vertical-tabs.js @@ -17,7 +17,7 @@ $(once('vertical-tabs-fragments', 'body')).on('formFragmentLinkClickOrHashChange.verticalTabs', handleFragmentLinkClickOrHashChange); once('vertical-tabs', '[data-vertical-tabs-panes]', context).forEach(panes => { const $this = $(panes).addClass('vertical-tabs__items--processed'); - const focusID = $this.find(':hidden.vertical-tabs__active-tab').val(); + const focusID = $this.find(':hidden.vertical-tabs__active-tab')[0].value; let tabFocus; const $details = $this.find('> details');