Created
May 25, 2020 02:22
-
-
Save jaredcwhite/6c652e9548701b0037b872c4c8cfe3fa to your computer and use it in GitHub Desktop.
LitElement web component which converts HTML markup to an uppercase and reversed string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LitElement, html } from "lit-element" | |
class UpcaseReverse extends LitElement { | |
connectedCallback() { | |
super.connectedCallback() | |
const observer = new MutationObserver(this.requestUpdate.bind(this)); | |
observer.observe(this, { characterData: true, subtree: true }) | |
} | |
render() { | |
const munged = this.textContent.toUpperCase().split("").reverse().join("") | |
return html`<div>${munged}</div>` | |
} | |
} | |
customElements.define('upcase-reverse', UpcaseReverse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See it in action! https://components.studio/edit/JssGVLyIYkNPggDH8N59