devilbox/.devilbox/www/htdocs/assets/js/html-email.js
Merlijn 01fb99ec1a Added custom shadowdom element to view emails
WIthout the styling leaking into the global styling.
2021-02-21 14:40:16 +01:00

22 lines
461 B
JavaScript

class HtmlEmail extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
let emailContent;
try {
emailContent = window.atob(this.dataset.content);
} catch (error) {
console.log(error);
return;
}
const container = document.createElement('div');
container.innerHTML = emailContent;
this.shadowRoot.appendChild(container);
}
}
customElements.define('html-email', HtmlEmail);