diff options
Diffstat (limited to 'core/modules')
64 files changed, 281 insertions, 199 deletions
diff --git a/core/modules/block/js/block.admin.es6.js b/core/modules/block/js/block.admin.es6.js index 42d22546a56..055f2fccba5 100644 --- a/core/modules/block/js/block.admin.es6.js +++ b/core/modules/block/js/block.admin.es6.js @@ -44,9 +44,8 @@ * The label of the block. */ function toggleBlockEntry(index, label) { - const $label = $(label); - const $row = $label.parent().parent(); - const textMatch = $label.text().toLowerCase().includes(query); + const $row = $(label).parent().parent(); + const textMatch = label.textContent.toLowerCase().includes(query); $row.toggle(textMatch); } diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 7daee8c4647..bfed45abdee 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -16,9 +16,8 @@ const query = e.target.value.toLowerCase(); function toggleBlockEntry(index, label) { - const $label = $(label); - const $row = $label.parent().parent(); - const textMatch = $label.text().toLowerCase().includes(query); + const $row = $(label).parent().parent(); + const textMatch = label.textContent.toLowerCase().includes(query); $row.toggle(textMatch); } diff --git a/core/modules/book/book.es6.js b/core/modules/book/book.es6.js index c102a5be05c..b9f44d564e6 100644 --- a/core/modules/book/book.es6.js +++ b/core/modules/book/book.es6.js @@ -26,8 +26,7 @@ if (val === 'new') { return Drupal.t('New book'); } - - return Drupal.checkPlain($select.find(':selected').text()); + return Drupal.checkPlain($select.find(':selected')[0].textContent); }); }, }; diff --git a/core/modules/book/book.js b/core/modules/book/book.js index 243e028a835..efc457056d5 100644 --- a/core/modules/book/book.js +++ b/core/modules/book/book.js @@ -20,7 +20,7 @@ return Drupal.t('New book'); } - return Drupal.checkPlain($select.find(':selected').text()); + return Drupal.checkPlain($select.find(':selected')[0].textContent); }); } diff --git a/core/modules/ckeditor/js/ckeditor.admin.es6.js b/core/modules/ckeditor/js/ckeditor.admin.es6.js index 24dbf45469b..77462288a9a 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.es6.js +++ b/core/modules/ckeditor/js/ckeditor.admin.es6.js @@ -285,7 +285,9 @@ $group .attr('data-drupal-ckeditor-toolbar-group-name', name) .children('.ckeditor-toolbar-group-name') - .text(name); + .each(function () { + this.textContent = name; + }); } // Invoke a user-provided callback and indicate failure. diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js index ae8d0011814..835bd01c2c0 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.js +++ b/core/modules/ckeditor/js/ckeditor.admin.js @@ -119,7 +119,9 @@ $group.removeAttr('aria-label').attr('data-drupal-ckeditor-type', 'group').attr('tabindex', 0).children('.ckeditor-toolbar-group-name').attr('id', groupID).end().children('.ckeditor-toolbar-group-buttons').attr('aria-labelledby', groupID); } - $group.attr('data-drupal-ckeditor-toolbar-group-name', name).children('.ckeditor-toolbar-group-name').text(name); + $group.attr('data-drupal-ckeditor-toolbar-group-name', name).children('.ckeditor-toolbar-group-name').each(function () { + this.textContent = name; + }); } if (action === 'cancel') { diff --git a/core/modules/ckeditor/js/ckeditor.language.admin.es6.js b/core/modules/ckeditor/js/ckeditor.language.admin.es6.js index d020cb1c97c..2ec193afccb 100644 --- a/core/modules/ckeditor/js/ckeditor.language.admin.es6.js +++ b/core/modules/ckeditor/js/ckeditor.language.admin.es6.js @@ -4,10 +4,16 @@ */ Drupal.behaviors.ckeditorLanguageSettingsSummary = { attach() { - $('#edit-editor-settings-plugins-language').drupalSetSummary((context) => - $( - '#edit-editor-settings-plugins-language-language-list-type option:selected', - ).text(), + $('#edit-editor-settings-plugins-language').drupalSetSummary( + (context) => { + const $selected = $( + '#edit-editor-settings-plugins-language-language-list-type option:selected', + ); + if ($selected.length) { + return $selected[0].textContent; + } + return ''; + }, ); }, }; diff --git a/core/modules/ckeditor/js/ckeditor.language.admin.js b/core/modules/ckeditor/js/ckeditor.language.admin.js index 5d6376fb1f4..8d5941930cf 100644 --- a/core/modules/ckeditor/js/ckeditor.language.admin.js +++ b/core/modules/ckeditor/js/ckeditor.language.admin.js @@ -8,7 +8,15 @@ (function ($, Drupal) { Drupal.behaviors.ckeditorLanguageSettingsSummary = { attach() { - $('#edit-editor-settings-plugins-language').drupalSetSummary(context => $('#edit-editor-settings-plugins-language-language-list-type option:selected').text()); + $('#edit-editor-settings-plugins-language').drupalSetSummary(context => { + const $selected = $('#edit-editor-settings-plugins-language-language-list-type option:selected'); + + if ($selected.length) { + return $selected[0].textContent; + } + + return ''; + }); } }; diff --git a/core/modules/ckeditor/js/views/VisualView.es6.js b/core/modules/ckeditor/js/views/VisualView.es6.js index b680eea6e5d..b0095d9c844 100644 --- a/core/modules/ckeditor/js/views/VisualView.es6.js +++ b/core/modules/ckeditor/js/views/VisualView.es6.js @@ -67,15 +67,14 @@ this.$el .find('[data-toolbar="active"]') .toggleClass('ckeditor-group-names-are-visible', groupNamesVisible); - this.$el - .find('.ckeditor-groupnames-toggle') - .text( - groupNamesVisible + const $toggle = this.$el.find('.ckeditor-groupnames-toggle'); + $toggle + .each((index, element) => { + element.textContent = groupNamesVisible ? Drupal.t('Hide group names') - : Drupal.t('Show group names'), - ) + : Drupal.t('Show group names'); + }) .attr('aria-pressed', groupNamesVisible); - return this; }, diff --git a/core/modules/ckeditor/js/views/VisualView.js b/core/modules/ckeditor/js/views/VisualView.js index a8b06d11afb..9040038ccf8 100644 --- a/core/modules/ckeditor/js/views/VisualView.js +++ b/core/modules/ckeditor/js/views/VisualView.js @@ -34,7 +34,10 @@ } this.$el.find('[data-toolbar="active"]').toggleClass('ckeditor-group-names-are-visible', groupNamesVisible); - this.$el.find('.ckeditor-groupnames-toggle').text(groupNamesVisible ? Drupal.t('Hide group names') : Drupal.t('Show group names')).attr('aria-pressed', groupNamesVisible); + const $toggle = this.$el.find('.ckeditor-groupnames-toggle'); + $toggle.each((index, element) => { + element.textContent = groupNamesVisible ? Drupal.t('Hide group names') : Drupal.t('Show group names'); + }).attr('aria-pressed', groupNamesVisible); return this; }, diff --git a/core/modules/comment/comment-entity-form.es6.js b/core/modules/comment/comment-entity-form.es6.js index 57d5742bf2e..af54d92a9c9 100644 --- a/core/modules/comment/comment-entity-form.es6.js +++ b/core/modules/comment/comment-entity-form.es6.js @@ -17,8 +17,7 @@ Drupal.checkPlain( $(context) .find('.js-form-item-comment input:checked') - .next('label') - .text(), + .next('label')[0].textContent, ), ); }, diff --git a/core/modules/comment/comment-entity-form.js b/core/modules/comment/comment-entity-form.js index 239b13bb0ee..7b7c8b0ed64 100644 --- a/core/modules/comment/comment-entity-form.js +++ b/core/modules/comment/comment-entity-form.js @@ -9,7 +9,7 @@ Drupal.behaviors.commentFieldsetSummaries = { attach(context) { const $context = $(context); - $context.find('fieldset.comment-entity-settings-form').drupalSetSummary(context => Drupal.checkPlain($(context).find('.js-form-item-comment input:checked').next('label').text())); + $context.find('fieldset.comment-entity-settings-form').drupalSetSummary(context => Drupal.checkPlain($(context).find('.js-form-item-comment input:checked').next('label')[0].textContent)); } }; diff --git a/core/modules/comment/js/comment-new-indicator.es6.js b/core/modules/comment/js/comment-new-indicator.es6.js index ffd9efed5ef..485af485276 100644 --- a/core/modules/comment/js/comment-new-indicator.es6.js +++ b/core/modules/comment/js/comment-new-indicator.es6.js @@ -30,9 +30,9 @@ if (timestamp > lastViewTimestamp) { // Turn the placeholder into an actual "new" indicator. - const $comment = $(placeholder) + placeholder.textContent = newCommentString; + $placeholder .removeClass('hidden') - .text(newCommentString) .closest('.js-comment') // Add 'new' class to the comment, so it can be styled. .addClass('new'); @@ -41,13 +41,13 @@ // this is the first new comment in the DOM. if (isFirstNewComment) { isFirstNewComment = false; - $comment.prev().before('<a id="new"></a>'); + $placeholder.prev().before('<a id="new"></a>'); // If the URL points to the first new comment, then scroll to that // comment. if (window.location.hash === '#new') { window.scrollTo( 0, - $comment.offset().top - Drupal.displace.offsets.top, + $placeholder.offset().top - Drupal.displace.offsets.top, ); } } diff --git a/core/modules/comment/js/comment-new-indicator.js b/core/modules/comment/js/comment-new-indicator.js index 64416bd63a0..63c6ee24558 100644 --- a/core/modules/comment/js/comment-new-indicator.js +++ b/core/modules/comment/js/comment-new-indicator.js @@ -18,14 +18,15 @@ const lastViewTimestamp = Drupal.history.getLastRead(nodeID); if (timestamp > lastViewTimestamp) { - const $comment = $(placeholder).removeClass('hidden').text(newCommentString).closest('.js-comment').addClass('new'); + placeholder.textContent = newCommentString; + $placeholder.removeClass('hidden').closest('.js-comment').addClass('new'); if (isFirstNewComment) { isFirstNewComment = false; - $comment.prev().before('<a id="new"></a>'); + $placeholder.prev().before('<a id="new"></a>'); if (window.location.hash === '#new') { - window.scrollTo(0, $comment.offset().top - Drupal.displace.offsets.top); + window.scrollTo(0, $placeholder.offset().top - Drupal.displace.offsets.top); } } } diff --git a/core/modules/comment/js/node-new-comments-link.es6.js b/core/modules/comment/js/node-new-comments-link.es6.js index add49dd2946..074864b4a8e 100644 --- a/core/modules/comment/js/node-new-comments-link.es6.js +++ b/core/modules/comment/js/node-new-comments-link.es6.js @@ -115,17 +115,17 @@ function render(results) { Object.keys(results || {}).forEach((nodeID) => { if ($placeholdersToUpdate.hasOwnProperty(nodeID)) { - $placeholdersToUpdate[nodeID] - .attr('href', results[nodeID].first_new_comment_link) - .text( - Drupal.formatPlural( - results[nodeID].new_comment_count, - '1 new comment', - '@count new comments', - ), - ) + const $placeholderItem = $placeholdersToUpdate[nodeID]; + const result = results[nodeID]; + $placeholderItem[0].textContent = Drupal.formatPlural( + result.new_comment_count, + '1 new comment', + '@count new comments', + ); + $placeholderItem + .attr('href', result.first_new_comment_link) .removeClass('hidden'); - show($placeholdersToUpdate[nodeID]); + show($placeholderItem); } }); } diff --git a/core/modules/comment/js/node-new-comments-link.js b/core/modules/comment/js/node-new-comments-link.js index ebac99a578f..6577421f21d 100644 --- a/core/modules/comment/js/node-new-comments-link.js +++ b/core/modules/comment/js/node-new-comments-link.js @@ -44,8 +44,11 @@ function render(results) { Object.keys(results || {}).forEach(nodeID => { if ($placeholdersToUpdate.hasOwnProperty(nodeID)) { - $placeholdersToUpdate[nodeID].attr('href', results[nodeID].first_new_comment_link).text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments')).removeClass('hidden'); - show($placeholdersToUpdate[nodeID]); + const $placeholderItem = $placeholdersToUpdate[nodeID]; + const result = results[nodeID]; + $placeholderItem[0].textContent = Drupal.formatPlural(result.new_comment_count, '1 new comment', '@count new comments'); + $placeholderItem.attr('href', result.first_new_comment_link).removeClass('hidden'); + show($placeholderItem); } }); } diff --git a/core/modules/contextual/js/contextual.es6.js b/core/modules/contextual/js/contextual.es6.js index 1c1c485c1c3..1054b1ee78b 100644 --- a/core/modules/contextual/js/contextual.es6.js +++ b/core/modules/contextual/js/contextual.es6.js @@ -107,9 +107,14 @@ this.setAttribute('href', url + glue + destination); }); + let title = ''; + const $regionHeading = $region.find('h2'); + if ($regionHeading.length) { + title = $regionHeading[0].textContent.trim(); + } // Create a model and the appropriate views. const model = new contextual.StateModel({ - title: $region.find('h2').eq(0).text().trim(), + title, }); const viewOptions = $.extend({ el: $contextual, model }, options); contextual.views.push({ diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js index c7f5da87f6f..7ef4bc9ec58 100644 --- a/core/modules/contextual/js/contextual.js +++ b/core/modules/contextual/js/contextual.js @@ -60,8 +60,15 @@ const glue = url.indexOf('?') === -1 ? '?' : '&'; this.setAttribute('href', url + glue + destination); }); + let title = ''; + const $regionHeading = $region.find('h2'); + + if ($regionHeading.length) { + title = $regionHeading[0].textContent.trim(); + } + const model = new contextual.StateModel({ - title: $region.find('h2').eq(0).text().trim() + title }); const viewOptions = $.extend({ el: $contextual, diff --git a/core/modules/contextual/js/views/AuralView.es6.js b/core/modules/contextual/js/views/AuralView.es6.js index 5bf53904003..a0da0fb5724 100644 --- a/core/modules/contextual/js/views/AuralView.es6.js +++ b/core/modules/contextual/js/views/AuralView.es6.js @@ -35,16 +35,19 @@ this.$el.find('.contextual-links').prop('hidden', !isOpen); // Update the view of the trigger. - this.$el - .find('.trigger') - .text( - Drupal.t('@action @title configuration options', { - '@action': !isOpen - ? this.options.strings.open - : this.options.strings.close, - '@title': this.model.get('title'), - }), - ) + const $trigger = this.$el.find('.trigger'); + $trigger + .each((index, element) => { + element.textContent = Drupal.t( + '@action @title configuration options', + { + '@action': !isOpen + ? this.options.strings.open + : this.options.strings.close, + '@title': this.model.get('title'), + }, + ); + }) .attr('aria-pressed', isOpen); }, }, diff --git a/core/modules/contextual/js/views/AuralView.js b/core/modules/contextual/js/views/AuralView.js index ff936f93be8..49c8dcb265e 100644 --- a/core/modules/contextual/js/views/AuralView.js +++ b/core/modules/contextual/js/views/AuralView.js @@ -16,10 +16,13 @@ render() { const isOpen = this.model.get('isOpen'); this.$el.find('.contextual-links').prop('hidden', !isOpen); - this.$el.find('.trigger').text(Drupal.t('@action @title configuration options', { - '@action': !isOpen ? this.options.strings.open : this.options.strings.close, - '@title': this.model.get('title') - })).attr('aria-pressed', isOpen); + const $trigger = this.$el.find('.trigger'); + $trigger.each((index, element) => { + element.textContent = Drupal.t('@action @title configuration options', { + '@action': !isOpen ? this.options.strings.open : this.options.strings.close, + '@title': this.model.get('title') + }); + }).attr('aria-pressed', isOpen); } }); diff --git a/core/modules/editor/js/editor.es6.js b/core/modules/editor/js/editor.es6.js index ccff56bbd44..9aa75157486 100644 --- a/core/modules/editor/js/editor.es6.js +++ b/core/modules/editor/js/editor.es6.js @@ -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')[0].textContent, }, ); const confirmationDialog = Drupal.dialog(`<div>${message}</div>`, { diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index ed787185830..2ebcf7a528e 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -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')[0].textContent }); const confirmationDialog = Drupal.dialog(`<div>${message}</div>`, { title: Drupal.t('Change text format?'), diff --git a/core/modules/layout_builder/js/layout-builder.es6.js b/core/modules/layout_builder/js/layout-builder.es6.js index 77ab574b046..5a9112717d7 100644 --- a/core/modules/layout_builder/js/layout-builder.es6.js +++ b/core/modules/layout_builder/js/layout-builder.es6.js @@ -43,9 +43,9 @@ * The link to add the block. */ const toggleBlockEntry = (index, link) => { - const $link = $(link); - const textMatch = $link.text().toLowerCase().indexOf(query) !== -1; - $link.toggle(textMatch); + const textMatch = + link.textContent.toLowerCase().indexOf(query) !== -1; + $(link).toggle(textMatch); }; // Filter if the length of the query is at least 2 characters. diff --git a/core/modules/layout_builder/js/layout-builder.js b/core/modules/layout_builder/js/layout-builder.js index 79997c2beca..4a8af0d2960 100644 --- a/core/modules/layout_builder/js/layout-builder.js +++ b/core/modules/layout_builder/js/layout-builder.js @@ -23,9 +23,8 @@ const query = e.target.value.toLowerCase(); const toggleBlockEntry = (index, link) => { - const $link = $(link); - const textMatch = $link.text().toLowerCase().indexOf(query) !== -1; - $link.toggle(textMatch); + const textMatch = link.textContent.toLowerCase().indexOf(query) !== -1; + $(link).toggle(textMatch); }; if (query.length >= 2) { diff --git a/core/modules/locale/locale.admin.es6.js b/core/modules/locale/locale.admin.es6.js index 54e8e16daea..a0a26e2d856 100644 --- a/core/modules/locale/locale.admin.es6.js +++ b/core/modules/locale/locale.admin.es6.js @@ -79,14 +79,13 @@ $tr.toggleClass('expanded'); - // Change screen reader text. - $tr.find('.locale-translation-update__prefix').text(() => { - if ($tr.hasClass('expanded')) { - return Drupal.t('Hide description'); - } - - return Drupal.t('Show description'); - }); + const $localePrefix = $tr.find('.locale-translation-update__prefix'); + if ($localePrefix.length) { + // Change screen reader text. + $localePrefix[0].textContent = $tr.hasClass('expanded') + ? Drupal.t('Hide description') + : Drupal.t('Show description'); + } }); $table.find('.requirements, .links').hide(); } diff --git a/core/modules/locale/locale.admin.js b/core/modules/locale/locale.admin.js index cfe50643c65..9dfaa522381 100644 --- a/core/modules/locale/locale.admin.js +++ b/core/modules/locale/locale.admin.js @@ -56,13 +56,11 @@ e.preventDefault(); const $tr = $(this).closest('tr'); $tr.toggleClass('expanded'); - $tr.find('.locale-translation-update__prefix').text(() => { - if ($tr.hasClass('expanded')) { - return Drupal.t('Hide description'); - } + const $localePrefix = $tr.find('.locale-translation-update__prefix'); - return Drupal.t('Show description'); - }); + if ($localePrefix.length) { + $localePrefix[0].textContent = $tr.hasClass('expanded') ? Drupal.t('Hide description') : Drupal.t('Show description'); + } }); $table.find('.requirements, .links').hide(); } diff --git a/core/modules/media/js/type_form.es6.js b/core/modules/media/js/type_form.es6.js index 9d1906dde10..f24d52b52e6 100644 --- a/core/modules/media/js/type_form.es6.js +++ b/core/modules/media/js/type_form.es6.js @@ -22,7 +22,7 @@ .find('input[name^="options"]:checked') .parent() .each(function () { - vals.push(Drupal.checkPlain($(this).find('label').text())); + vals.push(Drupal.checkPlain($(this).find('label')[0].textContent)); }); if (!$(context).find('#edit-options-status').is(':checked')) { vals.unshift(Drupal.t('Not published')); @@ -35,18 +35,16 @@ const vals = []; vals.push( - $(context) - .find( - '.js-form-item-language-configuration-langcode select option:selected', - ) - .text(), + $(context).find( + '.js-form-item-language-configuration-langcode select option:selected', + )[0].textContent, ); $(context) .find('input:checked') .next('label') .each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); return vals.join(', '); diff --git a/core/modules/media/js/type_form.js b/core/modules/media/js/type_form.js index 6f62a15db3d..e351a6d72ba 100644 --- a/core/modules/media/js/type_form.js +++ b/core/modules/media/js/type_form.js @@ -12,7 +12,7 @@ $context.find('#edit-workflow').drupalSetSummary(context => { const vals = []; $(context).find('input[name^="options"]:checked').parent().each(function () { - vals.push(Drupal.checkPlain($(this).find('label').text())); + vals.push(Drupal.checkPlain($(this).find('label')[0].textContent)); }); if (!$(context).find('#edit-options-status').is(':checked')) { @@ -23,9 +23,9 @@ }); $(context).find('#edit-language').drupalSetSummary(context => { const vals = []; - vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected').text()); + vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected')[0].textContent); $(context).find('input:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); return vals.join(', '); }); diff --git a/core/modules/media_library/js/media_library.view.es6.js b/core/modules/media_library/js/media_library.view.es6.js index 327cf63069b..46a67c901d5 100644 --- a/core/modules/media_library/js/media_library.view.es6.js +++ b/core/modules/media_library/js/media_library.view.es6.js @@ -39,9 +39,8 @@ Drupal.announce(announcement); }, ); - const $label = $( - '<label class="media-library-select-all"></label>', - ).text(Drupal.t('Select all media')); + const $label = $('<label class="media-library-select-all"></label>'); + $label[0].textContent = Drupal.t('Select all media'); $label.prepend($checkbox); $view.find('.js-media-library-item').first().before($label); } diff --git a/core/modules/media_library/js/media_library.view.js b/core/modules/media_library/js/media_library.view.js index e3b7622c6b2..acbbc265ab0 100644 --- a/core/modules/media_library/js/media_library.view.js +++ b/core/modules/media_library/js/media_library.view.js @@ -21,7 +21,8 @@ }) : Drupal.t('Zero items selected'); Drupal.announce(announcement); }); - const $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media')); + const $label = $('<label class="media-library-select-all"></label>'); + $label[0].textContent = Drupal.t('Select all media'); $label.prepend($checkbox); $view.find('.js-media-library-item').first().before($label); } 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 9c517fe870a..afd74d656c9 100644 --- a/core/modules/media_library/js/media_library.widget.es6.js +++ b/core/modules/media_library/js/media_library.widget.es6.js @@ -44,28 +44,28 @@ show: Drupal.t('Show media item weights'), hide: Drupal.t('Hide media item weights'), }; - $( - once( - 'media-library-toggle', - '.js-media-library-widget-toggle-weight', - context, - ), - ) - .on('click', (e) => { - e.preventDefault(); - $(e.currentTarget) - .toggleClass('active') - .text( - $(e.currentTarget).hasClass('active') - ? strings.hide - : strings.show, - ) - .closest('.js-media-library-widget') - .find('.js-media-library-item-weight') - .parent() - .toggle(); - }) - .text(strings.show); + const mediaLibraryToggle = once( + 'media-library-toggle', + '.js-media-library-widget-toggle-weight', + context, + ); + $(mediaLibraryToggle).on('click', (e) => { + e.preventDefault(); + const $target = $(e.currentTarget); + e.currentTarget.textContent = $target.hasClass('active') + ? strings.show + : strings.hide; + $target + .toggleClass('active') + .closest('.js-media-library-widget') + .find('.js-media-library-item-weight') + .parent() + .toggle(); + }); + mediaLibraryToggle.forEach((item) => { + item.textContent = strings.show; + }); + $(once('media-library-toggle', '.js-media-library-item-weight', context)) .parent() .hide(); diff --git a/core/modules/media_library/js/media_library.widget.js b/core/modules/media_library/js/media_library.widget.js index c193f74183a..54546dc1409 100644 --- a/core/modules/media_library/js/media_library.widget.js +++ b/core/modules/media_library/js/media_library.widget.js @@ -29,10 +29,16 @@ show: Drupal.t('Show media item weights'), hide: Drupal.t('Hide media item weights') }; - $(once('media-library-toggle', '.js-media-library-widget-toggle-weight', context)).on('click', e => { + const mediaLibraryToggle = once('media-library-toggle', '.js-media-library-widget-toggle-weight', context); + $(mediaLibraryToggle).on('click', e => { e.preventDefault(); - $(e.currentTarget).toggleClass('active').text($(e.currentTarget).hasClass('active') ? strings.hide : strings.show).closest('.js-media-library-widget').find('.js-media-library-item-weight').parent().toggle(); - }).text(strings.show); + const $target = $(e.currentTarget); + e.currentTarget.textContent = $target.hasClass('active') ? strings.show : strings.hide; + $target.toggleClass('active').closest('.js-media-library-widget').find('.js-media-library-item-weight').parent().toggle(); + }); + mediaLibraryToggle.forEach(item => { + item.textContent = strings.show; + }); $(once('media-library-toggle', '.js-media-library-item-weight', context)).parent().hide(); } diff --git a/core/modules/menu_ui/menu_ui.admin.es6.js b/core/modules/menu_ui/menu_ui.admin.es6.js index 57607657c3f..9507b8d15ec 100644 --- a/core/modules/menu_ui/menu_ui.admin.es6.js +++ b/core/modules/menu_ui/menu_ui.admin.es6.js @@ -54,7 +54,7 @@ const selectContents = document.createElement('option'); selectContents.selected = machineName === selected; selectContents.value = machineName; - selectContents.innerText = options[machineName]; + selectContents.textContent = 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 f78d82ff82a..a590def3d33 100644 --- a/core/modules/menu_ui/menu_ui.admin.js +++ b/core/modules/menu_ui/menu_ui.admin.js @@ -42,7 +42,7 @@ const selectContents = document.createElement('option'); selectContents.selected = machineName === selected; selectContents.value = machineName; - selectContents.innerText = options[machineName]; + selectContents.textContent = options[machineName]; $select.append(selectContents); totalOptions++; }); diff --git a/core/modules/node/content_types.es6.js b/core/modules/node/content_types.es6.js index 4bb82a5c468..b7650d1ef34 100644 --- a/core/modules/node/content_types.es6.js +++ b/core/modules/node/content_types.es6.js @@ -30,7 +30,7 @@ .find('input[name^="options"]:checked') .next('label') .each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); if (!$(context).find('#edit-options-status').is(':checked')) { vals.unshift(Drupal.t('Not published')); @@ -44,13 +44,13 @@ $( '.js-form-item-language-configuration-langcode select option:selected', context, - ).text(), + )[0].textContent, ); $('input:checked', context) .next('label') .each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); return vals.join(', '); @@ -62,7 +62,7 @@ .find('input:checked') .next('label') .each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); if (!$editContext.find('#edit-display-submitted').is(':checked')) { vals.unshift(Drupal.t("Don't display post information")); diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index c66537b2187..5a87bb70b47 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -17,7 +17,7 @@ $context.find('#edit-workflow').drupalSetSummary(context => { const vals = []; $(context).find('input[name^="options"]:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); if (!$(context).find('#edit-options-status').is(':checked')) { @@ -28,9 +28,9 @@ }); $('#edit-language', context).drupalSetSummary(context => { const vals = []; - vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text()); + vals.push($('.js-form-item-language-configuration-langcode select option:selected', context)[0].textContent); $('input:checked', context).next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); return vals.join(', '); }); @@ -38,7 +38,7 @@ const vals = []; const $editContext = $(context); $editContext.find('input:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); + vals.push(Drupal.checkPlain(this.textContent)); }); if (!$editContext.find('#edit-display-submitted').is(':checked')) { diff --git a/core/modules/node/node.es6.js b/core/modules/node/node.es6.js index 23e6cb44158..c9ed55068d3 100644 --- a/core/modules/node/node.es6.js +++ b/core/modules/node/node.es6.js @@ -45,7 +45,7 @@ .find('input:checked') .next('label') .each(function () { - vals.push(Drupal.checkPlain($(this).text().trim())); + vals.push(Drupal.checkPlain(this.textContent.trim())); }); return vals.join(', '); } diff --git a/core/modules/node/node.js b/core/modules/node/node.js index a31756ca98e..a92c5bb6f1f 100644 --- a/core/modules/node/node.js +++ b/core/modules/node/node.js @@ -40,7 +40,7 @@ if ($optionsContext.find('input').is(':checked')) { $optionsContext.find('input:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text().trim())); + vals.push(Drupal.checkPlain(this.textContent.trim())); }); return vals.join(', '); } diff --git a/core/modules/quickedit/js/editors/plainTextEditor.es6.js b/core/modules/quickedit/js/editors/plainTextEditor.es6.js index a7d99f90d8b..a951015127e 100644 --- a/core/modules/quickedit/js/editors/plainTextEditor.es6.js +++ b/core/modules/quickedit/js/editors/plainTextEditor.es6.js @@ -30,12 +30,15 @@ const $fieldItems = this.$el.find('.quickedit-field'); const $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el; this.$textElement = $textElement; - editorModel.set('originalValue', this.$textElement.text().trim()); + editorModel.set( + 'originalValue', + this.$textElement[0].textContent.trim(), + ); // Sets the state to 'changed' whenever the value changes. let previousText = editorModel.get('originalValue'); $textElement.on('keyup paste', (event) => { - const currentText = $textElement.text().trim(); + const currentText = $textElement[0].textContent.trim(); if (previousText !== currentText) { previousText = currentText; editorModel.set('currentValue', currentText); diff --git a/core/modules/quickedit/js/editors/plainTextEditor.js b/core/modules/quickedit/js/editors/plainTextEditor.js index 90bc75f44a5..7f386d4e4e3 100644 --- a/core/modules/quickedit/js/editors/plainTextEditor.js +++ b/core/modules/quickedit/js/editors/plainTextEditor.js @@ -16,10 +16,10 @@ const $fieldItems = this.$el.find('.quickedit-field'); const $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el; this.$textElement = $textElement; - editorModel.set('originalValue', this.$textElement.text().trim()); + editorModel.set('originalValue', this.$textElement[0].textContent.trim()); let previousText = editorModel.get('originalValue'); $textElement.on('keyup paste', event => { - const currentText = $textElement.text().trim(); + const currentText = $textElement[0].textContent.trim(); if (previousText !== currentText) { previousText = currentText; diff --git a/core/modules/quickedit/js/views/ContextualLinkView.es6.js b/core/modules/quickedit/js/views/ContextualLinkView.es6.js index 9b8725677c7..a9f0e2b5e7f 100644 --- a/core/modules/quickedit/js/views/ContextualLinkView.es6.js +++ b/core/modules/quickedit/js/views/ContextualLinkView.es6.js @@ -46,7 +46,9 @@ */ initialize(options) { // Insert the text of the quick edit toggle. - this.$el.find('a').text(options.strings.quickEdit); + this.$el.find('a').each((index, element) => { + element.textContent = options.strings.quickEdit; + }); // Initial render. this.render(); // Re-render whenever this entity's isActive attribute changes. diff --git a/core/modules/quickedit/js/views/ContextualLinkView.js b/core/modules/quickedit/js/views/ContextualLinkView.js index 8a22b6030d4..3df24887bba 100644 --- a/core/modules/quickedit/js/views/ContextualLinkView.js +++ b/core/modules/quickedit/js/views/ContextualLinkView.js @@ -23,7 +23,9 @@ }, initialize(options) { - this.$el.find('a').text(options.strings.quickEdit); + this.$el.find('a').each((index, element) => { + element.textContent = options.strings.quickEdit; + }); this.render(); this.listenTo(this.model, 'change:isActive', this.render); }, diff --git a/core/modules/quickedit/js/views/EntityToolbarView.es6.js b/core/modules/quickedit/js/views/EntityToolbarView.es6.js index b5152ef6960..d559b9fdba9 100644 --- a/core/modules/quickedit/js/views/EntityToolbarView.es6.js +++ b/core/modules/quickedit/js/views/EntityToolbarView.es6.js @@ -127,18 +127,18 @@ case 'opened': // The saving throbber is not managed by AJAX system. The // EntityToolbarView manages this visual element. + $button[0].textContent = Drupal.t('Save'); $button .removeClass('action-saving icon-throbber icon-end') - .text(Drupal.t('Save')) .removeAttr('disabled') .attr('aria-hidden', !isDirty); break; // The changes to the fields of the entity are being committed. case 'committing': + $button[0].textContent = Drupal.t('Saving'); $button .addClass('action-saving icon-throbber icon-end') - .text(Drupal.t('Saving')) .attr('disabled', 'disabled'); break; diff --git a/core/modules/quickedit/js/views/EntityToolbarView.js b/core/modules/quickedit/js/views/EntityToolbarView.js index 9b54675b322..a204c87dae2 100644 --- a/core/modules/quickedit/js/views/EntityToolbarView.js +++ b/core/modules/quickedit/js/views/EntityToolbarView.js @@ -59,11 +59,13 @@ switch (this.model.get('state')) { case 'opened': - $button.removeClass('action-saving icon-throbber icon-end').text(Drupal.t('Save')).removeAttr('disabled').attr('aria-hidden', !isDirty); + $button[0].textContent = Drupal.t('Save'); + $button.removeClass('action-saving icon-throbber icon-end').removeAttr('disabled').attr('aria-hidden', !isDirty); break; case 'committing': - $button.addClass('action-saving icon-throbber icon-end').text(Drupal.t('Saving')).attr('disabled', 'disabled'); + $button[0].textContent = Drupal.t('Saving'); + $button.addClass('action-saving icon-throbber icon-end').attr('disabled', 'disabled'); break; default: diff --git a/core/modules/settings_tray/js/settings_tray.es6.js b/core/modules/settings_tray/js/settings_tray.es6.js index 448c0934db7..7deaada89fa 100644 --- a/core/modules/settings_tray/js/settings_tray.es6.js +++ b/core/modules/settings_tray/js/settings_tray.es6.js @@ -74,11 +74,13 @@ ); } editMode = !!editMode; - const $editButton = $(toggleEditSelector); let $editables; + const editButton = document.querySelector(toggleEditSelector); // Turn on edit mode. if (editMode) { - $editButton.text(Drupal.t('Editing')); + if (editButton) { + editButton.textContent = Drupal.t('Editing'); + } closeToolbarTrays(); $editables = $( @@ -142,8 +144,9 @@ $editables.off('.settingstray'); $(quickEditItemSelector).off('.settingstray'); } - - $editButton.text(Drupal.t('Edit')); + if (editButton) { + editButton.textContent = Drupal.t('Edit'); + } closeOffCanvas(); disableQuickEdit(); } diff --git a/core/modules/settings_tray/js/settings_tray.js b/core/modules/settings_tray/js/settings_tray.js index 14635c670a3..773664e9bc2 100644 --- a/core/modules/settings_tray/js/settings_tray.js +++ b/core/modules/settings_tray/js/settings_tray.js @@ -42,11 +42,14 @@ } editMode = !!editMode; - const $editButton = $(toggleEditSelector); let $editables; + const editButton = document.querySelector(toggleEditSelector); if (editMode) { - $editButton.text(Drupal.t('Editing')); + if (editButton) { + editButton.textContent = Drupal.t('Editing'); + } + closeToolbarTrays(); $editables = $(once('settingstray', '[data-drupal-settingstray="editable"]')); @@ -81,7 +84,10 @@ $(quickEditItemSelector).off('.settingstray'); } - $editButton.text(Drupal.t('Edit')); + if (editButton) { + editButton.textContent = Drupal.t('Edit'); + } + closeOffCanvas(); disableQuickEdit(); } diff --git a/core/modules/system/js/system.date.es6.js b/core/modules/system/js/system.date.es6.js index 8412bd07f02..2ea0af1d95a 100644 --- a/core/modules/system/js/system.date.es6.js +++ b/core/modules/system/js/system.date.es6.js @@ -32,9 +32,6 @@ return; } - const $target = $(target); - const $preview = $target.find('em'); - /** * Event handler that replaces date characters with value. * @@ -47,8 +44,14 @@ dateFormats[key] ? dateFormats[key] : value, ); - $preview.text(dateString); - $target.toggleClass('js-hide', !dateString.length); + // Set date preview. + target.forEach((item) => { + item.querySelectorAll('em').forEach((em) => { + em.textContent = dateString; + }); + }); + + $(target).toggleClass('js-hide', !dateString.length); } /** diff --git a/core/modules/system/js/system.date.js b/core/modules/system/js/system.date.js index e742395ea23..586fca6adff 100644 --- a/core/modules/system/js/system.date.js +++ b/core/modules/system/js/system.date.js @@ -16,14 +16,15 @@ return; } - const $target = $(target); - const $preview = $target.find('em'); - function dateFormatHandler(e) { 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); + target.forEach(item => { + item.querySelectorAll('em').forEach(em => { + em.textContent = dateString; + }); + }); + $(target).toggleClass('js-hide', !dateString.length); } $(source).on('keyup.dateFormat change.dateFormat input.dateFormat', dateFormatHandler).trigger('keyup'); diff --git a/core/modules/system/js/system.modules.es6.js b/core/modules/system/js/system.modules.es6.js index 632d9758de4..f46b1226dcd 100644 --- a/core/modules/system/js/system.modules.es6.js +++ b/core/modules/system/js/system.modules.es6.js @@ -40,12 +40,16 @@ const re = new RegExp(`\\b${query}`, 'i'); function showModuleRow(index, row) { - const $row = $(row); - const $sources = $row.find( + const sources = row.querySelectorAll( '.table-filter-text-source, .module-name, .module-description', ); - const textMatch = $sources.text().search(re) !== -1; - $row.closest('tr').toggle(textMatch); + let sourcesConcat = ''; + // Concatenate the textContent of the elements in the row. + sources.forEach((item) => { + sourcesConcat += item.textContent; + }); + const textMatch = sourcesConcat.search(re) !== -1; + $(row).closest('tr').toggle(textMatch); } // Search over all rows and packages. $rowsAndDetails.show(); diff --git a/core/modules/system/js/system.modules.js b/core/modules/system/js/system.modules.js index 98f53c683bc..fb19695e9fd 100644 --- a/core/modules/system/js/system.modules.js +++ b/core/modules/system/js/system.modules.js @@ -31,10 +31,13 @@ const re = new RegExp(`\\b${query}`, 'i'); function showModuleRow(index, row) { - const $row = $(row); - const $sources = $row.find('.table-filter-text-source, .module-name, .module-description'); - const textMatch = $sources.text().search(re) !== -1; - $row.closest('tr').toggle(textMatch); + const sources = row.querySelectorAll('.table-filter-text-source, .module-name, .module-description'); + let sourcesConcat = ''; + sources.forEach(item => { + sourcesConcat += item.textContent; + }); + const textMatch = sourcesConcat.search(re) !== -1; + $(row).closest('tr').toggle(textMatch); } $rowsAndDetails.show(); diff --git a/core/modules/system/system.libraries.yml b/core/modules/system/system.libraries.yml index 135b004a9d7..7ccd963b8eb 100644 --- a/core/modules/system/system.libraries.yml +++ b/core/modules/system/system.libraries.yml @@ -62,6 +62,7 @@ drupal.system.modules: - core/jquery - core/drupal - core/drupal.debounce + - core/drupal.nodelist.foreach - core/once - core/jquery.once.bc - core/drupal.announce @@ -79,6 +80,7 @@ drupal.system.date: dependencies: - core/jquery - core/drupal + - core/drupal.nodelist.foreach - core/drupalSettings - core/once - core/jquery.once.bc diff --git a/core/modules/toolbar/js/escapeAdmin.es6.js b/core/modules/toolbar/js/escapeAdmin.es6.js index e4eda0363ed..30af90bd36c 100644 --- a/core/modules/toolbar/js/escapeAdmin.es6.js +++ b/core/modules/toolbar/js/escapeAdmin.es6.js @@ -34,11 +34,10 @@ attach() { const toolbarEscape = once('escapeAdmin', '[data-toolbar-escape-admin]'); if (toolbarEscape.length && pathInfo.currentPathIsAdmin) { - const $toolbarEscape = $(toolbarEscape); if (escapeAdminPath !== null) { - $toolbarEscape.attr('href', escapeAdminPath); + $(toolbarEscape).attr('href', escapeAdminPath); } else { - $toolbarEscape.text(Drupal.t('Home')); + toolbarEscape[0].textContent = Drupal.t('Home'); } } }, diff --git a/core/modules/toolbar/js/escapeAdmin.js b/core/modules/toolbar/js/escapeAdmin.js index d0a139bb251..151fff189fd 100644 --- a/core/modules/toolbar/js/escapeAdmin.js +++ b/core/modules/toolbar/js/escapeAdmin.js @@ -19,12 +19,10 @@ const toolbarEscape = once('escapeAdmin', '[data-toolbar-escape-admin]'); if (toolbarEscape.length && pathInfo.currentPathIsAdmin) { - const $toolbarEscape = $(toolbarEscape); - if (escapeAdminPath !== null) { - $toolbarEscape.attr('href', escapeAdminPath); + $(toolbarEscape).attr('href', escapeAdminPath); } else { - $toolbarEscape.text(Drupal.t('Home')); + toolbarEscape[0].textContent = Drupal.t('Home'); } } } diff --git a/core/modules/toolbar/js/toolbar.menu.es6.js b/core/modules/toolbar/js/toolbar.menu.es6.js index d80c0a49c19..56d6776a55a 100644 --- a/core/modules/toolbar/js/toolbar.menu.es6.js +++ b/core/modules/toolbar/js/toolbar.menu.es6.js @@ -41,10 +41,10 @@ // Twist the toggle. $toggle.toggleClass('open', switcher); // Adjust the toggle text. - $toggle - .find('.action') + $toggle.find('.action').each((index, element) => { // Expand Structure, Collapse Structure. - .text(switcher ? ui.handleClose : ui.handleOpen); + element.textContent = switcher ? ui.handleClose : ui.handleOpen; + }); } /** @@ -107,8 +107,9 @@ const $item = $(element); if ($item.children('ul.toolbar-menu').length) { const $box = $item.children('.toolbar-box'); + const $link = $box.find('a'); options.text = Drupal.t('@label', { - '@label': $box.find('a').text(), + '@label': $link.length ? $link[0].textContent : '', }); $item .children('.toolbar-box') diff --git a/core/modules/toolbar/js/toolbar.menu.js b/core/modules/toolbar/js/toolbar.menu.js index ca9031baf35..1b8d4b5045e 100644 --- a/core/modules/toolbar/js/toolbar.menu.js +++ b/core/modules/toolbar/js/toolbar.menu.js @@ -19,7 +19,9 @@ switcher = typeof switcher !== 'undefined' ? switcher : !$item.hasClass('open'); $item.toggleClass('open', switcher); $toggle.toggleClass('open', switcher); - $toggle.find('.action').text(switcher ? ui.handleClose : ui.handleOpen); + $toggle.find('.action').each((index, element) => { + element.textContent = switcher ? ui.handleClose : ui.handleOpen; + }); } function toggleClickHandler(event) { @@ -50,8 +52,9 @@ if ($item.children('ul.toolbar-menu').length) { const $box = $item.children('.toolbar-box'); + const $link = $box.find('a'); options.text = Drupal.t('@label', { - '@label': $box.find('a').text() + '@label': $link.length ? $link[0].textContent : '' }); $item.children('.toolbar-box').append(Drupal.theme('toolbarMenuItemToggle', options)); } diff --git a/core/modules/toolbar/js/views/ToolbarVisualView.es6.js b/core/modules/toolbar/js/views/ToolbarVisualView.es6.js index 1f63d054459..87c8fc5b3ff 100644 --- a/core/modules/toolbar/js/views/ToolbarVisualView.es6.js +++ b/core/modules/toolbar/js/views/ToolbarVisualView.es6.js @@ -292,9 +292,9 @@ $orientationToggleButton[0].value = antiOrientation; $orientationToggleButton .attr('title', this.strings[antiOrientation]) - .text(this.strings[antiOrientation]) .removeClass(iconClass) .addClass(iconAntiClass); + $orientationToggleButton[0].textContent = this.strings[antiOrientation]; // Update data offset attributes for the trays. const dir = document.documentElement.dir; diff --git a/core/modules/toolbar/js/views/ToolbarVisualView.js b/core/modules/toolbar/js/views/ToolbarVisualView.js index 3c5d4c77769..49f523c3094 100644 --- a/core/modules/toolbar/js/views/ToolbarVisualView.js +++ b/core/modules/toolbar/js/views/ToolbarVisualView.js @@ -146,7 +146,8 @@ const $orientationToggle = this.$el.find('.toolbar-toggle-orientation').toggle(this.model.get('isTrayToggleVisible')); const $orientationToggleButton = $orientationToggle.find('button'); $orientationToggleButton[0].value = antiOrientation; - $orientationToggleButton.attr('title', this.strings[antiOrientation]).text(this.strings[antiOrientation]).removeClass(iconClass).addClass(iconAntiClass); + $orientationToggleButton.attr('title', this.strings[antiOrientation]).removeClass(iconClass).addClass(iconAntiClass); + $orientationToggleButton[0].textContent = this.strings[antiOrientation]; 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/views_ui/js/ajax.es6.js b/core/modules/views_ui/js/ajax.es6.js index e98be85b817..9448f513291 100644 --- a/core/modules/views_ui/js/ajax.es6.js +++ b/core/modules/views_ui/js/ajax.es6.js @@ -144,8 +144,9 @@ re, `${response.title} $1 ${response.siteName}`, ); - - $('h1.page-title').text(response.title); + document.querySelectorAll('h1.page-title').forEach((item) => { + item.textContent = response.title; + }); }; /** diff --git a/core/modules/views_ui/js/ajax.js b/core/modules/views_ui/js/ajax.js index c467facc5bd..265684a5eed 100644 --- a/core/modules/views_ui/js/ajax.js +++ b/core/modules/views_ui/js/ajax.js @@ -50,7 +50,9 @@ const escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); const re = new RegExp(`.+ (.) ${escapedSiteName}`); doc.title = oldTitle.replace(re, `${response.title} $1 ${response.siteName}`); - $('h1.page-title').text(response.title); + document.querySelectorAll('h1.page-title').forEach(item => { + item.textContent = response.title; + }); }; Drupal.theme.tableDragChangedWarning = function () { diff --git a/core/modules/views_ui/js/views-admin.es6.js b/core/modules/views_ui/js/views-admin.es6.js index b29af12a412..76896746d5d 100644 --- a/core/modules/views_ui/js/views-admin.es6.js +++ b/core/modules/views_ui/js/views-admin.es6.js @@ -537,8 +537,7 @@ $description = $option.find('.description'); options[i] = { // Search on the lowercase version of the title text + description. - searchText: `${$title.text().toLowerCase()} ${$description - .text() + searchText: `${$title[0].textContent.toLowerCase()} ${$description[0].textContent.toLowerCase()} .toLowerCase()}`, // Maintain a reference to the jQuery object for each row, so we don't // have to create a new object inside the performance-sensitive keyup diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 99583f75ed1..03cd48e9363 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -255,7 +255,8 @@ $title = $option.find('.title'); $description = $option.find('.description'); options[i] = { - searchText: `${$title.text().toLowerCase()} ${$description.text().toLowerCase()}`, + searchText: `${$title[0].textContent.toLowerCase()} ${$description[0].textContent.toLowerCase()} + .toLowerCase()}`, $div: $option }; } 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 8a9f3195e54..24bafde92a2 100644 --- a/core/modules/views_ui/js/views_ui.listing.es6.js +++ b/core/modules/views_ui/js/views_ui.listing.es6.js @@ -29,12 +29,15 @@ const query = e.target.value.toLowerCase(); function showViewRow(index, row) { - const $row = $(row); - const $sources = $row.find( + const sources = row.querySelectorAll( '[data-drupal-selector="views-table-filter-text-source"]', ); - const textMatch = $sources.text().toLowerCase().indexOf(query) !== -1; - $row.closest('tr').toggle(textMatch); + let sourcesConcat = ''; + sources.forEach((item) => { + sourcesConcat += item.textContent; + }); + const textMatch = sourcesConcat.toLowerCase().indexOf(query) !== -1; + $(row).closest('tr').toggle(textMatch); } // Filter if the length of the query is at least 2 characters. diff --git a/core/modules/views_ui/js/views_ui.listing.js b/core/modules/views_ui/js/views_ui.listing.js index 6a816590660..43be02e3e73 100644 --- a/core/modules/views_ui/js/views_ui.listing.js +++ b/core/modules/views_ui/js/views_ui.listing.js @@ -21,10 +21,13 @@ const query = e.target.value.toLowerCase(); function showViewRow(index, row) { - const $row = $(row); - const $sources = $row.find('[data-drupal-selector="views-table-filter-text-source"]'); - const textMatch = $sources.text().toLowerCase().indexOf(query) !== -1; - $row.closest('tr').toggle(textMatch); + const sources = row.querySelectorAll('[data-drupal-selector="views-table-filter-text-source"]'); + let sourcesConcat = ''; + sources.forEach(item => { + sourcesConcat += item.textContent; + }); + const textMatch = sourcesConcat.toLowerCase().indexOf(query) !== -1; + $(row).closest('tr').toggle(textMatch); } if (query.length >= 2) { diff --git a/core/modules/views_ui/views_ui.libraries.yml b/core/modules/views_ui/views_ui.libraries.yml index 2cdea8edbd5..086f6917302 100644 --- a/core/modules/views_ui/views_ui.libraries.yml +++ b/core/modules/views_ui/views_ui.libraries.yml @@ -14,6 +14,7 @@ views_ui.admin: - core/drupal.form - core/drupal.ajax - core/drupal.dropbutton + - core/drupal.nodelist.foreach - views/views.ajax - views_ui/admin.styling @@ -24,6 +25,7 @@ views_ui.listing: dependencies: - core/jquery - core/drupal + - core/drupal.string.includes - core/once - core/jquery.once.bc - views_ui/admin.styling |