diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js
index 7ddca90bba..a588bc66d9 100644
--- a/core/modules/filter/filter.filter_html.admin.js
+++ b/core/modules/filter/filter.filter_html.admin.js
@@ -242,32 +242,39 @@
         // Let the browser do the parsing work for us.
         sandbox.innerHTML = allowedTags[t];
         node = sandbox.firstChild;
-        tag = node.tagName.toLowerCase();
-
-        // Build the Drupal.FilterHtmlRule object.
-        rule = new Drupal.FilterHTMLRule();
-        // We create one rule per allowed tag, so always one tag.
-        rule.restrictedTags.tags = [tag];
-        // Add the attribute restrictions.
-        attributes = node.attributes;
-        for (var i = 0; i < attributes.length; i++) {
-          attribute = attributes.item(i);
-          var attributeName = attribute.nodeName;
-          // @todo Drupal.FilterHtmlRule does not allow for generic attribute
-          //   value restrictions, only for the "class" and "style" attribute's
-          //   values. The filter_html filter always disallows the "style"
-          //   attribute, so we only need to support "class" attribute value
-          //   restrictions. Fix once https://www.drupal.org/node/2567801 lands.
-          if (attributeName === 'class') {
-            var attributeValue = attribute.textContent;
-            rule.restrictedTags.allowed.classes = attributeValue.split(' ');
-          }
-          else {
-            rule.restrictedTags.allowed.attributes.push(attributeName);
-          }
+        // Not a valid child of a <div>
+        if (!node) {
+          node = document.createElement(allowedTags[t].substring(1, allowedTags[t].length - 1));
         }
 
-        rules[tag] = rule;
+        if (node) {
+          tag = node.tagName.toLowerCase();
+
+          // Build the Drupal.FilterHtmlRule object.
+          rule = new Drupal.FilterHTMLRule();
+          // We create one rule per allowed tag, so always one tag.
+          rule.restrictedTags.tags = [tag];
+          // Add the attribute restrictions.
+          attributes = node.attributes;
+          for (var i = 0; i < attributes.length; i++) {
+            attribute = attributes.item(i);
+            var attributeName = attribute.nodeName;
+            // @todo Drupal.FilterHtmlRule does not allow for generic attribute
+            //   value restrictions, only for the "class" and "style" attribute's
+            //   values. The filter_html filter always disallows the "style"
+            //   attribute, so we only need to support "class" attribute value
+            //   restrictions. Fix once https://www.drupal.org/node/2567801 lands.
+            if (attributeName === 'class') {
+              var attributeValue = attribute.textContent;
+              rule.restrictedTags.allowed.classes = attributeValue.split(' ');
+            }
+            else {
+              rule.restrictedTags.allowed.attributes.push(attributeName);
+            }
+          }
+
+          rules[tag] = rule;
+        }
       }
       return rules;
     },
