Commit e25acf2c authored by alexpott's avatar alexpott

Issue #2141417 by babruix, Sam152, jessebeach: Trays without headings throw a...

Issue #2141417 by babruix, Sam152, jessebeach: Trays without headings throw a JavaScript error when the non-existent heading text is accessed
parent 1a73d7e6
......@@ -44,13 +44,16 @@
*/
onActiveTrayChange: function (model, tray) {
var relevantTray = (tray === null) ? model.previous('activeTray') : tray;
var trayName = relevantTray.querySelector('.toolbar-tray-name').textContent;
var action = (tray === null) ? Drupal.t('closed') : Drupal.t('opened');
var trayNameElement = relevantTray.querySelector('.toolbar-tray-name');
var text;
if (tray === null) {
text = Drupal.t('Tray "@tray" closed.', { '@tray': trayName });
if (trayNameElement !== null) {
text = Drupal.t('Tray "@tray" @action.', {
'@tray': trayNameElement.textContent, '@action': action
});
}
else {
text = Drupal.t('Tray "@tray" opened.', { '@tray': trayName });
text = Drupal.t('Tray @action.', {'@action': action});
}
Drupal.announce(text);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment