diff --git a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
index 2f09464..af0cf14 100644
--- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
+++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php
@@ -125,7 +125,7 @@ public function setDialogTitle($title) {
   public function render() {
     // Add the library for handling the dialog in the response.
     $attached['#attached']['library'][] = array('system', 'drupal.dialog.ajax');
-    drupal_render($attached);
+    $this->drupalRender($attached);
 
 
     // For consistency ensure the modal option is set to TRUE or FALSE.
@@ -138,4 +138,18 @@ public function render() {
       'dialogOptions' => $this->dialogOptions,
     );
   }
+
+  /**
+   * Wraps drupal_render.
+   *
+   * @param array $elements
+   *   The structured array describing the data to be rendered.
+   *
+   * @return string
+   *   The rendered HTML.
+   */
+  protected function drupalRender(array $elements) {
+    return drupal_render($elements);
+  }
+
 }
diff --git a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php
index 307d63f..55f07e6 100644
--- a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php
+++ b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php
@@ -131,7 +131,7 @@ public function ajaxView(Request $request) {
         $view->dom_id = $dom_id;
 
         $preview = $view->preview($display_id, $args);
-        $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", drupal_render($preview)));
+        $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", $this->drupalRender($preview)));
         return $response;
       }
       else {
@@ -143,4 +143,17 @@ public function ajaxView(Request $request) {
     }
   }
 
+  /**
+   * Wraps drupal_render.
+   *
+   * @param array $elements
+   *   The structured array describing the data to be rendered.
+   *
+   * @return string
+   *   The rendered HTML.
+   */
+  protected function drupalRender(array $elements) {
+    return drupal_render($elements);
+  }
+
 }
diff --git a/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php
index 05cbbaf..4521053 100644
--- a/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php
+++ b/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php
@@ -58,7 +58,7 @@ protected function setUp() {
       ->disableOriginalConstructor()
       ->getMock();
 
-    $this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory);
+    $this->viewAjaxController = new TestViewAjaxController($this->viewStorage, $this->executableFactory);
   }
 
   /**
@@ -172,6 +172,15 @@ protected function setupValidMocks() {
 
 }
 
+class TestViewAjaxController extends ViewAjaxController {
+
+  // @todo Remove once drupal_render is converted to autoloadable code.
+  protected function drupalRender(array $elements) {
+    return isset($elements['#markup']) ? $elements['#markup'] : (string) $elements;
+  }
+
+}
+
 }
 
 namespace {
@@ -182,11 +191,4 @@ function &drupal_static($key) {
     }
   }
 
-  // @todo Remove once drupal_render is converted to autoloadable code.
-  if (!function_exists('drupal_render')) {
-    function drupal_render($array) {
-      return isset($array['#markup']) ? $array['#markup'] : (string) $array;
-    }
-  }
-
 }
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
index bd6b27d..7c892e0 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
@@ -308,7 +308,7 @@ public function testSettingsCommand() {
    * Tests that OpenDialogCommand objects can be constructed and rendered.
    */
   public function testOpenDialogCommand() {
-    $command = new OpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', array(
+    $command = new TestOpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', array(
       'url' => FALSE,
       'width' => 500,
     ));
@@ -332,7 +332,7 @@ public function testOpenDialogCommand() {
    * Tests that OpenModalDialogCommand objects can be constructed and rendered.
    */
   public function testOpenModalDialogCommand() {
-    $command = new OpenModalDialogCommand('Title', '<p>Text!</p>', array(
+    $command = new TestOpenModalDialogCommand('Title', '<p>Text!</p>', array(
       'url' => 'example',
       'width' => 500,
     ));
@@ -424,3 +424,19 @@ public function testRedirectCommand() {
   }
 
 }
+
+class TestOpenModalDialogCommand extends OpenModalDialogCommand {
+
+  protected function drupalRender(array $elements) {
+    return '';
+  }
+
+}
+
+class TestOpenDialogCommand extends OpenDialogCommand {
+
+  protected function drupalRender(array $elements) {
+    return '';
+  }
+
+}
