Skip to content

Instantly share code, notes, and snippets.

@Ginden
Last active October 24, 2017 17:55
Show Gist options
  • Select an option

  • Save Ginden/03004e52b3d331e236b5256e3b4c08ff to your computer and use it in GitHub Desktop.

Select an option

Save Ginden/03004e52b3d331e236b5256e3b4c08ff to your computer and use it in GitHub Desktop.
const REALM = Symbol();
Object.define(HTMLElement.prototype, 'realm', {
get() {
if (!Reflect.has(this, REALM)) this[REALM] = window; // Your construction logic goes here
return this[REALM];
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment