diff --git a/core/includes/common.inc b/core/includes/common.inc index 0c16ac9..133863f 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3711,6 +3711,14 @@ function drupal_add_js($data = NULL, $options = NULL) { 'pathPrefix' => $pathPrefix, 'currentPath' => current_path(), ); + // Expose errors in Drupal behaviors, unless error reporting is + // disabled. + $error_level = config('system.logging')->get('error_level'); + if (!empty($error_level) && $error_level != 'hide') { + $javascript['settings']['data'][] = array( + 'errors' => 1, + ); + } } // All JavaScript settings are placed in the header of the page with // the library weight so that inline scripts appear afterwards. diff --git a/core/misc/drupal.js b/core/misc/drupal.js index 627e264..eb034c0 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -79,6 +79,11 @@ Drupal.attachBehaviors = function (context, settings) { // Execute all of them. for (i in behaviors) { if (behaviors.hasOwnProperty(i) && typeof behaviors[i].attach === 'function') { + // If errors are not hidden, execute behaviors directly. + if (settings.errors) { + behaviors[i].attach(context, settings); + continue; + } // Don't stop the execution of behaviors in case of an error. try { behaviors[i].attach(context, settings); @@ -142,6 +147,11 @@ Drupal.detachBehaviors = function (context, settings, trigger) { // Execute all of them. for (i in behaviors) { if (behaviors.hasOwnProperty(i) && typeof behaviors[i].detach === 'function' ) { + // If errors are not hidden, execute behaviors directly. + if (settings.errors) { + behaviors[i].detach(context, settings, trigger); + continue; + } // Don't stop the execution of behaviors in case of an error. try { behaviors[i].detach(context, settings, trigger); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 17015c6..dbf1fd8 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1220,6 +1220,7 @@ function system_library_info() { ), 'dependencies' => array( array('system', 'jquery'), + array('system', 'drupalSettings'), ), );