- From: Thomas Di Grégorio <notifications@github.com>
- Date: Fri, 20 Jan 2017 15:59:59 -0800
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 21 January 2017 00:00:33 UTC
With ES6+ object destructuring it will become less a pain to do so:
```es6
let { connected, attributeChange, disconnected } = customElements.symbols;
export class MyClass extends HTMLElement {
[connected]() {}
[attributeChange]() {}
[disconnected]() {}
normalMethod() {}
}
// or an object in well known symbols
let { connected: onAdded, observedAttributes: attrs, disconnected: onRemove } = Symbol.elements;
export class MyClass extends HTMLElement {
static get [attrs]() { return ... }
[onAdded]() {}
[onRemove]() {}
normalMethod() {}
}
```
Still in plain old es5 you can write less than `[customElements.connected]` if you choose to:
```js
var S = customElements.symbols;
function MyClass() {}
MyClass.prototype = Object.create(HTMLElement.prototype);
MyClass[S.observedAttributes] = 'attr1 attr2 attr3'.split(' ')
MyClass.prototype[S.connected] = function() {}
...
```
This is highly customisable by web developpers using the Symbols.
--
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/414#issuecomment-274211545
Received on Saturday, 21 January 2017 00:00:33 UTC