Skip to content

Instantly share code, notes, and snippets.

@AdaRoseCannon
Created October 11, 2017 23:40
Show Gist options
  • Save AdaRoseCannon/ecc847d8bba5eb9f522fc9bec6963817 to your computer and use it in GitHub Desktop.
Save AdaRoseCannon/ecc847d8bba5eb9f522fc9bec6963817 to your computer and use it in GitHub Desktop.
class HTMLElementWithRefs extends HTMLElement {
constructor () {
super();
this.refs = new Proxy({}, {
get: this.__getFromShadowRoot.bind(this)
});
}
__getFromShadowRoot (target, name) {
return this.shadowRoot.querySelector('[ref="' + name + '"]');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment