diff --git a/core/modules/system/src/Tests/Ajax/FrameworkTest.php b/core/modules/system/src/Tests/Ajax/FrameworkTest.php index c7ccd8b..7b78b5c 100644 --- a/core/modules/system/src/Tests/Ajax/FrameworkTest.php +++ b/core/modules/system/src/Tests/Ajax/FrameworkTest.php @@ -216,4 +216,14 @@ public function testLazyLoadOverriddenCSS() { // cache control. $this->assertNoText('system.module.css?', 'Ajax lazy loading does not add overridden CSS files.'); } + + /** + * Tests if the 'theme_token' key of 'ajaxPageState' is computed. + */ + public function testThemeToken() { + $this->drupalGet('ajax_forms_test_lazy_load_form'); + $settings = $this->getDrupalSettings(); + $this->assertTrue(is_null($settings['ajaxPageState']['theme_token'])); + } + } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index b0420c1..314ec39 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -691,9 +691,10 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) { // The theme token is only validated when the theme requested is not the // default, so don't generate it unless necessary. // @see \Drupal\Core\Theme\AjaxBasePageNegotiator::determineActiveTheme() - if (\Drupal::theme()->getActiveTheme()->getName() !== \Drupal::service('theme_handler')->getDefault()) { + $active_theme_key = \Drupal::theme()->getActiveTheme()->getName(); + if ($active_theme_key !== \Drupal::service('theme_handler')->getDefault()) { $settings['ajaxPageState']['theme_token'] = \Drupal::csrfToken() - ->get(\Drupal::theme()->getActiveTheme()->getName()); + ->get($active_theme_key); } } }