- From: TAMURA, Kent <notifications@github.com>
- Date: Thu, 25 Oct 2018 21:43:52 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/758/433284667@github.com>
Some code examples and comments. * Pass ```ElementInternals``` to ```super()``` ```javascript class MyElement extends HTMLElement { constructor() { const myInternals = new ElementInternals(); // myInternals is inactive. All operations on myInternals throw exceptions. super(myInternals); // myInternals is active. } } ``` * ```createdCallback()```, invoked by ```super()``` Custom element users can steal ```ElementInternals``` instance by inheritance. Code by a custom element author: ```javascript class MyElement extends HTMLElement { createdCallback(internals) { this.internals_ = internals; } } ``` Code by a custom element user: ```javascript class MyElement2 extends MyElement { createdCallback(internals) { // This is called instead of MyElement's one. super.createdCallback(intrenals); } } ``` * Opt-in + ```this.attachInternals()``` ```javascript class MyElement extends HTMLElement { // static getter is better than define()'s option? static get needsElementInternals() { return true; } constructor() { super(); this.internals_ = this.attachInternals(); // attachInternals() throws if needsElementInternals doesn't exist or returns false. } } ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/758#issuecomment-433284667
Received on Friday, 26 October 2018 04:44:13 UTC