Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<style> pre { white-space:pre-line }</style>
<script src=https://google.github.io/closure-library/source/closure/goog/base.js></script>
<script>
  goog.require('goog.html.sanitizer.HtmlSanitizer');
  goog.require('goog.html.sanitizer.HtmlSanitizer.Builder');
  goog.require('goog.dom');
</script>
<textarea id=t></textarea>
<pre id=output></pre>
<div id=outnode></div>
<script>
  t.oninput = ev => {
    const sanitizer = new goog.html.sanitizer.HtmlSanitizer.Builder()
                      .allowStyleTag()
                      .build();
    
    let sanitized;
    try {
      sanitized = sanitizer.sanitize(t.value);
      output.textContent = sanitized.privateDoNotAccessOrElseSafeHtmlWrappedValue_;
      const node = goog.dom.safeHtmlToNode(sanitized);
      outnode.textContent = '';
      outnode.appendChild(node);
    } catch (ex) {
      output.textContent = '';
      outnode.textContent = 'Exception thrown: ' + ex;
      throw ex
    }
    
    
    
  }
  
  
</script>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers