summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/toolbar/js/toolbar.menu.js
diff options
context:
space:
mode:
authorLauri Eskola <lauri.eskola@acquia.com>2022-01-28 11:53:59 +0200
committerLauri Eskola <lauri.eskola@acquia.com>2022-01-28 11:53:59 +0200
commit8c62a32c2da35b38d60a7930863a65ae820b41b4 (patch)
tree7b1ccfc0bf843e8d1ddbc7b49a0d4dcdfe51dc09 /core/modules/toolbar/js/toolbar.menu.js
parent6b8783b23aece75da1cbc6eb59f1d2c6adfad2a1 (diff)
downloaddrupal-8c62a32c2da35b38d60a7930863a65ae820b41b4.tar.gz
drupal-8c62a32c2da35b38d60a7930863a65ae820b41b4.zip
Issue #3239123 by hooroomoo, bnjmnm, nod_: Refactor (if feasible) uses of the jQuery text function to use vanillaJS
Diffstat (limited to 'core/modules/toolbar/js/toolbar.menu.js')
-rw-r--r--core/modules/toolbar/js/toolbar.menu.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/modules/toolbar/js/toolbar.menu.js b/core/modules/toolbar/js/toolbar.menu.js
index ca9031baf356..1b8d4b5045ef 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));
}