diff --git a/docroot/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/docroot/core/lib/Drupal/Core/Theme/ThemeInitialization.php
index d4e1d95..bdf5d74 100644
--- a/docroot/core/lib/Drupal/Core/Theme/ThemeInitialization.php
+++ b/docroot/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -88,8 +88,8 @@ public function getActiveThemeByName($theme_name) {
     $base_themes = array();
     $ancestor = $theme_name;
     while ($ancestor && isset($themes[$ancestor]->base_theme)) {
-      $ancestor = $themes[$ancestor]->base_theme;
       $base_themes[] = $themes[$ancestor];
+      $ancestor = $themes[$ancestor]->base_theme;
     }
 
     $active_theme = $this->getActiveTheme($themes[$theme_name], $base_themes);
