Pointless code: String return value from onbeforeunload

Created on 20 February 2024, 9 months ago

Problem/Motivation

The string return is pointless, instead it can return true or false or I think anything other than null or undefined.

      // Handle backbutton, exit etc.
      window.onbeforeunload = function() {
        // Add CKEditor support.
        if (typeof (CKEDITOR) != 'undefined' && typeof (CKEDITOR.instances) != 'undefined') {
          for (var i in CKEDITOR.instances) {
            if (CKEDITOR.instances[i].checkDirty()) {
              edit = true;
              break;
            }
          }
        }
        if (edit && !click) {
          click = false;
          return (Drupal.t("You will lose all unsaved work."));
        }
      }

Also this code can be moved out of the Drupal.behavior.*.attach function.

Steps to reproduce

Let the function return true instead of Drupal.t('...').
AND/OR
Move the function outside of the behavior attach function.

The behavior will not change.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇩🇪Germany donquixote

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024