Skip to content

Instantly share code, notes, and snippets.

@jaredcwhite
Created May 25, 2020 02:22
Show Gist options
  • Save jaredcwhite/6c652e9548701b0037b872c4c8cfe3fa to your computer and use it in GitHub Desktop.
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
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)
@jaredcwhite
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment