Re: document.register and ES6

>> Instead of passing in functions to document.register we can call methods
on the custom element.

My understanding is that the 'passing in functions' was a design decision,
not a technical one. IOW, Dimitri spec'd it that way so these (private)
lifecycle methods aren't just sitting there on the node's public API.

This technique certainly on the table to change, but I think it's improper
to deem it technical debt.

Scott


On Wed, Feb 6, 2013 at 9:03 AM, Erik Arvidsson <arv@chromium.org> wrote:

> On Tue, Feb 5, 2013 at 8:26 PM, Daniel Buchner <daniel@mozilla.com> wrote:
> > I have two questions:
> >
> > Does this affect our ability to polyfill doc.register in current
> browsers?
>
> Good point. This is really important to us as well so we most likely
> need to tweak this to make sure it will work.
>
> Do we need to be able to do "new MyButton" or is
> document.createElement/innerHTML/parser sufficient? If we need to be
> able to do "new" in the polyfill I think we either need to tweak
> document.register or get the developer to cooperate (by writing
> different code). At this point I don't see how we can tweak the API
> and still fulfill all of the requirements.
>
> > Are you saying we're going to nix the ability to easily register
> insertion,
> > removal, and attribute change callbacks from the API?
>
> No. I don't think there is any change here. Instead of passing in
> functions to document.register we can call methods on the custom
> element. For example:
>
> class MyButton extends HTMLButtonElement {
>   constructor() {
>     super();
>     this.moreInit();
>   }
>   handleAttributeChange(name, value) { ... }
>   moreInit() { ... }
>   ...
> }
> document.register('my-button', MyButton);
>
> instead of
>
> var myButtonPrototype = Object.create(HTMLButtonElement.prototype, {
>   handleAttributeChange: {
>     value: function(name, value) { ... },
>     enumerable: true,
>     configurable: true,
>     writable: true
>   },
>   moreInit: {
>     value: function() { ... },
>     enumerable: true,
>     configurable: true,
>     writable: true
>   },
>   ...
> });
>
> var MyButton = document.register('my-button', {
>   prototype:" myButtonPrototype,
>   created: function(element) {
>     element.moreInit();
>   },
>   attributeChange: function(element, name, value) {
>     element.handleAttibuteChange(name, value);
>   }
> });
>
> --
> erik
>
>

Received on Wednesday, 6 February 2013 18:38:58 UTC