code: function _sanitizeHtml(defaultDoc, unsafeHtmlInput) {
      var inertBodyElement = null;
      try {
          inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc);
          // Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
          var unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
          inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
          // mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
          // trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
          var mXSSAttempts = 5;
          var parsedHtml = unsafeHtml;
          do {
              if (mXSSAttempts === 0) {
                  throw new Error('Failed to sanitize html because the input is unstable');
              }
              mXSSAttempts--;
              unsafeHtml = parsedHtml;
              parsedHtml = inertBodyElement.innerHTML;
              inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
          } while (unsafeHtml !== parsedHtml);
          var sanitizer = new SanitizingHtmlSerializer();
          var safeHtml = sanitizer.sanitizeChildren(getTemplateContent(inertBodyElement) || inertBodyElement);
          if (isDevMode() && sanitizer.sanitizedSomething) {
              console.warn('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
          }
          return safeHtml;
      }
      finally {
          // In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
          if (inertBodyElement) {
              var parent_1 = getTemplateContent(inertBodyElement) || inertBodyElement;
              while (parent_1.firstChild) {
                  parent_1.removeChild(parent_1.firstChild);
              }
          }
      }
  }
docs: Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
  the DOM in a browser environment.