Element wrapper for the Sanitize.js library (a whitelist-based HTML sanitizer)

[ This description is mirrored from README.md at github.com/howking/sanitize-element on 2019-05-22 ]

Build Status Published on webcomponents.org Polymer2.0 ES6


Element wrapper for the Sanitize.js library (a whitelist-based HTML sanitizer), to use <marked-element>.


  .logo { width: 32px; }

<sanitize-element config='{
   "elements": ["img"],
   }' sanitizer="{{sanitizer}}"></sanitize-element>

<marked-element sanitize sanitizer="[[sanitizer]]">
  <div slot="markdown-html"></div>
  <script type="text/markdown">
Markdown Image link `![image](url)`.


You can set `class` like `<img class="logo">` and remove other attributes (e.g. onclick).

<img class="logo"

Source block is escaped.

      <img class="logo"


Other config like this.

<sanitize-element config='{
  "attributes":{"__ALL__":["class"], "a":["href","title"], "img":["src"]},
  }' sanitizer="{{sanitizer}}"></sanitize-element>

<marked-element markdown="[[markdown]]" sanitize sanitizer="[[sanitizer]]">
  <div slot="markdown-html"></div>

Note: The config attribute must be double quoted JSON.

Install the Polymer-CLI

First, make sure you have the Polymer CLI installed. Then run polymer serve to serve your element locally.

Viewing Your Element

$ polymer serve

Running Tests

$ polymer test

Your application is already set up to be tested via web-component-tester. Run polymer test to run your application's test suite locally.


Link to this version
ImportedReleased 18 August 2017MIT License
Framework Support
Polymer 2.0+
Browser Compatibility
Install with
bower install --save howking/sanitize-element"#0.2.2"
Run the above Bower command in your project folder. If you have any issues installing, please contact the author.
Release notes - Version 0.2.2


  • sanitize#gbirke/Sanitize.js#v1.0.0
  • marked-element#PolymerElements/marked-element#^2.3.0
  • polymer#Polymer/polymer#^2.0.0