Skip to content

Instantly share code, notes, and snippets.

@AdaRoseCannon
Created October 11, 2017 23:40
Embed
What would you like to do?
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