diff --git a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php
index 261cedf..a012741 100644
--- a/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php
+++ b/core/lib/Drupal/Core/Theme/AjaxBasePageNegotiator.php
@@ -67,17 +67,14 @@ public function __construct(CsrfTokenGenerator $token_generator, ConfigFactoryIn
    * {@inheritdoc}
    */
   public function applies(RouteMatchInterface $route_match) {
-    // Check whether the route was configured to use the base page theme.
-    return ($route = $route_match->getRouteObject())
-      && $route->hasOption('_theme')
-      && $route->getOption('_theme') == 'ajax_base_page';
+    return ($ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state')) && !empty($ajax_page_state['theme']) && isset($ajax_page_state['theme_token']);
   }
 
   /**
    * {@inheritdoc}
    */
   public function determineActiveTheme(RouteMatchInterface $route_match) {
-    if (($ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state'))  && !empty($ajax_page_state['theme']) && !empty($ajax_page_state['theme_token'])) {
+    if ($ajax_page_state = $this->requestStack->getCurrentRequest()->request->get('ajax_page_state')) {
       $theme = $ajax_page_state['theme'];
       $token = $ajax_page_state['theme_token'];
 
