Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • About Bonfire
Firefox for Web Developers
Firefox for Web Developers
@firefoxwebdevs@mastodon.social  ·  activity timestamp 2 days ago

You can throw away innerHTML and replace it with the new setHTML(), which has a built-in sanitizer. Here's how it works:

Your browser does not support the video tag.
This video cannot be previewed
Open original
Sorry, no caption provided by author
  • Copy link
  • Flag this post
  • Block
Leonardo Di Ottio
Leonardo Di Ottio
@LeonardoDiOttio@mastodon.social  ·  activity timestamp yesterday

@firefoxwebdevs Looks great but why is it called setHTML? What is the ‘set’ supposed to mean?

#WebDev #HTML

  • Copy link
  • Flag this comment
  • Block
Firefox for Web Developers
Firefox for Web Developers
@firefoxwebdevs@mastodon.social  ·  activity timestamp yesterday

@LeonardoDiOttio I see what you're getting at, but replaceChildrenWithParsedHTML is a bit long.

Fwiw when you set innerHTML you're not really setting the HTML either.

  • Copy link
  • Flag this comment
  • Block
Jon Koops 🇪🇺
Jon Koops 🇪🇺
@jonkoops@mastodon.social  ·  activity timestamp 2 days ago

@firefoxwebdevs Fantastic! Can’t wait for this to be in baseline!

  • Copy link
  • Flag this comment
  • Block
Firefox for Web Developers
Firefox for Web Developers
@firefoxwebdevs@mastodon.social  ·  activity timestamp 2 days ago

Here are the full docs https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API

HTML Sanitizer API - Web APIs | MDNMDN

The HTML Sanitizer API allows developers to take strings of HTML and filter out unwanted elements, attributes, and other HTML entities when they are inserted into the DOM or a shadow DOM.
  • Copy link
  • Flag this comment
  • Block
Xela
Xela
@xela@troet.cafe  ·  activity timestamp 2 days ago

@firefoxwebdevs awesome! Now we only have to wait for "baseline" 😉

  • Copy link
  • Flag this comment
  • Block
Firefox for Web Developers
Firefox for Web Developers
@firefoxwebdevs@mastodon.social  ·  activity timestamp 2 days ago

@xela hopefully it won't be too long! Just Safari to go

  • Copy link
  • Flag this comment
  • Block

BT Free Social

BT Free is a non-profit organization founded by @ozoned@btfree.social . It's goal is for digital privacy rights, advocacy and consulting. This goal will be attained by hosting open platforms to allow others to seamlessly join the Fediverse on moderated instances or by helping others join the Fediverse.

BT Free Social: About · Code of conduct · Privacy ·
Bonfire social · 1.0.2-alpha.34 no JS en
Automatic federation enabled
Log in
Instance logo
  • Explore
  • About
  • Code of Conduct