diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 6dc067f326..7141192ccd 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -19,7 +19,6 @@ loadjs, { isFocusable, tabbable }, ) { - /** * Attaches the Ajax behavior to each Ajax form element. * @@ -549,7 +548,8 @@ return ajax.beforeSend(xmlhttprequest, options); }, success(response, status, xmlhttprequest) { - ajax.preCommandsFocusedElementSelector = document.activeElement.getAttribute('data-drupal-selector'); + ajax.preCommandsFocusedElementSelector = + document.activeElement.getAttribute('data-drupal-selector'); // Sanity check for browser support (object expected). // When using iFrame uploads, responses must be returned as a string. @@ -1097,13 +1097,20 @@ if (!focusChanged) { let target = false; if (this.element) { - if ($(this.element).data('refocus-previous') && this.preCommandsFocusedElementSelector) { + if ( + $(this.element).data('refocus-previous') && + this.preCommandsFocusedElementSelector + ) { target = document.querySelector( `[data-drupal-selector="${this.preCommandsFocusedElementSelector}"]`, ); } if (!target && !$(this.element).data('disable-refocus')) { - for (let n = elementParents.length - 1; !target && n >= 0; n--) { + for ( + let n = elementParents.length - 1; + !target && n >= 0; + n-- + ) { target = document.querySelector( `[data-drupal-selector="${elementParents[n].getAttribute( 'data-drupal-selector',