diff --git a/core/modules/views/src/Tests/Plugin/StyleTestBase.php b/core/modules/views/src/Tests/Plugin/StyleTestBase.php
index 8bc328c..b5f729c 100644
--- a/core/modules/views/src/Tests/Plugin/StyleTestBase.php
+++ b/core/modules/views/src/Tests/Plugin/StyleTestBase.php
@@ -8,6 +8,7 @@
 namespace Drupal\views\Tests\Plugin;

 use Drupal\views\Tests\ViewUnitTestBase;
+use Masterminds\HTML5;

 /**
  * Tests some general style plugin related functionality.
@@ -25,8 +26,8 @@
    * Stores a view output in the elements.
    */
   function storeViewPreview($output) {
-    $htmlDom = new \DOMDocument();
-    @$htmlDom->loadHTML($output);
+    $html5 = new HTML5();
+    $htmlDom = $html5->loadHTML('<html><body>' . $output . '</body></html>');
     if ($htmlDom) {
       // It's much easier to work with simplexml than DOM, luckily enough
       // we can just simply import our DOM tree.
