- From: Joseph Orbegoso Pea <notifications@github.com>
- Date: Tue, 07 Jun 2016 12:27:05 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc:
- Message-ID: <w3c/webcomponents/issues/517/224387603@github.com>
The `attribute` property could possibly be a setter on the `HTMLElement` base class, which is what could trigger the HTML engine to take note of the specified attributes. Alternatively, it could be a method: ```js class MyElement extends HTMLElement { constructor() { super() // optional this.defineAttributes([ "foo", "bar", ]) // optional, but does nothing if no attributes are defined. this.enableAttributeSettersGetters() } // if "foo" attribute was specified during creation (HTML engine would check // this after the constructor call), then it will use (if present) the // specified matching getter/setter on the instance to get/set values for the // attribute. This could be nice because it would mean that // this.getAttribute('foo') could return an object instead of a string, and // this.setAttribute('foo', ...) could accept anything, not just strings! set foo(value) { ... } get foo() { ... } } ``` But I think I like the `attributes` setter/getter better than a method, because then we require a second method like `getDefinedAttributes` or something (trying to avoid confusion with setAttribute/getAttribute). --- 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/517#issuecomment-224387603
Received on Tuesday, 7 June 2016 19:27:39 UTC